forge-cc 0.1.41 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +454 -338
  2. package/dist/cli.js +194 -935
  3. package/dist/cli.js.map +1 -1
  4. package/dist/config/loader.d.ts +1 -1
  5. package/dist/config/loader.js +49 -56
  6. package/dist/config/loader.js.map +1 -1
  7. package/dist/config/schema.d.ts +37 -125
  8. package/dist/config/schema.js +13 -28
  9. package/dist/config/schema.js.map +1 -1
  10. package/dist/doctor.d.ts +10 -0
  11. package/dist/doctor.js +148 -0
  12. package/dist/doctor.js.map +1 -0
  13. package/dist/gates/index.d.ts +14 -12
  14. package/dist/gates/index.js +53 -105
  15. package/dist/gates/index.js.map +1 -1
  16. package/dist/gates/lint-gate.d.ts +2 -2
  17. package/dist/gates/lint-gate.js +60 -66
  18. package/dist/gates/lint-gate.js.map +1 -1
  19. package/dist/gates/tests-gate.d.ts +2 -4
  20. package/dist/gates/tests-gate.js +75 -203
  21. package/dist/gates/tests-gate.js.map +1 -1
  22. package/dist/gates/types-gate.d.ts +2 -2
  23. package/dist/gates/types-gate.js +53 -59
  24. package/dist/gates/types-gate.js.map +1 -1
  25. package/dist/linear/client.d.ts +31 -108
  26. package/dist/linear/client.js +88 -388
  27. package/dist/linear/client.js.map +1 -1
  28. package/dist/linear/sync.d.ts +15 -0
  29. package/dist/linear/sync.js +102 -0
  30. package/dist/linear/sync.js.map +1 -0
  31. package/dist/runner/loop.d.ts +4 -0
  32. package/dist/runner/loop.js +168 -0
  33. package/dist/runner/loop.js.map +1 -0
  34. package/dist/runner/prompt.d.ts +14 -0
  35. package/dist/runner/prompt.js +59 -0
  36. package/dist/runner/prompt.js.map +1 -0
  37. package/dist/runner/update.d.ts +1 -0
  38. package/dist/runner/update.js +72 -0
  39. package/dist/runner/update.js.map +1 -0
  40. package/dist/server.d.ts +6 -2
  41. package/dist/server.js +43 -101
  42. package/dist/server.js.map +1 -1
  43. package/dist/setup.d.ts +5 -0
  44. package/dist/setup.js +208 -0
  45. package/dist/setup.js.map +1 -0
  46. package/dist/state/cache.d.ts +3 -0
  47. package/dist/state/cache.js +23 -0
  48. package/dist/state/cache.js.map +1 -0
  49. package/dist/state/status.d.ts +66 -0
  50. package/dist/state/status.js +96 -0
  51. package/dist/state/status.js.map +1 -0
  52. package/dist/types.d.ts +46 -114
  53. package/dist/worktree/manager.d.ts +6 -103
  54. package/dist/worktree/manager.js +25 -296
  55. package/dist/worktree/manager.js.map +1 -1
  56. package/hooks/pre-commit-verify.js +109 -109
  57. package/package.json +3 -2
  58. package/skills/forge-go.md +20 -13
  59. package/skills/forge-setup.md +149 -388
  60. package/skills/forge-spec.md +367 -342
  61. package/skills/forge-triage.md +179 -133
  62. package/skills/forge-update.md +87 -93
