Skip to content
Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Plamen β€” Web3 Security Auditor for Claude Code

An autonomous smart contract security audit agent for Claude Code. Orchestrates 15–95 specialized AI agents across 8 phases to produce comprehensive security audit reports β€” from reconnaissance to verified PoC exploits.

Supports EVM/Solidity, Solana/Anchor, Aptos Move, and Sui Move via a tree architecture with shared rules and language-specific analysis branches.

Built for Claude Opus 4.6 (1M context). Works on Max (Core/Thorough) and Pro (Light mode) subscriptions.


Quick Start

Shell: All commands use Unix syntax. On Windows, use Git Bash (included with Git for Windows). On macOS/Linux, use your regular terminal. If pip/python don't work, try pip3/python3 instead.

Why ~/.claude? Claude Code reads its configuration, slash commands, agent definitions, and MCP server settings from ~/.claude/. This is not configurable β€” the repo must be cloned to this exact location for /plamen and all pipeline features to work.

Existing Claude Code users: ~/.claude will be overwritten. Back up your existing config first:

mv ~/.claude ~/.claude.backup
# 1. Clone into ~/.claude (required β€” Claude Code reads config from this path)
git clone https://github.com/PlamenTSV/plamen.git ~/.claude
cd ~/.claude

# 2. Initialize submodules (slither-mcp, farofino-mcp)
git submodule update --init --recursive

# 3. Install Python deps
pip install -r requirements.txt

# 4. Install MCP server deps (~2GB download β€” includes PyTorch for embeddings)
pip install -r custom-mcp/unified-vuln-db/requirements.txt
pip install -r custom-mcp/solodit-scraper/requirements.txt
pip install -r custom-mcp/defihacklabs-rag/requirements.txt
pip install -e custom-mcp/solana-fender
pip install -r custom-mcp/farofino-mcp/requirements.txt

# 4b. EVM users only β€” install slither MCP (requires Python 3.11+, solc)
pip install -e custom-mcp/slither-mcp    # skip if not auditing Solidity

# 5. Configure MCP servers + API keys (BEFORE building RAG)
cp mcp.json.example mcp.json
cp settings.json.example settings.json
# Edit mcp.json β€” add your API keys (see Configuration below)
# At minimum, get a free Solodit key: https://solodit.cyfrin.io
# Then set it for the current shell:
export SOLODIT_API_KEY=your_key_here     # needed for step 6

# 6. Build the RAG vulnerability database (~5 min, requires internet)
#    Without SOLODIT_API_KEY: only ~700 entries indexed (vs ~4000 with it)
cd custom-mcp/unified-vuln-db
python -m unified_vuln.indexer index -s solodit --max-pages 10
python -m unified_vuln.indexer index -s defihacklabs
python -m unified_vuln.indexer index -s immunefi
cd ../..

# 7. Run (terminal wrapper with interactive UI)
python plamen.py
# Or from Claude Code: /plamen
# Or add ~/.claude to PATH and just type: plamen

You'll need a smart contract project to audit (e.g., a Foundry or Hardhat project). The Setup menu inside the wrapper can install chain-specific tools (Foundry, Solana, Aptos, Sui) for you.

Having trouble? Open Claude Code and paste the contents of SETUP.md β€” it contains step-by-step instructions that Claude Code can follow to install everything for you automatically.


Table of Contents


Architecture

                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚       ORCHESTRATOR (CLAUDE.md)   β”‚
                          β”‚  Detects language, reads phase   β”‚
                          β”‚  prompts, spawns agents,         β”‚
                          β”‚  enforces gates                  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό                          β–Ό                          β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  Phase 1     β”‚          β”‚  Phase 2     β”‚          β”‚  Phase 3     β”‚
   β”‚  RECON       │───────►  β”‚  INSTANTIATE │───────►  β”‚  BREADTH     β”‚
   β”‚  (4 agents)  β”‚          β”‚  (orchestr.) β”‚          β”‚  (2-7 agents)β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                                              β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  Phase 3b    β”‚     β”‚  Phase 3c    β”‚     β”‚  Phase 4a       β”‚
   β”‚  RE-SCAN     │──►  β”‚  PER-CONTRACT│──►  β”‚  INVENTORY      β”‚
   β”‚  (sonnet,    β”‚     β”‚  (sonnet,    β”‚     β”‚  + Side Effect  β”‚
   β”‚   2 iters)   β”‚     β”‚   1/cluster) β”‚     β”‚  Trace Audit    β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                    β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  Phase 4a.5  β”‚     β”‚  Phase 4b       β”‚     β”‚  Phase 4c    β”‚
   β”‚  SEMANTIC    │──►  β”‚  DEPTH LOOP     │──►  β”‚  CHAIN       β”‚
   β”‚  INVARIANTS  β”‚     β”‚  (8+ agents Γ—   β”‚     β”‚  ANALYSIS    β”‚
   β”‚  (sonnet)    β”‚     β”‚   1-3 iters)    β”‚     β”‚  + Enablers  β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  + Niche agents β”‚     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚  + Inv. Fuzz    β”‚            β”‚
                        β”‚  + Medusa Fuzz  β”‚            β”‚
                        β”‚  + Design Stressβ”‚            β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚
                                                       β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  Phase 5     β”‚     β”‚  Phase 5.1   β”‚     β”‚  Phase 6         β”‚
   β”‚  VERIFY      │──►  β”‚  SKEPTIC-    │──►  β”‚  REPORT          β”‚
   β”‚  (N verifier β”‚     β”‚  JUDGE       β”‚     β”‚  Index β†’ 3 Tier  β”‚
   β”‚   agents)    β”‚     β”‚  (Thorough)  β”‚     β”‚  Writers β†’       β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  Assembler       β”‚
                                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                      β”‚
                                                      β–Ό
                                               AUDIT_REPORT.md

