Architectural Overview
Shannon emulates a human penetration tester’s methodology using a sophisticated multi-agent architecture. It combines white-box source code analysis with black-box dynamic exploitation across four distinct phases.Core Modules
Session Manager
Location:src/session-manager.ts
The session manager defines all agents and their relationships through the AGENTS registry:
- Agent definitions with prerequisites (dependency graph)
- Prompt template mappings
- Deliverable filename conventions
- Model tier selection (small/medium/large)
src/types/agents.ts defines the AgentName and AgentDefinition types.
Temporal Orchestration
Location:src/temporal/workflows.ts, src/temporal/activities.ts
Shannon uses Temporal for durable workflow orchestration with:
- Crash recovery - Workflows resume after failures
- Queryable progress - Real-time status via
getProgressquery - Intelligent retry - Automatic backoff for transient/billing errors
- Parallel execution - 5 concurrent agents in vuln/exploit phases
Workflow Structure
The main workflow (pentestPipelineWorkflow) orchestrates five phases:
- Pre-Recon - External scans + source code analysis
- Recon - Attack surface mapping
- Vulnerability Analysis - 5 parallel agents (injection, xss, auth, authz, ssrf)
- Exploitation - 5 parallel agents (conditional on vuln findings)
- Reporting - Executive-level security report
Activity Pattern
Activities follow a two-layer pattern:-
Activity wrapper (
src/temporal/activities.ts) - Thin wrapper with:- Heartbeat loop for crash recovery
- Error classification
- Container lifecycle management
-
Service layer (
src/services/) - Business logic:- Temporal-agnostic
- Accepts
ActivityLoggerinterface - Returns
Result<T, E>for error handling
AI Integration
Location:src/ai/claude-executor.ts
Shannon uses the @anthropic-ai/claude-agent-sdk with:
maxTurns: 10_000- Allows long-running analysisbypassPermissionsmode - For autonomous operation- Playwright MCP - Browser automation
- TOTP MCP tool - 2FA code generation
Model Tiers
Shannon uses three model tiers:- Small (
claude-haiku-4-5) - Summarization, reporting - Medium (
claude-sonnet-4-6) - Security analysis, exploitation - Large (
claude-opus-4-6) - Deep reasoning, code analysis
Configuration System
Location:src/config-parser.ts
YAML configurations with JSON Schema validation (config-schema.json) support:
- Authentication settings (form, SSO, API, basic auth)
- MFA/TOTP credentials
- Login flow templates
- Success condition verification
- Testing rules (avoid/focus areas)
Prompt System
Location:src/services/prompt-manager.ts, prompts/
Prompts are stored as .txt templates with:
- Variable substitution:
{{TARGET_URL}},{{CONFIG_CONTEXT}},{{LOGIN_INSTRUCTIONS}} - Include directives:
@include(shared/_target.txt)for shared partials - MCP server assignment: Automatic Playwright instance allocation
Five-Phase Pipeline
Phase 1: Pre-Reconnaissance
Agent:pre-reconTemplate:
prompts/pre-recon-code.txtDeliverable:
code_analysis_deliverable.md
Purpose: Build a comprehensive map of the application’s attack surface through:
- External scans (nmap, subfinder, whatweb)
- Source code analysis
- Technology stack identification
- Initial entry point discovery
Phase 2: Reconnaissance
Agent:reconTemplate:
prompts/recon.txtDeliverable:
recon_deliverable.md
Purpose: Live application exploration via browser automation to:
- Correlate code-level insights with real-world behavior
- Map all entry points and API endpoints
- Identify authentication mechanisms
- Build detailed attack surface map
Phase 3: Vulnerability Analysis
Agents: 5 parallel agents (injection, xss, auth, authz, ssrf)Templates:
prompts/vuln-*.txtDeliverables:
*_analysis_deliverable.md + *_exploitation_queue.json
Using reconnaissance data, specialized agents hunt for flaws in parallel:
- Injection/SSRF: Structured data flow analysis (source → sink)
- XSS: Output context analysis and encoding verification
- Auth/Authz: Logic flow analysis and access control gaps
- Analysis deliverable (findings documentation)
- Exploitation queue (hypothesized exploitable paths)
Phase 4: Exploitation
Agents: 5 parallel agents (conditional on queue presence)Templates:
prompts/exploit-*.txtDeliverables:
*_exploitation_evidence.md
“No Exploit, No Report” Policy: Only validated exploits are reported.
Agents receive hypothesized paths and attempt real-world attacks using:
- Browser automation (Playwright)
- Command-line tools
- Custom scripts
Phase 5: Reporting
Agent:reportTemplate:
prompts/report-executive.txtDeliverable:
comprehensive_security_assessment_report.md
Consolidates all validated findings into a professional report with:
- Executive summary
- Reproducible proof-of-concepts (copy-and-paste)
- Severity classifications
- Remediation guidance
Supporting Systems
Audit System
Location:src/audit/
Crash-safe append-only logging in audit-logs/{hostname}_{sessionId}/:
session.json- Session metrics and metadataagents/- Per-agent execution logsprompts/- Prompt snapshots for reproducibilitydeliverables/- Final reports and evidence
audit/workflow-logger.ts) provides unified human-readable logs, backed by LogStream (audit/log-stream.ts) shared stream primitive.
Workspaces and Resume
Location:src/temporal/client.ts, src/temporal/activities.ts
Named workspaces via WORKSPACE=<name> or auto-named from URL+timestamp.
Resume mechanism:
loadResumeState()in activities loadssession.json- Validates deliverable existence for completed agents
- Restores git checkpoints
- Cleans up incomplete deliverables
- Skips completed agents in workflow execution
src/temporal/workspaces.ts.
Container Management
Location:src/services/container.ts
DI container per workflow provides:
- Service initialization
- Dependency injection
- Shared instances across activities
- Excludes
AuditSession(parallel safety)
Error Handling
Location:src/services/error-handling.ts, src/types/errors.ts
Modular error handling with:
- ErrorCode enum - Categorized error types
- Result type - Explicit error propagation with typed success/error values
- Automatic retry - 3 attempts per agent with backoff
- Non-retryable classification - Permanent errors skip retry
AuthenticationError- API key issuesBillingError- Rate limits, quota exceededConfigurationError- Invalid configExecutionLimitError- Spending caps reached
Key Design Patterns
Configuration-Driven
YAML configs with JSON Schema validation enable:- Type-safe configuration parsing
- Validation at load time
- Clear error messages for misconfigurations
Progressive Analysis
Each phase builds on previous results:- Pre-recon → Recon (attack surface)
- Recon → Vuln Analysis (entry points)
- Vuln Analysis → Exploitation (hypotheses)
- Exploitation → Reporting (validated findings)
SDK-First
Claude Agent SDK handles autonomous analysis:- No prompt engineering required for tool use
- Automatic MCP tool discovery
- Self-directed browsing and exploration
Services Boundary
Strict separation between Temporal and business logic:- Activities are thin wrappers (heartbeat + error handling)
- Services own business logic (Temporal-agnostic)
- Services accept
ActivityLogger, returnResult<T, E> - No Temporal imports in services
Modular Error Handling
Explicit error propagation with:ErrorCodeenum for categorizationResult<T, E>monad for safe error handling- Automatic retry logic with backoff
- Non-retryable classification for permanent errors
Code Style Guidelines
SeeCLAUDE.md in the source repository for complete guidelines. Key points:
- Clarity over brevity - Optimize for readability
- Function keyword for top-level functions
- Explicit return types on exported functions
- No nested ternaries - Use if/else or switch
- Numbered steps for multi-phase functions
- Timeless comments - No conversation references
Key Files
Entry Points:src/temporal/workflows.ts- Main workflowsrc/temporal/activities.ts- Activity wrapperssrc/temporal/worker.ts- Worker entry pointsrc/temporal/client.ts- CLI client
src/session-manager.ts- Agent registrysrc/ai/claude-executor.ts- SDK integrationsrc/config-parser.ts- Config parsingsrc/services/- Business logicsrc/audit/- Audit system
shannon- CLI tooldocker-compose.yml- Container orchestrationconfigs/- YAML configsprompts/- Prompt templates
- Adding Agents - Extending Shannon with new agents
- Custom Prompts - Customizing agent behavior