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…
In this repository3 other files it gives its agents.
- docs-ssotSkill
- forge-setupSkill
- forgeSkill
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
- Distinctive: line 77
When installed as a plugin, the MCP server is registered automatically:
- Very specific: line 83
No manual claude mcp add is needed.
- Very specific: line 95
After restarting, the mcp__forge-state__* tool calls in SKILL.md will route to the running server process.
- Very specific: line 139
When adding/changing an agent's input files → update BOTH the agent .md file AND the Agent Roster table in SKILL.md
- Very specific: line 140
When adding a new phase → add its ID to the Go MCP server state package and ensure pipeline_next_action recognises it
- Distinctive: line 141
When changing hook behavior → verify the hook's exit code semantics (exit 0 = allow, exit 2 = block)
- Very specific: line 142
When changing state.json schema → ensure the Go MCP server (mcp-server/state/), all hook scripts, and SKILL.md are aligned
- Very specific: line 233
Do NOT add isolation: "worktree" to any Agent tool call — breaks inter-task visibility
- Very specific: line 234
Do NOT duplicate agent instructions in SKILL.md prompts — agents have their own system prompts
- Very specific: line 235
Do NOT store state in memory/conversation — use state.json via the mcp__forge-state__* MCP tools
- Very specific: line 236
Do NOT use bare flock without a mkdir fallback — macOS lacks flock by default.
- Very specific: line 243
Read BACKLOG.md for known issues and improvement candidates
- Very specific: line 244
Read docs/architecture/ for design rationale if making structural changes (see ARCHITECTURE.md for the index)
- Very specific: line 245
Check agents/README.md for the current agent roster
- Very specific: line 247
Read .claude/rules/git.md for Git branch and commit conventions
- Very specific: line 248
Read .claude/rules/shell-script.md for Bash scripting conventions before editing any .sh file
- Very specific: line 249
Read docs/architecture/go-package-layering.md before editing any Go code in mcp-server/ — the one-way import DAG (tools → orchestrator → …
≈ “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.
Files
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 stopMCP 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:
plugin.jsondeclares"mcpServers": "./.mcp.json".mcp.jsondefines theforge-stateserver (stdio transport,${CLAUDE_PLUGIN_ROOT}/bin/forge-state-mcp)- The
Setuphook inhooks/hooks.jsonrunsscripts/setup.shto 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 addAfter 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 responseTool 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_actionrecognises 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 command | MCP tool | Category |
init | init | Lifecycle |
| (MCP-only) | pipeline_init | Lifecycle |
| (MCP-only) | pipeline_init_with_context | Lifecycle |
| (MCP-only) | pipeline_next_action | Lifecycle |
| (MCP-only) | pipeline_report_result | Lifecycle |
get | get | Read |
phase-start | phase_start | Phase |
phase-complete | phase_complete | Phase |
phase-fail | phase_fail | Phase |
checkpoint | checkpoint | Phase |
skip-phase | skip_phase | Phase |
abandon | abandon | Phase |
revision-bump | revision_bump | Revision |
inline-revision-bump | inline_revision_bump | Revision |
set-revision-pending | set_revision_pending | Revision |
clear-revision-pending | clear_revision_pending | Revision |
set-branch | set_branch | Config |
set-effort | set_effort | Config |
set-flow-template | set_flow_template | Config |
set-auto-approve | set_auto_approve | Config |
set-skip-pr | set_skip_pr | Config |
set-debug | set_debug | Config |
set-use-current-branch | set_use_current_branch | Config |
task-init | task_init | Task |
task-update | task_update | Task |
phase-log | phase_log | Metrics |
phase-stats | phase_stats | Metrics |
resume-info | resume_info | Query |
| (MCP-only) | search_patterns | Query |
| (MCP-only) | subscribe_events | Query |
| (MCP-only) | ast_summary | Query |
| (MCP-only) | ast_find_definition | Query |
| (MCP-only) | dependency_graph | Query |
| (MCP-only) | impact_scope | Query |
| (MCP-only) | profile_get | Query |
| (MCP-only) | history_search | Query |
| (MCP-only) | history_get_patterns | Query |
| (MCP-only) | history_get_friction_map | Query |
| (MCP-only) | analytics_pipeline_summary | Query |
| (MCP-only) | analytics_repo_dashboard | Query |
| (MCP-only) | analytics_estimate | Query |
| (MCP-only) | validate_input | Validation |
| (MCP-only) | validate_artifact | Validation |
| (MCP-only) | preferences_get | Config |
| (MCP-only) | preferences_set | Config |
| (MCP-only) | __IMPORTANT | Discovery |
refresh-index | refresh_index | Utility |
FORGE_AGENTS_PATHmust be set to the absolute path of theagents/directory in production forpipeline_next_actionto resolve agent.mdfiles 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
flockwithout a mkdir fallback — macOS lacksflockby 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, withengine/sourcetypeandpkg/maputilas shared lower layers.engine/sourcetypemust never importengine/orchestratororhandler/tools;pkg/maputilmust never import any internal package. Violating this causes an import cycle (caught byimport_cycle_test.go). See docs/architecture/go-package-layering.md for the full rule set.
Before You Start Working
- Read
BACKLOG.mdfor known issues and improvement candidates - Read
docs/architecture/for design rationale if making structural changes (seeARCHITECTURE.mdfor the index) - Check
agents/README.mdfor the current agent roster - See the Canonical command list above for available MCP tools (all 26 state commands are in the Go MCP server)
- Read
.claude/rules/git.mdfor Git branch and commit conventions - Read
.claude/rules/shell-script.mdfor Bash scripting conventions before editing any.shfile - Read
docs/architecture/go-package-layering.mdbefore editing any Go code inmcp-server/— the one-way import DAG (tools → orchestrator → state) is enforced by a compile-time test and violations cause import cycles
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
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.

