agentleFS
GH05TCREWGH05TCREW/pentestagent/CLAUDE.md

pentestagent

CLAUDE.md3.1k starsChanged 2 months agoMITView on GitHub

PentestAgent (v0.2.0) is an AI-powered penetration testing framework built in Python. It wraps LiteLLM to support any provider (Anthropic, OpenAI, etc.) and exposes a TUI, a CLI, and an MCP server interface. The agent can run tools locally or inside a Docker sandbox (base or Kali image). - Python 3.10+, packaged with Hatchling (pyproject.toml) - LiteLLM — provider-agnostic LLM wrapper - Textual — TUI framework (pentestagent/interface/) - Typer — CLI framework - Playwright — browser tool - MCP (Model Context…

  • Reads credentials
  • Installs packages

Trending

Quiet since June.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 1 mentionMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 1 mentionJun 2026: 1 mentionJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the GH05TCREW/pentestagent repository that our weekly crawl found: only 4 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

The file

We split this CLAUDE.md into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create .env in the project root:

    line 71
  2. Very specific:

    RAG tool optimizer: if an MCP server exposes >128 tools, a single mcp_<server>_rag_optimizer meta-tool replaces them and retrieves relevant …

    line 219
  3. Very specific:

    Test config: pytest.ini_options in pyproject.toml, asyncio mode = auto.

    line 237
  4. Distinctive:

    Only use against systems you have explicit written authorisation to test.

    line 249

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

PentestAgent — CLAUDE.md

Project overview

PentestAgent (v0.2.0) is an AI-powered penetration testing framework built in Python. It wraps LiteLLM to support any provider (Anthropic, OpenAI, etc.) and exposes a TUI, a CLI, and an MCP server interface. The agent can run tools locally or inside a Docker sandbox (base or Kali image).

Tech stack

  • Python 3.10+, packaged with Hatchling (pyproject.toml)
  • LiteLLM — provider-agnostic LLM wrapper
  • Textual — TUI framework (pentestagent/interface/)
  • Typer — CLI framework
  • Playwright — browser tool
  • MCP (Model Context Protocol) — both client (consuming external servers) and server (exposing PentestAgent to Claude Desktop / Cursor / etc.)
  • FAISS + sentence-transformers — optional RAG engine (pip install -e ".[rag]")

Repository layout

pentestagent/
  agents/
    crew/           # Multi-agent mode: orchestrator + worker pool + shadow graph
    pa_agent/       # Single-agent implementation
    state.py        # Shared agent state
  config/
    settings.py     # Global Settings dataclass (singleton via get_settings())
    constants.py    # Model defaults, iteration limits, etc.
  interface/
    cli.py          # Typer CLI entry-point
    notifier.py     # Event bus between agent and UI
    utils.py        # Shared UI helpers
  knowledge/
    graph.py        # ShadowGraph — derives strategic insights from notes
    indexer.py      # Indexes knowledge sources for RAG
    rag.py          # FAISS-backed retrieval
  llm/
    config.py       # LiteLLM configuration
    memory.py       # Conversation/token management
    utils.py        # Streaming helpers
  mcp/
    stdio_adapter.py    # STDIO MCP server transport
    example_adapter.py  # SSE MCP server transport
  playbooks/
    base_playbook.py
    thp3_recon.py / thp3_network.py / thp3_web.py
  runtime/
    docker_runtime.py   # Runs tool commands inside Docker
    tool_server.py      # Local runtime
  tools/
    loader.py       # Discovers & dynamically imports tool modules
    executor.py     # Executes tool calls, tracks tokens
    token_tracker.py
    terminal/       # Shell execution tool
    browser/        # Playwright browser tool
    web_search/     # Tavily web search (needs TAVILY_API_KEY)
    notes/          # Persistent findings store → loot/notes.json
    finish/         # Signals task completion
  workspaces/       # Workspace isolation helpers
loot/               # Persisted notes and findings (git-ignored)
mcp_examples/       # Example MCP configs and adapters
scripts/            # setup.sh / setup.ps1
tests/              # pytest suite

Configuration

Create .env in the project root:

ANTHROPIC_API_KEY=sk-ant-...
PENTESTAGENT_MODEL=claude-sonnet-4-20250514

# Optional
TAVILY_API_KEY=...          # web_search tool
OPENAI_API_KEY=sk-...       # if using OpenAI

Settings are managed by pentestagent/config/settings.py (get_settings() singleton). The MCP external-server config lives in mcp_servers.json (Claude Desktop format).

Running the project

source venv/bin/activate
pentestagent                    # TUI
pentestagent -t 192.168.1.1     # TUI with pre-set target
pentestagent tui --docker       # Use Docker sandbox for tool execution
pentestagent run -t example.com --playbook thp3_web   # Run a playbook
pentestagent mcp_server --type stdio   # Expose as MCP server (STDIO)
pentestagent mcp_server --type sse     # Expose as MCP server (HTTP/SSE, port 8080)

PentestAgent as MCP server

PentestAgent can expose itself as an MCP server so any MCP-compatible client (Claude Desktop, Cursor, etc.) can drive it programmatically.

Transports

# STDIO — for local clients
pentestagent mcp_server --type stdio
pentestagent mcp_server --type stdio --target 192.168.1.1 --scope 192.168.1.0/24 --docker

# SSE (HTTP) — for remote/networked clients (default: 0.0.0.0:8080)
pentestagent mcp_server --type sse
pentestagent mcp_server --type sse --host 0.0.0.0 --port 8080 --target 10.0.0.1

Claude Desktop config (claude_desktop_config.json)

{
  "mcpServers": {
    "pentestagent": {
      "command": "pentestagent",
      "args": ["mcp_server", "--type", "stdio"]
    }
  }
}

Tools exposed by the MCP server

CategoryTools
Status / configget_server_status, get_config, update_config
Task executionrun_task (blocking), run_task_async (returns task_id)
Task inspectionlist_tasks, get_task_status, get_task_result, await_tasks
Task controlcancel_task
Tool managementlist_tools, enable_tool, disable_tool
Conversationget_conversation_history, reset_conversation
Memorystore_memory, retrieve_memory, clear_memory
Observabilityget_logs, get_metrics

Async task pattern

run_task_async  task="Enumerate subdomains of example.com"
run_task_async  task="Run nmap SYN scan on example.com"
await_tasks     task_ids=["<id1>", "<id2>"]  timeout_seconds=300
get_task_result task_id="<id1>"
get_task_result task_id="<id2>"

mcp_server flags

FlagDefaultDescription
--type(required)stdio or sse
--host0.0.0.0SSE bind host
--port8080SSE bind port
--targetnonePrimary pentest target
--scope[]In-scope CIDRs (space-separated)
--modelenv varOverrides PENTESTAGENT_MODEL
--dockerfalseUse DockerRuntime
--no-ragfalseSkip RAG initialisation
--no-mcpfalseSkip external MCP connections

TUI commands (quick reference)

CommandDescription
/assist <task>Single-shot instruction with tool execution
/agent <task>Autonomous single-agent loop
/crew <task>Multi-agent: orchestrator spawns specialised workers
/interact <task>Guided interactive chat
/target <host>Set target
/toolsList available tools
/notesShow saved findings
/reportGenerate report from session
/mcp list/addManage MCP servers
EscStop running agent

Conversation history controls (TUI)

Each user message in the TUI exposes two inline buttons: rewind and fork.

Rewind

Clicking rewind on a user message opens a confirmation dialog and then truncates the conversation back to just before that message — both in the UI and in the agent's in-memory history. Use it to retry a query from scratch without saving the discarded path.

Fork

Clicking >> fork on a user message:

  1. Saves the current full conversation to the conversation store (ConversationStore, persisted under the workspaces base directory) and reports the short ID of the saved snapshot.
  2. Truncates the conversation to just before the selected message (same as rewind).

This lets you branch off from any point while keeping the original conversation retrievable. Typical use-case: try an alternative approach from a given message without losing the thread you had so far.

Both controls are implemented in pentestagent/interface/tui.py via RewindButton / ForkButton widgets and their corresponding *ConfirmScreen modals.

Key architectural patterns

  • Tool registration: Tools self-register via pentestagent/tools/loader.py. Add a new tool by creating a directory under pentestagent/tools/<name>/ with an __init__.py that registers it with the tool registry.
  • Modes: assist → single LLM call; agent → agentic loop; crew → CrewOrchestrator manages a WorkerPool; interact → streaming chat.
  • MCP server tools: run_task, run_task_async, await_tasks, get_task_result, list_tasks, cancel_task, list_tools, enable_tool, disable_tool, store_memory, retrieve_memory, get_logs, get_metrics.
  • Agent self-spawning (spawn_mcp_agent): running agent can spawn child agents as MCP servers over stdio, enabling hierarchical multi-agent workflows.
  • RAG tool optimizer: if an MCP server exposes >128 tools, a single mcp_<server>_rag_optimizer meta-tool replaces them and retrieves relevant subsets via embedding similarity.
  • Notes persistence: findings saved to loot/notes.json via the notes tool; categories: credential, vulnerability, finding, artifact.
  • ShadowGraph (crew mode only): builds a knowledge graph from notes to provide strategic context to the orchestrator.

Development

pip install -e ".[dev]"
pytest                       # Run tests
pytest --cov=pentestagent    # With coverage
black pentestagent           # Format
ruff check pentestagent      # Lint

Test config: pytest.ini_options in pyproject.toml, asyncio mode = auto.

Docker

docker compose build
docker compose run --rm pentestagent          # Base image
docker compose --profile kali run --rm pentestagent-kali   # Kali image

Legal

Only use against systems you have explicit written authorisation to test. Unauthorised access is illegal. MIT licence.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.