package/README.md CHANGED
@@ -1,338 +1,454 @@
1
- <p align="center">
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/badge/forge--cc-Autonomous_Dev_Workflow-white?style=for-the-badge&labelColor=000000" />
4
- <img src="https://img.shields.io/badge/forge--cc-Autonomous_Dev_Workflow-000000?style=for-the-badge&labelColor=white" alt="forge-cc" />
5
- </picture>
6
- </p>
7
-
8
- <p align="center">
9
- <strong>Idea to merged PR. Autonomous agent teams. Zero manual git.</strong>
10
- </p>
11
-
12
- <p align="center">
13
- <a href="https://www.npmjs.com/package/forge-cc"><img src="https://img.shields.io/npm/v/forge-cc?style=flat-square&color=0969da" alt="npm" /></a>
14
- <img src="https://img.shields.io/badge/Claude_Code-plugin-7c3aed?style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTIgMkw0IDdWMTdMMTIgMjJMMjAgMTdWN0wxMiAyWiIgZmlsbD0id2hpdGUiLz48L3N2Zz4=&logoColor=white" alt="Claude Code" />
15
- <img src="https://img.shields.io/badge/node-%3E%3D18-339933?style=flat-square&logo=node.js&logoColor=white" alt="node" />
16
- <img src="https://img.shields.io/npm/l/forge-cc?style=flat-square&color=22863a" alt="MIT" />
17
- </p>
18
-
19
- ---
20
-
21
- ## What is forge-cc?
22
-
23
- forge-cc is a Claude Code plugin that turns your AI coding agent into an autonomous development team. You describe what you want to build. Forge breaks it into milestones, spins up parallel agent teams, verifies every line of code, creates the PR, gets it reviewed, and merges it -- all without you touching git.
24
-
25
- ```
26
- npm install -g forge-cc
27
- ```
28
-
29
- ---
30
-
31
- ## The Workflow
32
-
33
- Four commands take you from raw idea to production-ready, merged code.
34
-
35
- ```
36
- ┌──────────────────────────────────────────────────────────────────────────────────┐
37
- │ │
38
- YOU HAVE AN IDEA FORGE DOES THE REST
39
- │ │
40
- "We need auth, ┌────────────┐ ┌────────────┐ ┌────────────┐ │
41
- a dashboard, │ │ │ │ │ │ │
42
- and email TRIAGE ├──► SPEC ├──► GO │ │
43
- notifications" │ │ │ │ │ │ │
44
- └─────┬──────┘ └─────┬──────┘ └─────┬──────┘ │
45
- │ │ │ │
46
- Creates Linear Scans codebase Agent teams
47
- projects from + interviews build each
48
- brain dump you + generates milestone
49
- PRD + milestones in parallel
50
- │ │ │
51
- │ ▼ │
52
- │ ┌────────────────┐ │
53
- │ │ VERIFY + PR │ │
54
- │ │ + CODE REVIEW │ │
55
- │ └────────────────┘ │
56
- │ │
57
- └──────────────────────────────────────────────────────────────────────────────────┘
58
- ```
59
-
60
- ### `/forge:triage` -- Brain Dump to Backlog
61
-
62
- Paste sticky notes, Slack messages, or stream-of-consciousness feature ideas. Forge extracts distinct projects, deduplicates against your existing Linear backlog, and creates them after your confirmation.
63
-
64
- ### `/forge:spec` -- Project to PRD
65
-
66
- Pick a project from Linear. Forge scans your codebase in parallel (structure, routes, dependencies, patterns), then conducts an adaptive interview -- leading with recommendations based on what it found, not blank-slate questions. The output is a full PRD with milestones sized to fit agent context windows, synced back to Linear with issues and status tracking.
67
-
68
- ### `/forge:go` -- Milestones to Merged Code
69
-
70
- This is the engine. Each milestone is executed by an autonomous agent team:
71
-
72
- ```
73
- ┌─────────────────────────────────────────────────────────────────────┐
74
- EXECUTIVE (orchestrator) │
75
- │ Plans waves, assigns tasks, resolves escalations │
76
- ├─────────────────────────────────────────────────────────────────────┤
77
- REVIEWER (persistent across all waves)
78
- Reviews diff against PRD after each wave │
79
- │ Findings go through consensus protocol with builders │
80
- ├────────────────────┬────────────────────┬───────────────────────────┤
81
- BUILDER 1 │ BUILDER 2 │ BUILDER N ... │
82
- Parallel agents │ Parallel agents │ Each gets a task,
83
- │ within each wave │ within each wave │ writes + tests code │
84
- └────────────────────┴────────────────────┴───────────────────────────┘
85
- ```
86
-
87
- **What happens during execution:**
88
-
89
- ```
90
- Wave 1 ─► Verify ─► Review ─► Fix ─► Wave 2 ─► ... ─► PR ─► Merge
91
- │ │ │ │
92
- │ │ │ └─ Fix agents spawn for accepted findings
93
- └─ Reviewer + builders reach consensus on issues
94
- └─ Types + lint + tests run automatically (self-healing loop)
95
- └─ Parallel builder agents execute independent tasks
96
- ```
97
-
98
- After the final wave passes all gates + review, forge creates the PR, waits for Codex review comments, and spawns fix agents for any findings. The PR is left for the user to merge.
99
-
100
- ### `npx forge run` -- Auto-Chain Everything
101
-
102
- Run all remaining milestones autonomously. Each gets a fresh Claude session (no context rot), with stall detection that stops on failure. Independent milestones run in parallel.
103
-
104
- ---
105
-
106
- ## Verification Gates
107
-
108
- Not just "run tests." Forge runs **8 verification gates** that catch what tests alone can't:
109
-
110
- ```
111
- ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
112
- │ TYPES │ │ LINT │ │ TESTS │ │ VISUAL │
113
- │ tsc │ │ biome │ │ vitest/ │ │ 3-viewport│
114
- --noEmit │ │ check │ │ jest │ │ screenshots│
115
- └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘
116
- │ │ │ │
117
- ▼ ▼ ▼ ▼
118
- ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
119
- │ RUNTIME PRD │ │ REVIEW │ │ CODEX │
120
- endpoint │ acceptance│ │ AI code │ │ post-PR │
121
- │ checks │ │ criteria │ │ review │ │ review │
122
- └──────────┘ └──────────┘ └──────────┘ └──────────┘
123
- ```
124
-
125
- | Gate | What it catches |
126
- |------|----------------|
127
- | **types** | Compilation errors, type mismatches |
128
- | **lint** | Style violations, dead imports, code smells |
129
- | **tests** | Broken behavior, regressions |
130
- | **visual** | UI regressions across desktop, tablet, and mobile viewports |
131
- | **runtime** | Crashed endpoints, wrong status codes, malformed responses |
132
- | **prd** | Missing features, acceptance criteria drift |
133
- | **review** | Logic errors, missing edge cases, architectural issues |
134
- | **codex** | Post-PR findings from GitHub's Codex reviewer |
135
-
136
- **Self-healing:** When a gate fails, forge parses the errors into structured remediation (file, line, message, fix hint) and spawns a fix agent. This loops up to 5 times before stopping -- most failures resolve automatically.
137
-
138
- ---
139
-
140
- ## Linear Integration
141
-
142
- Forge manages your Linear project lifecycle end-to-end. Every state transition happens automatically as work progresses:
143
-
144
- ```
145
- Linear State: Backlog ──► Planned ──► In Progress ──► In Review ──► Done
146
- │ │ │ │ │
147
- Forge Action: triage /forge:spec /forge:go PR created user merges
148
- creates generates PRD, executes after final when ready
149
- projects syncs milestones milestone verification
150
- ```
151
-
152
- Set `FORGE_LINEAR_API_KEY` in your environment to enable. Forge creates projects, milestones, and issues during spec, transitions them through states during execution, and marks them done when the PR merges.
153
-
154
- ---
155
-
156
- ## Branch & Worktree Management
157
-
158
- You never touch git. Forge handles the entire branch lifecycle:
159
-
160
- ```
161
- main ─────────────────────────────────────────────────────► main (updated)
162
- │ ▲
163
- └──► feat/auth ──► worktree 1 ──► wave 1..N ──► PR ──► merge + cleanup
164
- │ │
165
- └──► feat/dashboard ──► worktree 2 ──► (parallel) ┘
166
- ```
167
-
168
- **Session isolation** -- Each milestone runs in its own git worktree (`../.forge-wt/<repo>/<session>/`). Parallel agents can't corrupt each other's git index. Multiple milestones can execute simultaneously on the same repo.
169
-
170
- **Automatic cleanup** -- When a milestone finishes, its worktree and branch are deleted. When a PR merges, `npx forge cleanup` prunes the local branch. Crashed sessions are detected by PID and cleaned up. Protected branches (`main`, `master`) are never touched.
171
-
172
- **Cross-platform** -- Windows path limits handled with 8-char hex session IDs. Atomic file writes use retry-on-rename for Windows file locking.
173
-
174
- ---
175
-
176
- ## Quick Start
177
-
178
- ```bash
179
- # 1. Install
180
- npm install -g forge-cc
181
-
182
- # 2. Set up your project
183
- npx forge setup
184
-
185
- # 3. Start building
186
- # /forge:triage → /forge:spec → /forge:go
187
- ```
188
-
189
- `forge setup` auto-detects your stack (TypeScript, Biome, test runner), creates `.forge.json`, installs enforcement hooks, and scaffolds planning directories. Run `npx forge doctor` anytime to check your environment.
190
-
191
- ### Configuration
192
-
193
- `.forge.json` in your project root:
194
-
195
- ```json
196
- {
197
- "gates": ["types", "lint", "tests"],
198
- "maxIterations": 5,
199
- "linearProject": "My Project"
200
- }
201
- ```
202
-
203
- <details>
204
- <summary><b>Full configuration options</b></summary>
205
-
206
- | Option | Default | Description |
207
- |--------|---------|-------------|
208
- | `gates` | `["types","lint","tests"]` | Which verification gates to run |
209
- | `maxIterations` | `5` | Max self-healing retry loops |
210
- | `verifyFreshness` | `600000` | Cache validity (ms, default 10min) |
211
- | `devServer.command` | -- | Start command for visual/runtime gates |
212
- | `devServer.port` | -- | Dev server port |
213
- | `devServer.readyPattern` | -- | Stdout pattern for server ready |
214
- | `prdPath` | -- | PRD path for acceptance criteria gate |
215
- | `linearProject` | -- | Linear project name for lifecycle sync |
216
- | `review.blocking` | `false` | Whether review findings block the pipeline |
217
-
218
- **Environment:** Set `FORGE_LINEAR_API_KEY` to enable Linear integration.
219
-
220
- </details>
221
-
222
- ### CLI
223
-
224
- ```bash
225
- npx forge verify # Run all gates
226
- npx forge verify --gate types # Run specific gates
227
- npx forge status # Branch, config, last verification
228
- npx forge doctor # Environment health check
229
- npx forge cleanup # Prune stale worktrees + branches
230
- npx forge run # Auto-chain all milestones
231
- ```
232
-
233
- ### Enforcement Hooks
234
-
235
- Forge installs two Claude Code hooks automatically during setup:
236
-
237
- - **Pre-commit hook** -- Blocks commits that haven't passed verification. Checks branch protection, cache freshness, and gate results.
238
- - **Version check hook** -- Non-blocking notice when a newer forge-cc version is available.
239
-
240
- ### MCP Server
241
-
242
- Expose gates as MCP tools for programmatic access:
243
-
244
- ```json
245
- {
246
- "mcpServers": {
247
- "forge-cc": {
248
- "command": "node",
249
- "args": ["node_modules/forge-cc/dist/server.js"]
250
- }
251
- }
252
- }
253
- ```
254
-
255
- ---
256
-
257
- ## How It's Different
258
-
259
- | Without forge | With forge |
260
- |--------------|-----------|
261
- | Agent writes code, you review everything | Agent teams build, verify, review, and fix their own code |
262
- | Manual git branching, PRs, merges | Automatic branches, worktrees, and PRs |
263
- | "Tests pass" = done | 8 gates including visual regression, PRD compliance, and AI code review |
264
- | One agent, one task, serial | Parallel agent teams with wave-based execution |
265
- | Context rot across long sessions | Fresh session per milestone, no degradation |
266
- | Linear updated manually | Bidirectional sync -- forge moves issues through your pipeline |
267
-
268
- ---
269
-
270
- <details>
271
- <summary><h2>Agent & Contributor Reference</h2></summary>
272
-
273
- ### Project Structure
274
-
275
- ```
276
- forge-cc/
277
- src/
278
- cli.ts # CLI entry (npx forge)
279
- server.ts # MCP server (stdio transport)
280
- types.ts # Core types
281
- gates/ # Verification gates + remediation
282
- config/ # .forge.json schema + auto-detection
283
- linear/ # Linear API client + lifecycle
284
- hooks/ # Pre-commit enforcement
285
- reporter/ # Human + JSON output formatting
286
- state/ # Session state reader/writer
287
- spec/ # Spec engine (scanner, interview, generator)
288
- go/ # Execution engine (verify loop, auto-chain, finalize)
289
- setup/ # Project scaffolding templates
290
- worktree/ # Worktree manager, session registry, state merge
291
- utils/ # Platform utilities (atomic writes, paths)
292
- skills/ # Claude Code skill definitions
293
- hooks/ # Installable hook files
294
- tests/ # Test suite (vitest)
295
- ```
296
-
297
- ### Development
298
-
299
- ```bash
300
- npm install # Dependencies
301
- npm run build # Build
302
- npm test # Tests
303
- npm run dev # Watch mode
304
- npx forge verify # Self-verify
305
- ```
306
-
307
- **Stack:** TypeScript (ES2022 strict), Node.js 18+, MCP SDK, Commander, Playwright, Zod, Vitest
308
-
309
- ### Agent Team Architecture
310
-
311
- During `/forge:go`, forge creates a 3-tier agent team:
312
-
313
- - **Executive** -- The orchestrator. Plans waves, assigns tasks, manages state, resolves deadlocks.
314
- - **Reviewer** -- Persistent Opus agent. Examines diff after each wave against PRD acceptance criteria. Sends structured findings (file/line/message/remediation). Participates in consensus protocol with builders.
315
- - **Builders** -- Parallel Opus agents, one per task. Full-capability (file editing, git, shell). Can spawn subagents for research. Stage only their files.
316
- - **Notetaker** -- Optional, spawned for 3+ waves or 4+ agents per wave. Tracks decisions, file ownership, cross-agent dependencies.
317
-
318
- **Consensus protocol:** Reviewer sends findings to builders. Builders respond agree/disagree/propose alternative. Up to 2 rounds of back-and-forth. Deadlocks escalate to executive.
319
-
320
- ### Gate Pipeline Details
321
-
322
- Gates run in configured order. If all core gates (types, lint, tests) fail, remaining gates are skipped. Each gate has a 2-minute timeout. Results are cached per-branch to `.forge/verify-cache/<branch>.json`.
323
-
324
- The self-healing loop parses failures into structured remediation templates -- each error includes file path, line number, error message, and a specific fix hint. Fix agents receive only the errors to fix, keeping context minimal and focused.
325
-
326
- ### Worktree Internals
327
-
328
- Each session creates a worktree at `../.forge-wt/<repo>/<session-id>/` branching from the feature branch. Active sessions are tracked in `.forge/sessions.json`. On completion, the worktree branch merges back to the feature branch, then the worktree and its branch are deleted.
329
-
330
- The parallel scheduler analyzes milestone `dependsOn` fields, builds a DAG, detects cycles, and groups independent milestones into parallel waves that execute simultaneously in separate worktrees.
331
-
332
- </details>
333
-
334
- ---
335
-
336
- <p align="center">
337
- <sub>MIT License &bull; Built for <a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a></sub>
338
- </p>
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/badge/forge--cc-Autonomous_Dev_Workflow-white?style=for-the-badge&labelColor=000000" />
4
+ <img src="https://img.shields.io/badge/forge--cc-Autonomous_Dev_Workflow-000000?style=for-the-badge&labelColor=white" alt="forge-cc" />
5
+ </picture>
6
+ </p>
7
+
8
+ <p align="center">
9
+ <strong>Idea to merged PR. Autonomous agent teams. Zero manual git.</strong>
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://www.npmjs.com/package/forge-cc"><img src="https://img.shields.io/npm/v/forge-cc?style=flat-square&color=0969da" alt="npm" /></a>
14
+ <img src="https://img.shields.io/badge/Claude_Code-plugin-7c3aed?style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTIgMkw0IDdWMTdMMTIgMjJMMjAgMTdWN0wxMiAyWiIgZmlsbD0id2hpdGUiLz48L3N2Zz4=&logoColor=white" alt="Claude Code" />
15
+ <img src="https://img.shields.io/badge/node-%3E%3D18-339933?style=flat-square&logo=node.js&logoColor=white" alt="node" />
16
+ <img src="https://img.shields.io/npm/l/forge-cc?style=flat-square&color=22863a" alt="MIT" />
17
+ </p>
18
+
19
+ ---
20
+
21
+ ## What is forge-cc?
22
+
23
+ forge-cc is a Claude Code plugin that turns your AI coding agent into an autonomous development team. You describe what you want to build. Forge breaks it into milestones, spins up parallel agent teams in isolated worktrees, verifies every line of code through automated gates, and creates the PR -- all without you touching git.
24
+
25
+ ```
26
+ npm install -g forge-cc
27
+ ```
28
+
29
+ ---
30
+
31
+ ## The Workflow
32
+
33
+ Five skill commands take you from raw idea to production-ready, merged code.
34
+
35
+ ```
36
+ +-----------------------------------------------------------------------------------+
37
+ | |
38
+ | YOU HAVE AN IDEA FORGE DOES THE REST |
39
+ | |
40
+ | "We need auth, +-----------+ +-----------+ +-----------+ |
41
+ | a dashboard, | | | | | | |
42
+ | and email | TRIAGE +--> SPEC +--> GO | |
43
+ | notifications" | | | | | | |
44
+ | +-----+-----+ +-----+-----+ +-----+-----+ |
45
+ | | | | |
46
+ | Creates Linear Scans codebase Agent teams |
47
+ | projects from + interviews build each |
48
+ | brain dump you + generates milestone |
49
+ | PRD + milestones in worktrees |
50
+ | | |
51
+ | v |
52
+ | +----------------+ |
53
+ | | VERIFY + PR | |
54
+ | +----------------+ |
55
+ | |
56
+ +-----------------------------------------------------------------------------------+
57
+ ```
58
+
59
+ ### `/forge:triage` -- Brain Dump to Backlog
60
+
61
+ Paste sticky notes, Slack messages, or stream-of-consciousness feature ideas. Forge extracts distinct projects, deduplicates against your existing Linear backlog, and creates them after your confirmation.
62
+
63
+ ### `/forge:spec` -- Project to PRD
64
+
65
+ Pick a project from Linear. Forge scans your codebase in parallel (structure, routes, dependencies, patterns), then conducts an adaptive interview -- leading with recommendations based on what it found, not blank-slate questions. The output is a full PRD with milestones sized to fit agent context windows, synced back to Linear with issues and status tracking.
66
+
67
+ ### `/forge:go` -- Milestones to Merged Code
68
+
69
+ This is the engine. Each milestone is executed by an autonomous agent team:
70
+
71
+ ```
72
+ +---------------------------------------------------------------------+
73
+ | EXECUTIVE (orchestrator) |
74
+ | Plans waves, assigns tasks, resolves escalations |
75
+ +---------------------------------------------------------------------+
76
+ | REVIEWER (persistent across all waves) |
77
+ | Reviews diff against PRD after each wave |
78
+ | Findings go through consensus protocol with builders |
79
+ +-------------------+-------------------+-----------------------------+
80
+ | BUILDER 1 | BUILDER 2 | BUILDER N ... |
81
+ | Parallel agents | Parallel agents | Each gets a task, |
82
+ | within each wave | within each wave | writes + tests code |
83
+ +-------------------+-------------------+-----------------------------+
84
+ | NOTETAKER (optional, for 3+ waves or 4+ agents) |
85
+ | Tracks decisions, file ownership, cross-agent dependencies |
86
+ +---------------------------------------------------------------------+
87
+ ```
88
+
89
+ **What happens during execution:**
90
+
91
+ ```
92
+ Wave 1 -> Verify -> Review -> Fix -> Wave 2 -> ... -> PR
93
+ | | | |
94
+ | | | +-- Fix agents spawn for accepted findings
95
+ | | +-- Reviewer + builders reach consensus on issues
96
+ | +-- Types + lint + tests run automatically (self-healing loop)
97
+ +-- Parallel builder agents execute independent tasks
98
+ ```
99
+
100
+ The agent team architecture is skill-driven (defined in `/forge:go` markdown), not baked into the TypeScript codebase. This makes the orchestration pattern easy to modify.
101
+
102
+ ### `npx forge run` -- Auto-Chain Milestones
103
+
104
+ Run all remaining milestones for a PRD autonomously via the Ralph loop. Each milestone gets a fresh Claude session (no context degradation), spawned in an isolated worktree. On verification failure, the loop retries up to `maxIterations` times before stopping.
105
+
106
+ ### `/forge:setup` and `/forge:update`
107
+
108
+ `/forge:setup` initializes a project: auto-detects your stack, creates `.forge.json`, installs skills and hooks, and scaffolds planning directories. `/forge:update` checks for newer forge-cc versions and upgrades.
109
+
110
+ ---
111
+
112
+ ## Verification Gates
113
+
114
+ Forge runs **3 verification gates** that catch issues before code ships:
115
+
116
+ ```
117
+ +----------+ +----------+ +----------+
118
+ | TYPES | | LINT | | TESTS |
119
+ | tsc | | biome | | vitest/ |
120
+ | --noEmit | | check | | jest |
121
+ +----------+ +----------+ +----------+
122
+ ```
123
+
124
+ | Gate | What it catches |
125
+ |------|----------------|
126
+ | **types** | Compilation errors, type mismatches (`tsc --noEmit`) |
127
+ | **lint** | Style violations, dead imports, code smells (`biome check`) |
128
+ | **tests** | Broken behavior, regressions (`vitest` or `jest`) |
129
+
130
+ Gates run sequentially with configurable per-gate timeouts (default 2 minutes each). Results are cached to `.forge/last-verify.json`.
131
+
132
+ **Self-healing (Ralph loop):** When a gate fails during `forge run`, the errors are fed back to Claude as structured context -- file path, line number, error message. Claude fixes the issues and re-runs verification. This loops up to `maxIterations` (default 5) times before stopping. Most failures resolve automatically.
133
+
134
+ ---
135
+
136
+ ## Linear Integration
137
+
138
+ Forge manages your Linear project lifecycle end-to-end. Every state transition happens automatically as work progresses:
139
+
140
+ ```
141
+ Linear State: Backlog --> Planned --> In Progress --> In Review --> Done
142
+ | | | | |
143
+ Forge Action: triage /forge:spec /forge:go /forge:go user merges,
144
+ creates generates PRD, starts last milestone runs
145
+ projects syncs milestones milestone completes linear-sync done
146
+ ```
147
+
148
+ State names are configurable via `linearStates` in `.forge.json` (default: "Planned", "In Progress", "In Review", "Done").
149
+
150
+ Set `LINEAR_API_KEY` in your environment to enable. Forge creates projects, milestones, and issues during spec, transitions them through states during execution, and marks them done when the user merges the PR.
151
+
152
+ ---
153
+
154
+ ## Branch & Worktree Management
155
+
156
+ You never touch git. Forge handles the entire branch lifecycle:
157
+
158
+ ```
159
+ main -----------------------------------------------------------> main (updated)
160
+ | ^
161
+ +---> feat/my-project ---> worktree m1 ---> wave 1..N ---> merge ---+
162
+ | |
163
+ +---> worktree m2 ---> (sequential)---+
164
+ ```
165
+
166
+ **Worktree isolation** -- Each milestone runs in its own git worktree at `../.forge-wt/<repo>/<slug>-m<N>/`. Parallel agents within a wave share the worktree, but separate milestones get separate worktrees. Merges back to the feature branch use `--ff-only`.
167
+
168
+ **Minimal footprint** -- Worktree management is 3 functions (~50 lines): `createWorktree`, `mergeWorktree`, `removeWorktree`. No session registry, no parallel scheduler, no sessions.json.
169
+
170
+ **Automatic cleanup** -- When a milestone finishes (pass or fail), its worktree is removed. Protected branches (`main`, `master`) are never committed to directly.
171
+
172
+ ---
173
+
174
+ ## Quick Start
175
+
176
+ ```bash
177
+ # 1. Install
178
+ npm install -g forge-cc
179
+
180
+ # 2. Set up your project
181
+ npx forge setup
182
+
183
+ # 3. (Optional) Set Linear API key for project management
184
+ export LINEAR_API_KEY="lin_api_..."
185
+
186
+ # 4. Start building
187
+ # /forge:triage -> /forge:spec -> /forge:go
188
+ ```
189
+
190
+ `forge setup` auto-detects your stack (TypeScript, Biome, test runner), creates `.forge.json`, installs enforcement hooks, syncs skill files to `~/.claude/commands/forge/`, and updates your `CLAUDE.md`. Run `npx forge doctor` anytime to check your environment.
191
+
192
+ ### Configuration
193
+
194
+ `.forge.json` in your project root:
195
+
196
+ ```json
197
+ {
198
+ "gates": ["types", "lint", "tests"],
199
+ "maxIterations": 5,
200
+ "linearTeam": "ENG"
201
+ }
202
+ ```
203
+
204
+ <details>
205
+ <summary><b>Full configuration reference</b></summary>
206
+
207
+ | Option | Type | Default | Description |
208
+ |--------|------|---------|-------------|
209
+ | `gates` | `string[]` | `["types", "lint", "tests"]` | Which verification gates to run |
210
+ | `gateTimeouts` | `Record<string, number>` | `{}` | Per-gate timeout in ms (default 120000 per gate) |
211
+ | `maxIterations` | `number` | `5` | Max Ralph loop retry iterations |
212
+ | `linearTeam` | `string` | `""` | Linear team key or name for lifecycle sync |
213
+ | `linearStates` | `object` | see below | Custom Linear state names |
214
+ | `verifyFreshness` | `number` | `600000` | Verify cache validity in ms (default 10 min) |
215
+ | `forgeVersion` | `string` | `"1.0.0"` | Version stamp from setup (used by version-check hook) |
216
+
217
+ **`linearStates` defaults:**
218
+
219
+ ```json
220
+ {
221
+ "planned": "Planned",
222
+ "inProgress": "In Progress",
223
+ "inReview": "In Review",
224
+ "done": "Done"
225
+ }
226
+ ```
227
+
228
+ **Environment:** Set `LINEAR_API_KEY` to enable Linear integration.
229
+
230
+ </details>
231
+
232
+ ---
233
+
234
+ ## CLI Reference
235
+
236
+ ```bash
237
+ # Verification
238
+ npx forge verify # Run all configured gates
239
+ npx forge verify --gate types,lint # Run specific gates
240
+ npx forge verify --json # Output results as JSON
241
+
242
+ # Milestone execution
243
+ npx forge run --prd <slug> # Auto-chain all milestones for a PRD
244
+
245
+ # Status
246
+ npx forge status # Show PRD progress across all projects
247
+
248
+ # Setup & maintenance
249
+ npx forge setup # Initialize forge for a project
250
+ npx forge setup --skills-only # Only sync skill files
251
+ npx forge doctor # Environment health check
252
+ npx forge update # Check for and install updates
253
+
254
+ # Linear sync (used by skills, can also be called directly)
255
+ npx forge linear-sync start --slug <slug> --milestone <n>
256
+ npx forge linear-sync complete --slug <slug> --milestone <n> [--last] [--pr-url <url>]
257
+ npx forge linear-sync done --slug <slug>
258
+ npx forge linear-sync list-issues --slug <slug>
259
+ ```
260
+
261
+ ### Skill Commands
262
+
263
+ Skills are Claude Code slash commands installed to `~/.claude/commands/forge/`:
264
+
265
+ | Skill | Description |
266
+ |-------|-------------|
267
+ | `/forge:triage` | Brain dump to Linear projects -- extracts, deduplicates, creates |
268
+ | `/forge:spec` | Linear project to PRD with milestones -- scans codebase, interviews, generates |
269
+ | `/forge:go` | Execute milestones with wave-based agent teams -- build, verify, review, PR |
270
+ | `/forge:setup` | Run project scaffolding -- config, hooks, skills, CLAUDE.md |
271
+ | `/forge:update` | Check for updates and upgrade forge-cc |
272
+
273
+ ### Enforcement Hooks
274
+
275
+ Forge installs two Claude Code hooks during setup:
276
+
277
+ - **Pre-commit hook** (`pre-commit-verify.js`) -- Blocks commits that haven't passed verification. Checks branch protection (no direct commits to main/master), verify cache freshness, and `result === 'PASSED'` in `.forge/last-verify.json`.
278
+ - **Version check hook** (`version-check.js`) -- Non-blocking notice when a newer forge-cc version is available or when project setup is stale.
279
+
280
+ ### MCP Server
281
+
282
+ Expose the verification pipeline as an MCP tool for programmatic access:
283
+
284
+ ```json
285
+ {
286
+ "mcpServers": {
287
+ "forge-cc": {
288
+ "command": "node",
289
+ "args": ["node_modules/forge-cc/dist/server.js"]
290
+ }
291
+ }
292
+ }
293
+ ```
294
+
295
+ **Tool:** `forge_run_pipeline`
296
+
297
+ | Input | Type | Description |
298
+ |-------|------|-------------|
299
+ | `projectDir` | `string?` | Project directory (defaults to cwd) |
300
+ | `gates` | `string[]?` | Filter to specific gates |
301
+
302
+ Returns the full pipeline result as JSON (result status, per-gate pass/fail, errors with file/line/message).
303
+
304
+ ---
305
+
306
+ ## How It's Different
307
+
308
+ | Without forge | With forge |
309
+ |--------------|-----------|
310
+ | Agent writes code, you review everything | Agent teams build, verify, review, and fix their own code |
311
+ | Manual git branching, PRs, merges | Automatic worktrees, branches, and PRs |
312
+ | "Tests pass" = done | 3 gates: types + lint + tests, with self-healing retry loop |
313
+ | One agent, one task, serial | Parallel agent teams with wave-based execution |
314
+ | Context rot across long sessions | Fresh session per milestone, no degradation |
315
+ | Linear updated manually | Automatic state transitions through your pipeline |
316
+
317
+ ---
318
+
319
+ ## Troubleshooting
320
+
321
+ <details>
322
+ <summary><b>Common issues</b></summary>
323
+
324
+ ### `forge run` fails when invoked from within Claude Code
325
+
326
+ Forge strips the `CLAUDECODE` environment variable before spawning `claude` subprocesses. Claude Code uses this variable to detect nested sessions and blocks them. If `forge run` hangs or exits immediately, ensure you're running it from a terminal, not from inside an active Claude Code session. When invoked via the `/forge:go` skill, this is handled automatically.
327
+
328
+ ### Pre-commit hook blocks commits
329
+
330
+ The pre-commit hook requires a passing verification cached in `.forge/last-verify.json`. Run `npx forge verify` to populate the cache. The cache expires after `verifyFreshness` ms (default 10 minutes).
331
+
332
+ ### Linear sync runs but does nothing
333
+
334
+ If `forge linear-sync` produces no output, check:
335
+ 1. `LINEAR_API_KEY` is set in your environment
336
+ 2. Your `.planning/status/<slug>.json` has `linearTeamId` and `linearProjectId` populated (these are set during `/forge:spec`)
337
+ 3. Run `npx forge doctor` to validate the API key and team configuration
338
+
339
+ ### `forge run` on Windows
340
+
341
+ On Windows, to locate the globally installed `forge-cc` package programmatically, use `process.env.APPDATA + '/npm/node_modules/forge-cc'`. Don't use bash path traversal -- backslash escaping breaks (the `\n` in `npm\node_modules` is interpreted as a newline).
342
+
343
+ ### Doctor says checks failed
344
+
345
+ Run `npx forge doctor` to see which checks fail. Required: Node.js >= 18 and git. Optional: `gh` CLI (for PR workflows), `LINEAR_API_KEY` (for Linear integration).
346
+
347
+ </details>
348
+
349
+ ---
350
+
351
+ <details>
352
+ <summary><h2>Architecture & Contributor Reference</h2></summary>
353
+
354
+ ### Project Structure
355
+
356
+ ```
357
+ forge-cc/
358
+ src/
359
+ cli.ts # CLI entry (npx forge)
360
+ server.ts # MCP server (stdio transport)
361
+ types.ts # Core types
362
+ doctor.ts # Environment health checks
363
+ setup.ts # Project scaffolding
364
+ config/
365
+ loader.ts # .forge.json reader + auto-detection
366
+ schema.ts # Zod schema for .forge.json
367
+ gates/
368
+ index.ts # Gate registry + pipeline runner
369
+ types-gate.ts # TypeScript gate (tsc --noEmit)
370
+ lint-gate.ts # Lint gate (biome check)
371
+ tests-gate.ts # Tests gate (vitest/jest)
372
+ linear/
373
+ client.ts # @linear/sdk wrapper (team-scoped)
374
+ sync.ts # Linear state transitions
375
+ runner/
376
+ loop.ts # Ralph loop executor
377
+ prompt.ts # Prompt builder + PRD section extractor
378
+ update.ts # Version check
379
+ state/
380
+ status.ts # PRD status CRUD
381
+ cache.ts # Verify cache writer
382
+ worktree/
383
+ manager.ts # createWorktree, mergeWorktree, removeWorktree
384
+ skills/ # Claude Code skill definitions (markdown)
385
+ hooks/ # Installable hooks (pre-commit, version-check)
386
+ tests/ # Test suite (vitest)
387
+ ```
388
+
389
+ ### Design Decisions
390
+
391
+ **Skill-driven orchestration.** The agent team architecture (executive, reviewer, builders, notetaker) is defined in skill markdown files, not in TypeScript. This means the orchestration pattern can be modified by editing a markdown file -- no code changes, no builds.
392
+
393
+ **File system as memory.** Milestones communicate through `.planning/status/<slug>.json` files and the PRD itself. No in-memory state is passed between milestones. This enables the "fresh process per milestone" pattern that avoids context degradation.
394
+
395
+ **Minimal worktree management.** Three functions, ~50 lines. No session registry, no parallel DAG scheduler. Worktrees are created at `../.forge-wt/<repo>/<slug>-m<N>/` and cleaned up after each milestone.
396
+
397
+ **Gate pipeline, not gate tree.** Gates run sequentially, not in parallel. This is intentional -- types must pass before lint makes sense, lint before tests. Per-gate timeouts (default 2 minutes) prevent hangs.
398
+
399
+ ### Extension Points
400
+
401
+ **Adding a gate:** Create a new file in `src/gates/` implementing the `Gate` interface (`name: string`, `run: (projectDir: string) => Promise<GateResult>`). Register it in `src/cli.ts` and `src/server.ts` with `registerGate()`.
402
+
403
+ **Custom Linear states:** Override the default state names in `.forge.json`:
404
+
405
+ ```json
406
+ {
407
+ "linearStates": {
408
+ "planned": "Todo",
409
+ "inProgress": "Doing",
410
+ "inReview": "Review",
411
+ "done": "Complete"
412
+ }
413
+ }
414
+ ```
415
+
416
+ **Custom gate timeouts:** Set per-gate timeouts in milliseconds:
417
+
418
+ ```json
419
+ {
420
+ "gateTimeouts": {
421
+ "tests": 300000
422
+ }
423
+ }
424
+ ```
425
+
426
+ ### Key Lessons Learned
427
+
428
+ These lessons were learned during forge-cc's own development and are baked into the workflow:
429
+
430
+ - **Milestone sizing matters.** Every milestone must be completable in one agent context window. If it's too large, split it. The `/forge:spec` skill enforces this.
431
+ - **No compaction chaining.** Never rely on Claude Code's context compaction for multi-milestone execution. Fresh processes per milestone (via `forge run`) are the correct pattern -- the file system is the only memory between iterations.
432
+ - **Restage at wave boundaries.** Parallel builder agents can disrupt each other's git index. Restage all files at wave boundaries.
433
+ - **Verify between waves.** Run `tsc --noEmit` between every wave, not just at the end. Catches cross-agent integration issues early.
434
+ - **Silent failure is a bug.** CLI commands that touch external systems must print what they did or why they skipped. No-output-as-success is not acceptable.
435
+
436
+ ### Development
437
+
438
+ ```bash
439
+ npm install # Dependencies
440
+ npm run build # Build
441
+ npm test # Tests
442
+ npx tsc --noEmit # Type check
443
+ npx forge verify # Self-verify
444
+ ```
445
+
446
+ **Stack:** TypeScript (ES2022 strict), Node.js 18+, MCP SDK, Commander, Zod, Vitest
447
+
448
+ </details>
449
+
450
+ ---
451
+
452
+ <p align="center">
453
+ <sub>MIT License &bull; Built for <a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a></sub>
454
+ </p>