agentleFS
hiromailyhiromaily/claude-forge/CLAUDE.md

claude-forge

CLAUDE.md3 starsChanged 8 months agoMITView on GitHub

This is a Claude Code plugin that orchestrates a multi-phase development pipeline using isolated subagents. The forge-state MCP server is the sole state-management interface. All 26 state-management commands are typed MCP tool calls. See SETUP.md for the complete setup guide. When installed as a plugin, the MCP server is registered automatically: No manual claude mcp add is needed. See SETUP.md for details. For contributors working on the MCP server source: After restarting, the mcp__forge-state__* tool calls in SKILL.md will route…

The file

Show its rules and text

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

17 rules. About 0 are common, 2 are distinctive, and 15 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 15

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When installed as a plugin, the MCP server is registered automatically:

    line 77
  2. Very specific:

    No manual claude mcp add is needed.

    line 83
  3. Very specific:

    After restarting, the mcp__forge-state__* tool calls in SKILL.md will route to the running server process.

    line 95
  4. Very specific:

    When adding/changing an agent's input files → update BOTH the agent .md file AND the Agent Roster table in SKILL.md

    line 139
  5. Very specific:

    When adding a new phase → add its ID to the Go MCP server state package and ensure pipeline_next_action recognises it

    line 140
  6. Distinctive:

    When changing hook behavior → verify the hook's exit code semantics (exit 0 = allow, exit 2 = block)

    line 141
  7. Very specific:

    When changing state.json schema → ensure the Go MCP server (mcp-server/state/), all hook scripts, and SKILL.md are aligned

    line 142
  8. Very specific:

    Do NOT add isolation: "worktree" to any Agent tool call — breaks inter-task visibility

    line 233
  9. Very specific:

    Do NOT duplicate agent instructions in SKILL.md prompts — agents have their own system prompts

    line 234
  10. Very specific:

    Do NOT store state in memory/conversation — use state.json via the mcp__forge-state__* MCP tools

    line 235
  11. Very specific:

    Do NOT use bare flock without a mkdir fallback — macOS lacks flock by default.

    line 236
  12. Very specific:

    Read BACKLOG.md for known issues and improvement candidates

    line 243
  13. Very specific:

    Read docs/architecture/ for design rationale if making structural changes (see ARCHITECTURE.md for the index)

    line 244
  14. Very specific:

    Check agents/README.md for the current agent roster

    line 245
  15. Very specific:

    Read .claude/rules/git.md for Git branch and commit conventions

    line 247
  16. Very specific:

    Read .claude/rules/shell-script.md for Bash scripting conventions before editing any .sh file

    line 248
  17. Very specific:

    Read docs/architecture/go-package-layering.md before editing any Go code in mcp-server/ — the one-way import DAG (tools → orchestrator → …

    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

Claude-Forge Plugin — AI Agent Guide

This is a Claude Code plugin that orchestrates a multi-phase development pipeline using isolated subagents.

Directory structure

claude-forge/
├── CLAUDE.md              ← AI agent guide (auto-loaded by Claude Code)
├── ARCHITECTURE.md        ← index (full docs in docs/architecture/)
├── BACKLOG.md             ← known issues, improvement candidates
├── README.md              ← project overview and quick start
├── .claude-plugin/
│   └── plugin.json        ← plugin metadata (name, version)
├── .claude/
│   └── rules/
│       ├── git.md         ← Git practices enforced in this repo
│       ├── shell-script.md ← Shell scripting conventions for *.sh files
│       └── docs.md        ← Documentation rules (SSOT, bilingual, VitePress)
├── agents/                ← 10 named agent definitions (.md files)
│   ├── README.md          ← agent roster with roles
│   ├── situation-analyst.md
│   ├── investigator.md
│   ├── architect.md
│   ├── design-reviewer.md
│   ├── task-decomposer.md
│   ├── task-reviewer.md
│   ├── implementer.md
│   ├── impl-reviewer.md
│   ├── comprehensive-reviewer.md
│   └── verifier.md
├── docs/
│   ├── _partials/         ← SSOT content fragments (included by docs/)
│   └── architecture/      ← architecture documentation (13 focused files)
├── hooks/
│   └── hooks.json         ← hook definitions (Setup, SessionStart, PreToolUse, PostToolUse, Stop)
├── mcp-server/            ← Go MCP server source (forge-state binary)
├── scripts/
│   ├── common.sh          ← shared find_active_workspace helper
│   ├── launch-mcp.sh      ← self-healing MCP launcher
│   ├── session-start-hook.sh ← dashboard URL display at session start
│   ├── pre-tool-hook.sh   ← read-only guard, commit blocking, checkout blocking
│   ├── post-agent-hook.sh ← agent output quality validation
│   ├── post-bash-hook.sh  ← auto-commits state.json+summary.md (v1 legacy)
│   ├── setup.sh           ← downloads forge-state-mcp binary from GitHub Releases
│   ├── stop-hook.sh       ← pipeline completion guard
│   └── test-hooks.sh      ← automated test suite (62 tests)
└── skills/
    └── forge/
        └── SKILL.md       ← orchestrator instructions (the main skill)

How the Pieces Connect

SKILL.md (orchestrator)
  ├── calls mcp__forge-state__validate_input before workspace setup
  ├── invokes agents/ by name via Agent tool
  ├── calls mcp__forge-state__* MCP tools for state transitions
  └── hooks/ enforce constraints automatically
       ├── pre-tool-hook.sh reads state.json → blocks writes in Phase 1-2,
       │     blocks git commit in parallel Phase 5,
       │     blocks checkout/switch to main/master
       ├── post-agent-hook.sh reads state.json → warns on bad output
       ├── post-bash-hook.sh reads state.json → auto-commits state.json+summary.md after post-to-source
       └── stop-hook.sh reads state.json → blocks premature stop

MCP Server Registration

The forge-state MCP server is the sole state-management interface. All 26 state-management commands are typed MCP tool calls. See SETUP.md for the complete setup guide.

Auto-registration (plugin install)

When installed as a plugin, the MCP server is registered automatically:

  1. plugin.json declares "mcpServers": "./.mcp.json"
  2. .mcp.json defines the forge-state server (stdio transport, ${CLAUDE_PLUGIN_ROOT}/bin/forge-state-mcp)
  3. The Setup hook in hooks/hooks.json runs scripts/setup.sh to download the pre-built binary from GitHub Releases

No manual claude mcp add is needed. See SETUP.md for details.


MCP Local Development

For contributors working on the MCP server source:

make setup-manual   # build + install + register via claude mcp add

After restarting, the mcp__forge-state__* tool calls in SKILL.md will route to the running server process. Verify with /mcp (should show forge-state as Connected).


MCP Library Usage

Key API surface used in mcp-server/ (github.com/mark3labs/mcp-go):

// Server construction and stdio transport
srv := server.NewMCPServer("forge-state", "1.0.0")
server.ServeStdio(srv)   // package-level function, not a method on srv

// Registering a tool
srv.AddTool(mcp.NewTool("tool_name",
    mcp.WithDescription("..."),
    mcp.WithString("param", mcp.Required(), mcp.Description("...")),
    mcp.WithNumber("num_param", mcp.Description("...")),
), HandlerFunc)

// Reading parameters inside a handler
workspace, err := req.RequireString("workspace")   // returns error if missing
value := req.GetString("key", "default")           // returns default if missing
num := req.GetInt("tokens", 0)
flag := req.GetBool("validated", false)
args := req.GetArguments()                         // map[string]any for complex params

// Returning results
mcp.NewToolResultText("ok")                        // success with text
mcp.NewToolResultError("error message")            // IsError=true response

Tool names use underscores (phase_complete), not hyphens — MCP protocol requirement. The corresponding MCP tool call name is mcp__forge-state__phase_complete.


Go Module Setup

The MCP server lives in mcp-server/ as a separate Go module (go.mod with its own module path). This keeps the Go build hermetic from the rest of the repo (which has no Go code). Run go mod tidy from inside mcp-server/ after adding dependencies. The make build / make install targets handle this automatically.


Consistency Requirements

  • When adding/changing an agent's input files → update BOTH the agent .md file AND the Agent Roster table in SKILL.md
  • When adding a new phase → add its ID to the Go MCP server state package and ensure pipeline_next_action recognises it
  • When changing hook behavior → verify the hook's exit code semantics (exit 0 = allow, exit 2 = block)
  • When changing state.json schema → ensure the Go MCP server (mcp-server/state/), all hook scripts, and SKILL.md are aligned

Testing the Plugin

  • MCP state commands: use cd mcp-server && go test ./state/... to run the Go unit tests for all 26 state-management commands.
  • Hook scripts: pipe sample JSON to stdin and check exit code
    echo '{"tool_name":"Edit","tool_input":{"file_path":"/src/foo.go"}}' | bash scripts/pre-tool-hook.sh
    echo $?  # should be 0 (no active pipeline) or 2 (blocked)
  • Full hook test suite (run after any change):
    bash scripts/test-hooks.sh   # run to see current test count (62 tests)
  • Go MCP server tests (run after any change to mcp-server/):
    cd mcp-server && go test -race ./...

Script Structure Conventions

pre-tool-hook.sh — Enforces four rules: Rule 1 (read-only guard in phase-1/2 with workspace carve-out for artifact writes), Rule 2 (parallel phase-5 git commit block), Rule 3f (effort null warning on phase-start phase-1, non-blocking), Rule 5 (main/master checkout block). Sources scripts/common.sh for find_active_workspace.

find_active_workspace — pre-tool-hook.sh and stop-hook.sh share the same predicate and both source scripts/common.sh. post-agent-hook.sh uses a different filter (status == "in_progress" only) and does NOT source common.sh. Do not unify post-agent-hook.sh's copy into common.sh.

MCP tool count — scripts/state-manager.sh no longer exists; all 26 state-management commands are implemented in the Go MCP server (mcp-server/). The forge-state MCP server exposes all 26 commands as typed tool calls, plus additional MCP-only tools (currently __IMPORTANT, search_patterns, subscribe_events, ast_summary, ast_find_definition, dependency_graph, impact_scope, validate_input, validate_artifact, pipeline_init, pipeline_init_with_context, pipeline_next_action, pipeline_report_result, profile_get, history_search, history_get_patterns, history_get_friction_map, analytics_pipeline_summary, analytics_repo_dashboard, analytics_estimate, preferences_get, and preferences_set). The total MCP tool count is 47. When adding or removing a command, update the count in CLAUDE.md (here), scripts/README.md, and README.md. The count drifted to "22" in documentation before and was caught only in a comprehensive review pass — keep it accurate.

MCP-only tools — __IMPORTANT, search_patterns, subscribe_events, ast_summary, ast_find_definition, dependency_graph, impact_scope, validate_input, validate_artifact, pipeline_init, pipeline_init_with_context, pipeline_next_action, pipeline_report_result, profile_get, history_search, history_get_patterns, history_get_friction_map, analytics_pipeline_summary, analytics_repo_dashboard, analytics_estimate, preferences_get, and preferences_set are exposed as MCP tools but have no shell equivalents. __IMPORTANT is a session-start discovery tool that returns the dashboard URL and basic status information; it follows the __IMPORTANT naming convention for auto-injection into the system prompt. search_patterns performs BM25 scoring over .specs/index.json (see design rationale in ARCHITECTURE.md); no shell fallback exists. subscribe_events is a discovery tool that returns the SSE endpoint URL when FORGE_EVENTS_PORT is set; there is no shell equivalent. ast_summary parses a source file with tree-sitter and returns a compact markdown summary of exported signatures only. ast_find_definition locates and returns the definition of a named symbol in a source file. dependency_graph walks a source tree and returns a file-level import graph as JSON (nodes = files, edges = imports). impact_scope identifies files that call a given symbol via a two-pass import+call-site scan; returns a ranked list (distance: -1 for TypeScript/Python). validate_input validates the raw pipeline input string (empty, too-short, URL format); no shell fallback exists. validate_artifact checks that the expected artifact file exists for a given phase and meets content constraints; always returns a JSON array. pipeline_next_action reads current pipeline state and returns the next action for the orchestrator to execute (spawn_agent, checkpoint, exec, write_file, or done); it reads agent .md files from the path set by the FORGE_AGENTS_PATH environment variable — this must be set in production to the absolute path of the agents/ directory. pipeline_report_result records a phase-log entry, validates artifacts, parses review verdicts, and advances pipeline state. profile_get returns the cached repository profile (languages, CI system, linter configs, build/test commands) computed by RepoProfiler; triggers AnalyzeOrUpdate() on first call and returns a fresh or cached result. history_search queries the history index built from past .specs/ pipeline runs using BM25 scoring and returns ranked similar past pipelines; accepts query, limit, and optional task_type_filter. history_get_patterns returns accumulated review-finding patterns (normalized, Levenshtein-merged) from past pipeline review phases; accepts agent_filter, severity_filter, and limit. history_get_friction_map returns accumulated AI friction points extracted from improvement.md files in past spec directories; accepts no parameters. analytics_pipeline_summary returns token, duration, cost, and review-finding statistics for a single pipeline run; accepts workspace. analytics_repo_dashboard returns aggregate statistics across all pipeline runs in .specs/ (counts, averages, cost, review pass rate, common findings); accepts no parameters. analytics_estimate returns P50/P90 predictions for tokens, duration, and cost for a given (task_type, effort) combination based on historical pipeline runs; accepts task_type and effort. preferences_get reads user preferences from .specs/preferences.json; returns {} if not configured. preferences_set writes user preferences to .specs/preferences.json as a full replacement; accepts a preferences JSON object.

Canonical command list (shell name → MCP tool name):

Shell commandMCP toolCategory
initinitLifecycle
(MCP-only)pipeline_initLifecycle
(MCP-only)pipeline_init_with_contextLifecycle
(MCP-only)pipeline_next_actionLifecycle
(MCP-only)pipeline_report_resultLifecycle
getgetRead
phase-startphase_startPhase
phase-completephase_completePhase
phase-failphase_failPhase
checkpointcheckpointPhase
skip-phaseskip_phasePhase
abandonabandonPhase
revision-bumprevision_bumpRevision
inline-revision-bumpinline_revision_bumpRevision
set-revision-pendingset_revision_pendingRevision
clear-revision-pendingclear_revision_pendingRevision
set-branchset_branchConfig
set-effortset_effortConfig
set-flow-templateset_flow_templateConfig
set-auto-approveset_auto_approveConfig
set-skip-prset_skip_prConfig
set-debugset_debugConfig
set-use-current-branchset_use_current_branchConfig
task-inittask_initTask
task-updatetask_updateTask
phase-logphase_logMetrics
phase-statsphase_statsMetrics
resume-inforesume_infoQuery
(MCP-only)search_patternsQuery
(MCP-only)subscribe_eventsQuery
(MCP-only)ast_summaryQuery
(MCP-only)ast_find_definitionQuery
(MCP-only)dependency_graphQuery
(MCP-only)impact_scopeQuery
(MCP-only)profile_getQuery
(MCP-only)history_searchQuery
(MCP-only)history_get_patternsQuery
(MCP-only)history_get_friction_mapQuery
(MCP-only)analytics_pipeline_summaryQuery
(MCP-only)analytics_repo_dashboardQuery
(MCP-only)analytics_estimateQuery
(MCP-only)validate_inputValidation
(MCP-only)validate_artifactValidation
(MCP-only)preferences_getConfig
(MCP-only)preferences_setConfig
(MCP-only)__IMPORTANTDiscovery
refresh-indexrefresh_indexUtility

FORGE_AGENTS_PATH must be set to the absolute path of the agents/ directory in production for pipeline_next_action to resolve agent .md files correctly.


Development Constraints

  • Do NOT add isolation: "worktree" to any Agent tool call — breaks inter-task visibility
  • Do NOT duplicate agent instructions in SKILL.md prompts — agents have their own system prompts
  • Do NOT store state in memory/conversation — use state.json via the mcp__forge-state__* MCP tools
  • Do NOT use bare flock without a mkdir fallback — macOS lacks flock by default. Hook scripts use mkdir-based atomic locking; follow the same pattern if adding new shell scripts that need locking.
  • Do NOT reverse the Go package import direction: handler/tools → engine/orchestrator → engine/state, with engine/sourcetype and pkg/maputil as shared lower layers. engine/sourcetype must never import engine/orchestrator or handler/tools; pkg/maputil must never import any internal package. Violating this causes an import cycle (caught by import_cycle_test.go). See docs/architecture/go-package-layering.md for the full rule set.

Before You Start Working

  1. Read BACKLOG.md for known issues and improvement candidates
  2. Read docs/architecture/ for design rationale if making structural changes (see ARCHITECTURE.md for the index)
  3. Check agents/README.md for the current agent roster
  4. See the Canonical command list above for available MCP tools (all 26 state commands are in the Go MCP server)
  5. Read .claude/rules/git.md for Git branch and commit conventions
  6. Read .claude/rules/shell-script.md for Bash scripting conventions before editing any .sh file
  7. Read docs/architecture/go-package-layering.md before editing any Go code in mcp-server/ — the one-way import DAG (tools → orchestrator → state) is enforced by a compile-time test and violations cause import cycles

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.