The workflow is fully autonomous β€” provide a smart contract project and optionally documentation. The orchestrator detects the language, loads the appropriate branch, and handles everything from pattern detection to PoC verification to final report assembly.


Audit Modes

Dimension Light Core Thorough
Target plan Pro Max Max
Agent models All Sonnet/Haiku Opus + Sonnet Opus + Sonnet
Recon 2 sonnet (no RAG) 4 agents 4 agents (full RAG)
Breadth 2-3 sonnet 2-7 opus 2-7 opus
Re-scan (3b/3c) Skip Skip Full (2 iter + per-contract)
Depth loop 4 merged sonnet, iter 1 8+ agents, iter 1 Iter 1-3 (Devil's Advocate)
Niche agents Skip Flag-triggered Flag-triggered
Semantic invariants Skip (state consistency tradeoff) Pass 1 Pass 1 + Pass 2
Confidence scoring None (verdicts only) 2-axis 4-axis
RAG Sweep Skip 1 haiku 1 haiku
Invariant / Medusa fuzz Skip Skip Yes (EVM)
Chain analysis 1 sonnet (merged) 2 agents 2 agents + iteration 2
Verification (PoC) Medium+ (sonnet) Medium+ ALL severities + fuzz
Skeptic-Judge Skip Skip HIGH/CRIT
Report 2 agents 5 agents 5 agents
Agent count ~15-18 ~25-45 ~35-95

Proven-only mode (--proven-only): Available in all modes. Caps findings with only [CODE-TRACE] evidence (no executed PoC or fuzzer counterexample) at Low severity. Useful for benchmark comparisons where only mechanically proven findings should drive severity.


How It Works

Phase 1: Reconnaissance (4 parallel agents)

Split into 4 agents to prevent timeout:

  • Agent 1A (sonnet): RAG queries β€” unified-vuln-db, Solodit live search
  • Agent 1B (opus): Documentation parsing, fork ancestry research, trust model extraction
  • Agent 2 (sonnet): Build environment, static analysis (Slither β†’ Farofino/Aderyn β†’ grep fallback), test suite
  • Agent 3 (opus): Pattern detection, attack surface mapping, template recommendations with BINDING MANIFEST

Produces 17+ scratchpad artifacts consumed by all downstream phases.

Phase 2: Instantiation (orchestrator)

Reads the BINDING MANIFEST, resolves skill templates, applies merge hierarchy (max 3 skills/agent), and composes agent prompts with instantiated parameters.

Phase 3: Parallel Breadth Analysis (2-7 agents)

All agents spawned in a single message. Each runs a targeted sweep per vulnerability class across its scope, producing findings with precondition/postcondition analysis.

Phase 3b/3c: Re-Scan + Per-Contract (Thorough only)

  • Re-scan: 2-3 sonnet agents re-analyze with an exclusion list of known findings. Counters LLM attention saturation.
  • Per-contract: 1 agent per contract/cluster at maximum depth. Zero distraction from other contracts.

Phase 4a: Inventory + Side Effect Trace

Consolidates all findings, promotes static analysis results, performs side effect trace audit on external token interactions.

Phase 4a.5: Semantic Invariant Pre-Computation

Sonnet agent enumerates write sites, defines semantic invariants, detects mirror variables, flags conditional writes and accumulation exposures. Pass 2 (Thorough) traces consequences recursively.

Phase 4b: Adaptive Depth Loop (8+ agents Γ— 1-3 iterations)

Iteration 1 (always): 4 depth agents + 3 blind spot scanners + validation sweep + niche agents, all in parallel.

Depth Agent Model Focus
depth-token-flow opus Balance invariants, mint/burn, transfer side effects
depth-state-trace opus Cross-function state mutation, constraint enforcement
depth-edge-case sonnet Boundary values, zero state, overflow, first-user
depth-external sonnet External call effects, oracle integrity, cross-chain timing
Scanner Focus
Blind Spot A External token coverage, parameter governance, msg.value loops, returnbomb
Blind Spot B Guards, visibility, inheritance, override safety
Blind Spot C Role lifecycle, capability exposure, reachability
Validation Sweep Write completeness, struct validation, sibling propagation

Niche agents (flag-triggered, 1 budget slot each):

  • EVENT_COMPLETENESS β€” event emission coverage
  • SEMANTIC_GAP_INVESTIGATOR β€” sync gaps, accumulation exposure, conditional writes
  • SPEC_COMPLIANCE_AUDIT β€” spec-to-code compliance
  • SIGNATURE_VERIFICATION_AUDIT β€” replay, malleability, EIP-712, nonces
  • SEMANTIC_CONSISTENCY_AUDIT β€” cross-contract unit mismatches, formula drift, magic numbers

Invariant fuzzing (EVM Thorough only):

  • Foundry invariant fuzz campaign (from semantic invariants)
  • Medusa stateful fuzz campaign (parallel, standalone harness, 15-min timeout)

Iterations 2-3 (Thorough): Devil's Advocate agents re-examine uncertain findings with structural adversarial role, contrastive path summaries, fresh MCP calls.

Confidence scoring (haiku, batched): 4-axis model (Evidence Γ— 0.25 + Consensus Γ— 0.25 + Analysis Quality Γ— 0.3 + RAG Match Γ— 0.2). Routes findings to CONFIDENT/UNCERTAIN/LOW_CONFIDENCE with severity-weighted spawn priority.

Phase 4c: Chain Analysis (2 sequential agents)

  • Agent 1: Exhaustive enabler enumeration (5 actor categories per dangerous state), finding grouping with anti-absorption rules
  • Agent 2: Postconditionβ†’precondition chain matching, composition coverage map, RAG validation for chains

Phase 5: Verification (parallel verifiers)

Mandatory PoC execution. Every finding gets:

  1. Written PoC from language-specific templates
  2. Compiled and executed (max 5 retry attempts with structured recovery)
  3. Fuzz variant (Medium+, Thorough mode)
  4. Evidence tagged: [POC-PASS], [POC-FAIL], [CODE-TRACE], [MEDUSA-PASS]

Pre-PoC feasibility gates (Reachability + Math Bounds) prevent wasted verification effort.

Phase 5.1: Skeptic-Judge (Thorough, HIGH/CRIT only)

After standard verification:

  1. Skeptic (sonnet): INVERSION MANDATE β€” if standard said CONFIRMED, skeptic tries to REFUTE, and vice versa
  2. If skeptic AGREES β†’ high confidence (dual-confirmed)
  3. If skeptic DISAGREES β†’ Judge (haiku): "prove it or lose it" β€” stronger mechanical evidence wins

Phase 6: Report Generation (5 agents)

  • Index Agent (haiku): Clean ID assignment, root-cause consolidation, tier assignment, strict mode demotion
  • 3 Tier Writers (parallel): Opus for Critical+High, Sonnet for Medium, Sonnet for Low+Info
  • Assembler (haiku/sonnet): Merges sections, quality checks, writes AUDIT_REPORT.md

Language Support

Tree architecture β€” shared root with language-specific branches. No file contains content for more than one language.

Language Skills Build Static Analysis Fuzz On-chain
EVM/Solidity 18 Foundry, Hardhat Slither MCP, Farofino/Aderyn, grep Foundry invariant, Medusa etherscan, fork testing
Solana/Anchor 19 Anchor, cargo-build-sbf Fender MCP, grep Trident, proptest Helius
Aptos Move 21 aptos move compile Move Prover, grep Boundary-value parameterized β€”
Sui Move 21 sui move build grep Boundary-value parameterized β€”

Language detection is automatic (Step 0) based on config files and source file patterns.


Skill System

Skills are methodology files loaded into agents at instantiation time. Three tiers:

Standard Skills (per-language tree)

Always-available skills triggered by pattern flags from recon. Examples: ORACLE_ANALYSIS, SEMI_TRUSTED_ROLES, TOKEN_FLOW_TRACING, FLASH_LOAN_INTERACTION.

Injectable Skills (protocol-type-specific)

Loaded only when recon classifies the protocol as a matching type. Appended to existing agents (no new agent spawned):

Skill Trigger
VAULT_ACCOUNTING vault protocol type
ACCOUNT_ABSTRACTION_SECURITY ERC-4337, EntryPoint, UserOperation
NFT_PROTOCOL_SECURITY ERC721/1155 with marketplace/staking/collateral
GOVERNANCE_ATTACK_VECTORS Governor, Timelock, voting, proposal
OUTCOME_DETERMINISM Finite-pool selection with depletion fallback + time-gated actions

Niche Agents (flag-triggered standalone)

Spawn as independent agents (1 depth budget slot each). Used when a concern needs dedicated focus:

Agent Trigger Checks
EVENT_COMPLETENESS MISSING_EVENT Event coverage, parameter accuracy, cross-contract gaps
SEMANTIC_GAP_INVESTIGATOR Semantic invariant flags SYNC_GAP, ACCUMULATION_EXPOSURE, CONDITIONAL, CLUSTER_GAP
SPEC_COMPLIANCE_AUDIT HAS_DOCS Spec-to-code compliance, testable claim verification
SIGNATURE_VERIFICATION_AUDIT HAS_SIGNATURES Replay, malleability, EIP-712, permit, nonces
SEMANTIC_CONSISTENCY_AUDIT HAS_MULTI_CONTRACT Unit mismatches, formula drift, magic number consistency

Security Rules

16 rules (R1–R16) enforced across all agents:

Rule Name Summary
R1 External Return Types Verify all external call return values
R2 Keeper/Admin Griefability Check both directions of privileged action abuse
R3 Transfer Side Effects Document token type and side effects
R4 Adversarial Assumption CONTESTED/unknown β†’ assume adversarial
R5 Combinatorial Impact N-entity systems need combinatorial analysis
R6 Bidirectional Role Semi-trusted roles analyzed in both directions
R7 Donation-based DoS Check thresholds vulnerable to donations
R8 Cached Parameters Multi-step ops with stale external state
R9 Stranded Assets Check recovery paths for locked funds
R10 Worst-State Severity Use worst realistic state, not current snapshot
R11 Unsolicited Token Transfer Trace impact of uninitiated transfers
R12 Exhaustive Enabler Enum 5 actor categories per dangerous state
R13 Anti-Normalization "By design" is not a valid severity dismissal
R14 Cross-Variable Invariant Aggregate variables, constraint coherence, setter regression
R15 Flash Loan Precondition Flash-loan-accessible state manipulation
R16 Oracle Integrity Staleness, decimals, zero, failure modes

MCP Servers

Plamen uses 9 MCP servers configured in mcp.json. 2 are bundled in custom-mcp/, 2 are git submodules, 5 are npm packages. Two additional bundled libraries (solodit-scraper, defihacklabs-rag) serve as data sources for the RAG database.

Bundled (custom-mcp/)

Server Purpose Required?
unified-vuln-db RAG vulnerability database β€” Solodit, DeFiHackLabs, Immunefi. Semantic search, hypothesis validation, root cause analysis Required
solodit-scraper Solodit API scraper with SQLite cache, rate limiting Required by unified-vuln-db
defihacklabs-rag DeFiHackLabs exploit analysis with ChromaDB embeddings Optional (enriches RAG)
solana-fender Solana program static security analysis Optional (Solana only)

Submodules (custom-mcp/)

Server Purpose Required?
slither-mcp Slither static analyzer by Trail of Bits Optional (EVM, falls back to grep)
farofino-mcp Aderyn + pattern analysis fallback Optional (EVM, when Slither fails)

npm Packages (installed on demand via npx)

Server Purpose API Key?
foundry-suite Anvil fork testing, Forge scripts, Heimdall bytecode No
evm-chain-data On-chain ABI/state queries via Etherscan Optional (free key)
tavily-search Web search for fork ancestry + documentation Optional (free key)
helius Solana on-chain account/transaction data Optional (free key)
memory Persistent memory across sessions No

Prerequisites

Required

Tool Purpose Install
Claude Code CLI The AI runtime docs.anthropic.com
Python 3.11+ MCP servers, plamen.py wrapper python.org
Node.js 18+ / npx npm MCP servers (foundry-suite, tavily, etc.) nodejs.org
Git Dependency resolution, submodules git-scm.com

Per-Language (install what you need)

EVM/Solidity:

Tool Purpose Install
Foundry (forge, anvil, cast) Build, test, fork testing curl -L https://foundry.paradigm.xyz | bash && foundryup
Slither Static analysis pip install slither-analyzer
Medusa Stateful fuzzing (Thorough mode) github.com/crytic/medusa

Solana:

Tool Purpose Install
Solana CLI Toolchain, account dumps docs.anza.xyz
Anchor Build Anchor programs avm install latest && avm use latest
Trident Stateful fuzzing cargo install trident-cli

Aptos Move:

Tool Purpose Install
Aptos CLI Build, test, prove aptos.dev/build/cli

Sui Move:

Tool Purpose Install
Sui CLI Build, test docs.sui.io

Installation

1. Clone and initialize

git clone https://github.com/PlamenTSV/plamen.git ~/.claude
cd ~/.claude
git submodule update --init --recursive

Note: This clones into ~/.claude which is where Claude Code looks for its configuration. If you already have a ~/.claude directory, back it up first.

2. Install Python dependencies

# Plamen wrapper
pip install -r requirements.txt

# MCP servers (~2GB download β€” includes PyTorch for embeddings)
pip install -r custom-mcp/unified-vuln-db/requirements.txt
pip install -r custom-mcp/solodit-scraper/requirements.txt
pip install -r custom-mcp/defihacklabs-rag/requirements.txt
pip install -e custom-mcp/solana-fender
pip install -r custom-mcp/farofino-mcp/requirements.txt

# EVM users only (requires Python 3.11+, solc)
pip install -e custom-mcp/slither-mcp

3. Configure MCP servers and API keys

cp mcp.json.example mcp.json
cp settings.json.example settings.json

Edit mcp.json with your API keys. See Configuration. At minimum, get a free Solodit API key β€” it's needed to index the largest RAG data source (3400+ findings).

The default settings.json.example auto-approves all tool calls required for autonomous auditing. Critical permissions β€” removing any of these will break the pipeline:

Permission Why Required
Agent(*) Spawns all subagents (depth, scanner, verifier, chain analysis). Without this, the pipeline silently fails.
Bash(*) Runs forge build/test, cargo test, aptos move test, etc.
Read(*), Write(*), Edit(*) Reads source code, writes PoC tests, edits scratchpad artifacts
mcp__* All MCP server tool calls (Slither, RAG, Solodit, Foundry, etc.)

The deny list blocks destructive operations (rm -rf, sudo, force push). Review and adjust if desired.

The env block sets MCP timeouts: MCP_TIMEOUT (30s connection) and MCP_TOOL_TIMEOUT (300s = 5 min execution). The 5-minute tool timeout accounts for ChromaDB cold start on first use β€” the RAG database and embedding model load into memory on the first MCP call per session, which can take 1-5 minutes. After warm-up, calls return in seconds.

4. Build the RAG database

Set your Solodit key first, then build:

export SOLODIT_API_KEY=your_key_here

See Building the RAG Database for full instructions.

5. Verify installation

python plamen.py

The startup screen runs a dependency check showing which tools are available.


Configuration

mcp.json

Copy mcp.json.example to mcp.json and configure:

The example below shows a subset. Copy mcp.json.example for the full 9-server configuration including solana-fender, farofino, and memory.

{
  "mcpServers": {
    "slither-analyzer": {
      "command": "slither-mcp",
      "args": []
    },
    "unified-vuln-db": {
      "command": "python",
      "args": ["-m", "unified_vuln.server"],
      "cwd": "./custom-mcp/unified-vuln-db"
    },
    "foundry-suite": {
      "command": "npx",
      "args": ["-y", "@pranesh.asp/foundry-mcp-server"],
      "env": { "RPC_URL": "YOUR_RPC_URL" }
    },
    "evm-chain-data": {
      "command": "npx",
      "args": ["-y", "@mcpdotdirect/evm-mcp-server"],
      "env": { "ETHERSCAN_API_KEY": "YOUR_KEY" }
    },
    "tavily-search": {
      "command": "npx",
      "args": ["-y", "tavily-mcp"],
      "env": { "TAVILY_API_KEY": "YOUR_KEY" }
    },
    "helius": {
      "command": "npx",
      "args": ["-y", "helius-mcp@latest"],
      "env": { "HELIUS_API_KEY": "YOUR_KEY" }
    }
  }
}

Path notes: The cwd fields use relative paths (./custom-mcp/...). Claude Code resolves these relative to ~/.claude/. If you installed elsewhere, use absolute paths.

API Keys

Key Where to Get Cost Used For
Solodit solodit.cyfrin.io Free RAG database indexing (3400+ findings) + live search
Etherscan etherscan.io/apis Free Contract ABI verification
Tavily tavily.com Free tier Fork ancestry web search, RAG fallback
Helius helius.dev Free tier Solana on-chain data
RPC URL Alchemy, Infura, or public Free/Paid Fork testing

All keys are optional. The pipeline degrades gracefully β€” missing keys mean reduced coverage, not failure. You can leave YOUR_* placeholders in mcp.json and the pipeline will skip those services.

Recommended: Get the free Solodit API key β€” it provides 3400+ indexed findings vs ~700 without it. The Tavily key is also recommended as the WebSearch fallback when RAG MCP tools are slow on first use.


Building the RAG Database

The unified-vuln-db MCP server uses a ChromaDB vector database populated from three sources. Build it before your first audit.

Quick build (~5 minutes)

cd custom-mcp/unified-vuln-db

# Index from all sources
python -m unified_vuln.indexer index -s solodit --max-pages 10
python -m unified_vuln.indexer index -s defihacklabs
python -m unified_vuln.indexer index -s immunefi

# Verify
python -m unified_vuln.indexer stats

Full build (~30 minutes, better RAG quality)

# Index ALL Solodit findings (thousands of pages)
python -m unified_vuln.indexer index -s solodit --max-pages 100

# Clone DeFiHackLabs dataset for deeper coverage
git clone https://github.com/SunWeb3Sec/DeFiHackLabs.git data/DeFiHackLabs
python -m unified_vuln.indexer index -s defihacklabs

# Immunefi
python -m unified_vuln.indexer index -s immunefi

Rebuild from scratch

python -m unified_vuln.indexer clear
# Then run the index commands above

The data/ directory (ChromaDB, caches) is gitignored. Each user builds their own database.

Cold start note

The first MCP tool call in each Claude Code session loads the ChromaDB database and sentence-transformers embedding model into memory. This can take 1-5 minutes depending on your hardware. Subsequent calls are instant. The pipeline handles this automatically β€” the recon agent's probe-first pattern detects slow MCP responses and falls back to WebSearch (Tavily) or code-level analysis.


Two Ways to Run

Plamen can be launched from its dedicated terminal wrapper or from inside Claude Code. Both go through the same audit pipeline β€” the difference is how you start it.

Option A: Terminal Wrapper (recommended for first-time setup)

The terminal wrapper is a standalone Rich + InquirerPy application that handles dependency checking, tool installation, cost estimation, and launches Claude Code for you.

plamen

This opens an interactive UI with arrow-key menus:

 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—      β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—
 β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
 β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘
 β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
 β•šβ•β•     β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•β•šβ•β•     β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•β•β•

⬑ Web3 Security Auditor  v1.0.0

> Select audit mode:
    Light      15-18 agents | Pro plan  | best under 3k LOC
    Core       25-45 agents | Max plan  | ALL severities
    Thorough   35-95 agents | Max plan  | ALL severities + fuzz
    ──────────
    Compare    variable     | DELTA report
    Setup      install tools + build RAG DB

The Setup option shows your full toolchain status and lets you install missing tools (Foundry, Solana, Aptos, Sui, Medusa, etc.) and build the RAG database β€” all from the same UI, with automatic prerequisite detection and cross-platform support (Windows, macOS, Linux).

After selecting a mode, the wrapper walks you through target selection, documentation, scope, proven-only mode, shows a cost estimate, then hands off to Claude Code.

To make plamen available as a command, add ~/.claude to your PATH:

# Unix/macOS β€” add to ~/.bashrc or ~/.zshrc
export PATH="$HOME/.claude:$PATH"

# Windows β€” run once in PowerShell
[System.Environment]::SetEnvironmentVariable("Path", "$env:USERPROFILE\.claude;" + $env:Path, "User")

Or run directly without PATH setup:

python ~/.claude/plamen.py          # any platform
./plamen.sh                         # Unix/macOS
plamen.bat                          # Windows

CLI fast path (skip the wizard):

plamen core /path/to/project --docs whitepaper.pdf
plamen thorough /path/to/project --scope scope.txt --network ethereum --proven-only
plamen setup                        # just run the installer

Option B: Inside Claude Code (/plamen command)

If you're already in a Claude Code session, type /plamen to launch the audit wizard directly:

> /plamen

This presents a mode selection dialog with previews inside Claude Code, then walks you through target, docs, scope, and launches the full pipeline β€” all within the same session.

You can also skip the wizard with arguments:

> /plamen core /path/to/project docs: /path/to/docs
> /plamen thorough /path/to/project scope: scope.txt proven-only: true
> /plamen compare report: audit.md ground_truth: reference.md

When to use which

Terminal Wrapper (plamen) Claude Code (/plamen)
First time Use this β€” Setup installs tools + builds RAG Need tools already installed
Cost estimate Shows token/cost estimate before launch No estimate
Dependency check Full toolchain box with install option Basic toolchain probe
Daily use Quick CLI: plamen core . Quick command: /plamen core .
Already in Claude Opens new Claude session Uses current session

Repository Structure

~/.claude/
β”œβ”€β”€ CLAUDE.md                          # Orchestrator β€” mode table, critical rules, file refs
β”œβ”€β”€ plamen.py                          # Terminal wrapper (Rich + InquirerPy)
β”œβ”€β”€ plamen.sh / plamen.bat             # Launcher scripts
β”œβ”€β”€ VERSION                            # Semantic version
β”‚
β”œβ”€β”€ commands/
β”‚   └── plamen.md                      # /plamen slash command β€” wizard + full workflow
β”‚
β”œβ”€β”€ rules/                             # Shared rules (all languages)
β”‚   β”œβ”€β”€ finding-output-format.md       # Finding template, Rules Applied, Depth Evidence Tags
β”‚   β”œβ”€β”€ phase3b-rescan-prompt.md       # Breadth re-scan (Thorough)
β”‚   β”œβ”€β”€ phase4-confidence-scoring.md   # 4-axis scoring, anti-dilution, convergence
β”‚   β”œβ”€β”€ phase4c-chain-prompt.md        # Chain analysis β€” enabler enum + chain matching
β”‚   β”œβ”€β”€ phase5-poc-execution.md        # Mandatory PoC execution protocol
β”‚   β”œβ”€β”€ phase6-report-prompts.md       # Report pipeline β€” Index β†’ Tier Writers β†’ Assembler
β”‚   β”œβ”€β”€ report-template.md             # Report format, severity matrix, consolidation
β”‚   β”œβ”€β”€ skill-index.md                 # Master skill registry (all trees)
β”‚   └── post-audit-improvement-protocol.md  # Compare mode methodology
β”‚
β”œβ”€β”€ agents/                            # Agent definitions (language-agnostic)
β”‚   β”œβ”€β”€ depth-token-flow.md
β”‚   β”œβ”€β”€ depth-state-trace.md
β”‚   β”œβ”€β”€ depth-edge-case.md
β”‚   β”œβ”€β”€ depth-external.md
β”‚   β”œβ”€β”€ security-analyzer.md
β”‚   └── security-verifier.md
β”‚
β”œβ”€β”€ prompts/                           # Language-specific prompts
β”‚   β”œβ”€β”€ evm/                           # 10 files (includes invariant-fuzz)
β”‚   β”œβ”€β”€ solana/                        # 9 files
β”‚   β”œβ”€β”€ aptos/                         # 9 files
β”‚   └── sui/                           # 9 files
β”‚   # Each tree contains:
β”‚   #   phase1-recon-prompt.md         β€” 4-agent recon with BINDING MANIFEST
β”‚   #   phase4a-inventory-prompt.md    β€” inventory + side effect trace
β”‚   #   phase4b-loop.md               β€” adaptive depth loop orchestration
β”‚   #   phase4b-depth-templates.md    β€” 4 depth agent prompts
β”‚   #   phase4b-scanner-templates.md  β€” 3 scanners + validation sweep + design stress
β”‚   #   phase5-verification-prompt.md β€” verifier + skeptic-judge (EVM)
β”‚   #   generic-security-rules.md     β€” R1-R16 enforcement
β”‚   #   self-check-checklists.md      β€” per-phase quality gates
β”‚   #   mcp-tools-reference.md        β€” MCP tool usage guide
β”‚
β”œβ”€β”€ agents/skills/
β”‚   β”œβ”€β”€ evm/                           # 18 EVM skill templates
β”‚   β”œβ”€β”€ solana/                        # 19 Solana skill templates
β”‚   β”œβ”€β”€ aptos/                         # 21 Aptos skill templates
β”‚   β”œβ”€β”€ sui/                           # 21 Sui skill templates
β”‚   β”œβ”€β”€ injectable/                    # 5 protocol-type-specific skills
β”‚   └── niche/                         # 5 flag-triggered niche agents
β”‚
β”œβ”€β”€ custom-mcp/                        # MCP servers
β”‚   β”œβ”€β”€ unified-vuln-db/               # RAG vulnerability database (code only, data/ gitignored)
β”‚   β”‚   β”œβ”€β”€ unified_vuln/
β”‚   β”‚   β”‚   β”œβ”€β”€ server.py              # MCP server entry point
β”‚   β”‚   β”‚   β”œβ”€β”€ indexer.py             # CLI: index, clear, stats
β”‚   β”‚   β”‚   β”œβ”€β”€ database.py            # ChromaDB interface
β”‚   β”‚   β”‚   β”œβ”€β”€ schema.py              # Vulnerability data model
β”‚   β”‚   β”‚   β”œβ”€β”€ chunking.py            # Document chunking
β”‚   β”‚   β”‚   └── sources/               # Data source adapters
β”‚   β”‚   β”‚       β”œβ”€β”€ solodit.py         # Solodit API + content parser
β”‚   β”‚   β”‚       β”œβ”€β”€ defihacklabs.py    # DeFiHackLabs exploit corpus
β”‚   β”‚   β”‚       β”œβ”€β”€ immunefi.py        # Immunefi bug bounty data
β”‚   β”‚   β”‚       └── huggingface.py     # Disabled (diluted results)
β”‚   β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”‚   └── setup.py
β”‚   β”œβ”€β”€ solodit-scraper/               # Solodit API scraper with SQLite cache
β”‚   β”‚   β”œβ”€β”€ solodit_mcp/
β”‚   β”‚   β”‚   β”œβ”€β”€ server.py
β”‚   β”‚   β”‚   β”œβ”€β”€ scraper.py
β”‚   β”‚   β”‚   └── database.py
β”‚   β”‚   └── requirements.txt
β”‚   β”œβ”€β”€ defihacklabs-rag/              # DeFiHackLabs ChromaDB embeddings
β”‚   β”‚   β”œβ”€β”€ defihacklabs_mcp/
β”‚   β”‚   β”‚   β”œβ”€β”€ server.py
β”‚   β”‚   β”‚   └── indexer.py
β”‚   β”‚   └── requirements.txt
β”‚   β”œβ”€β”€ solana-fender/                 # Solana static analysis
β”‚   β”‚   β”œβ”€β”€ solana_fender_mcp/
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   └── __main__.py
β”‚   β”‚   └── setup.py
β”‚   β”œβ”€β”€ farofino-mcp/                  # [submodule] Aderyn + pattern analysis
β”‚   └── slither-mcp/                   # [submodule] Trail of Bits Slither
β”‚
β”œβ”€β”€ mcp.json.example                   # MCP server config template
β”œβ”€β”€ settings.json.example             # Permissions config template
β”œβ”€β”€ requirements.txt                   # Python deps (Rich, InquirerPy)
β”œβ”€β”€ .gitmodules                        # Submodule refs (farofino, slither)
└── .gitignore

Severity Matrix

Impact Γ— Likelihood:

Likelihood: High Likelihood: Medium Likelihood: Low
Impact: High (direct fund loss) Critical High Medium
Impact: Medium (conditional fund loss) High Medium Medium
Impact: Low (non-fund) Medium Low Low
Impact: Info (quality, style) Informational Informational Informational

Downgrade modifiers: on-chain-only exploit (βˆ’1 tier), view-function-only (cap Medium), fully-trusted actor required (βˆ’1 tier, floor Info).


Cost Estimation

The plamen.py wrapper estimates token usage before launch, accounting for multi-turn context accumulation per agent. Estimates displayed in the launch summary:

  • Input/Output tokens (millions)
  • API cost (USD, at current Anthropic pricing)
  • Weekly plan usage (% of Pro, Max x5, and Max x20 allowances)

Estimates are rough β€” actual usage varies with protocol complexity and finding count. Run /cost after an audit for actuals.


Evidence Tags

Findings carry evidence tags that determine confidence scoring:

Tag Weight Meaning
[PROD-ONCHAIN] 1.0 Verified against production on-chain state
[PROD-SOURCE] 0.9 Verified against production source code
[PROD-FORK] 0.9 Verified on Anvil fork of production
[MEDUSA-PASS] 1.0 Medusa fuzzer found counterexample
[POC-PASS] 1.0 PoC compiled, executed, assertions passed
[POC-FAIL] β€” PoC executed but assertions failed
[CODE] 0.8 Code-level evidence with specific locations
[CODE-TRACE] 0.6 Manual trace with concrete values, no execution (caps at CONTESTED)
[DOC] 0.4 Documentation-based evidence
[MOCK] 0.2 Mock-based (not production-representative)
[EXT-UNV] 0.1 External/unverified claim

Contributing

See CONTRIBUTING.md. In short:

  1. Fork the repository
  2. Create a feature branch
  3. Follow the anti-bloat gates from post-audit-improvement-protocol.md
  4. Submit a PR with the template

License

MIT


Acknowledgments

About

Autonomous Web3 security audit agent for Claude Code

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages