01What it does
Code Forge solves the three failure modes of multi-agent code generation — protocol drift, reviewer blind spots, and tautological tests — by making each one a structural property of the run rather than a prompt-level hope.
TDD as a phase
A dedicated test-author writes tests before any implementer touches code. cycle-tests-pass.sh red inverts exit codes so tautological tests fail the gate.
Best-of-N implementer
6 Sonnet workers dispatched in a single turn produce independent candidates; the cycle child scores them by LOC + files + complexity and applies the simplest passer.
Dimensional review
N reviewers (count, model, dimensions all picked in spec.md) cover a curated lens menu — correctness, design, simplicity, security, more. A consolidator clusters, verifies, ships review.md.
Goal-driven cycles
The /forge skill drives the run in your interactive session and spawns one claude -p /goal per cycle for the autonomous bits — each child loops until its result.json shows status: pass.
Anti-weakening hook
Test files (plus the state.json/tests.json anchors) are read-only during green. Without it /goal "tests pass" would mutate tests instead of the implementation.
Codex cross-checks
G2.a (spec ↔ plan) and G2.b (spec ↔ e2e) gates round-trip through Codex via codex-bridge as independent second-opinion judges.
02How a run flows
The /forge skill is the orchestrator. It runs in your
interactive Claude Code session and drives Phase 0/1 + the cycle loop
directly — no separate outer process. For each cycle in
spec.md ## Cycle Plan, it spawns one claude -p /goal
child; each child has its own Haiku evaluator that judges the cycle's
goal condition after every turn.
/forge skill (your Claude Code session) reads spec.md, picks the next pending cycle, spawns a claude -p /goal child, narrates the result. Repeat until every cycle status is pass.03Inside a cycle child
Each cycle is one claude -p /goal session whose condition
is "result.json exists with status: pass
AND review.md has 0 critical clusters". The child
runs a linear sequence of dispatches + gates inline; the cycle's
/goal handles re-prompting on failure until done or
capped at K turns.
Legend
spec.md.04Configurable dimensional review
Each cycle's reviewer fan-out is parameterized at spec-authoring time. The planner runs an interactive Phase 1.5 sub-step asking for the model + dimensions and writes the result into spec.md ## Reviewer Config:
## Reviewer Config
model: opus # or sonnet
dimensions:
- correctness # ★ default trio
- simplicity # ★ default trio
- security # ★ default trio
The length of the dimensions list IS the reviewer count — no separate count: field, no validation mismatch. Want two security reviewers? List security twice.
Curated dimension menu
| Tier | Dimension | What it covers |
|---|---|---|
| 1 ★ | correctness | Does the code do what spec says? Off-by-one, type confusions, hidden behaviors. |
| 1 | design | Module boundaries, separation of concerns, naming clarity. |
| 1 | error-handling | Silent failures, swallowed exceptions, missing error paths. |
| 1 ★ | simplicity | Accidental complexity, premature abstraction, dead code. |
| 1 | tests-vs-impl | Tautology hunting — do tests actually exercise the impl? |
| 1 ★ | security | Real vuln classes — auth gaps, input validation, capability leaks. |
| 2 | performance | Algorithmic complexity, obvious bottlenecks. |
| 2 | naming-readability | Names communicate intent; code reads top-to-bottom. |
| 2 | dependency-hygiene | Unused / outdated / vulnerable deps. |
| 2 | type-safety | Type contracts at boundaries; no any escape hatches. |
| 2 | concurrency | Race conditions, shared mutable state. |
| 2 | observability | Logging, error surfacing, debuggability. |
| 3 | sui-move-idioms | Move 2024 conventions, ability usage, object capability patterns. |
| 3 | frontend-a11y | ARIA, semantic markup, keyboard nav, contrast. |
| 3 | api-contract-stability | Backwards compatibility, deprecation, breaking-change risk. |
★ = the default trio shown selected when the planner first opens the picker. Tier 3 dimensions are declared per-project (not in the default menu).
05The one hook
Code Forge ships exactly one PreToolUse hook: the test-immutability
rule. Without it, /goal "tests pass" would happily mutate
the tests instead of the implementation — the evaluator can only see
what's in the transcript and cannot diff against a baseline.
Worker candidate-staging is also covered
Best-of-N workers stage candidates under .forge/cycles/<id>/green/candidates/worker-K/files/<repo-relative-path>. The hook peels that prefix so a write to a staged copy of a test file still trips.
06spec.md — the single artifact
Everything per-project lives in one file. The planner emits it during Phase 1; the skill and every cycle child read it.
# <Project Name>+## Vision— what + why## Target Users## Acceptance Criteria— observable behaviors withAC-NNNids## Architecture— concise, ~½ page max## Out of Scope## E2E Tests— YAML scenarios that the final cycle's tests cover## Cycle Plan— sequential YAML list, each entry hasid,goal,files_affected,acceptance,goal_condition## Reviewer Config—model+dimensionslist
Example ## Cycle Plan entry
- id: C1
goal: implement the user storage layer
files_affected:
- src/storage/users.ts
- src/storage/types.ts
acceptance: [AC-001]
goal_condition: |
cycles/C1/result.json exists with status: pass AND
cycles/C1/review.md has 0 critical clusters,
or stop after 30 turns
Example result.json from a passing cycle
{
"cycle_id": "C1",
"status": "pass",
"summary": "all tests pass; 0 critical findings",
"winner_worker": "W3",
"review_clusters": {
"critical": 0,
"high": 2,
"medium": 5,
"low": 3,
"info": 0
},
"started_at": "2026-05-19T10:00:00Z",
"ended_at": "2026-05-19T10:24:00Z"
}
07Quick start
Code Forge is a Claude Code plugin. There's one entry point:
/forge "Build a CLI that counts source lines"
# Skip Phase 0 (Codex-mediated planning refinement) for trivial tasks:
/forge "Add a --json flag to my CLI" --quick
# Skip the optional G2.5 Codex gate (cost savings):
/forge "<description>" --light
# Resume a run that left a partial .forge/ behind:
/forge "<description>" --resume
The code-forge skill drives the whole run in your interactive session (Phase 0 → Phase 1 → cycle loop), spawning one claude -p /goal child per cycle for the autonomous bits.
Requirements
- Claude Code v2.1.139+ —
/goalis load-bearing. codex-bridgeplugin — provides the Codex MCP tools used by the planner's G2.a / G2.b / G2.5 cross-checks.- Hooks enabled —
disableAllHooks: falsein settings (the default). The one anti-cheat invariant is aPreToolUsehook; if it's disabled,/goal "tests pass"will reliably weaken tests. jq+nodeinPATH— used bycycle-validate.shandforge-guard.mjs.
08Further reading
- GitHub repo — source of truth
- docs/goal-integration.md — full protocol (skill + cycle child procedures)
- templates/spec.md.template — copy-pasteable spec skeleton
- agents/ — per-agent prompts (planner, test-author, implementer-worker, reviewer, consolidator)
- hooks/forge-guard.mjs — the surviving rule
- tests/smoke.sh — the plugin's self-test (90 assertions)