From forge
Use when Forge starts implementation after design approval, or when the user asks for parallel module development with worktrees, scoped tasks, PR review, and living-standard enforcement. Trigger on requests to split implementation, dispatch developers, or enforce consistent multi-agent coding.
npx claudepluginhub cjy5507/forge --plugin forgeThis skill uses the workspace's default tool permissions.
<Purpose>
Implements structured self-debugging workflow for AI agent failures: capture errors, diagnose patterns like loops or context overflow, apply contained recoveries, and generate introspection reports.
Monitors deployed URLs for regressions in HTTP status, console errors, performance metrics, content, network, and APIs after deploys, merges, or upgrades.
Provides React and Next.js patterns for component composition, compound components, state management, data fetching, performance optimization, forms, routing, and accessible UIs.
<Use_When>
<Core_Rules>
<Hybrid_Dispatch> Forge uses a 3-layer dispatch model. AgentRecommendation from scripts/lib/forge-state.mjs classifies agents automatically into the appropriate layer. Choose the lightest layer that meets the need.
Layer 0 — Prompt Switch (in-conversation): Lead-dev operates in the main conversation, not as a separate subagent. Claude switches to the lead-dev role by loading agents/lead-dev.md context. Use for: task splitting, lane-graph management, code review, merge decisions. No isolation needed — the lead works on the main branch.
Layer 1 — Team (iterative collaboration): When multiple agents need multi-turn back-and-forth (e.g., Developer ↔ Lead review cycles), use TeamCreate + SendMessage. Use for: review rounds, design discussions, cross-lane coordination. Context is preserved across rounds — no re-dispatch needed.
Layer 2 — Isolated Subagent (parallel execution): Developers and fact-checkers dispatch with Agent tool using isolation: "worktree" or subagent_type: "forge:developer" / "forge:fact-checker". Use for: module implementation, technical verification. Each agent gets its own worktree and minimal context. </Hybrid_Dispatch>
<Progressive_Disclosure>
references/review-pipeline.md when you need the full review tiers or worktree rules.references/lane-runtime.md when you need the standard runtime helper commands and lane graph rules.
</Progressive_Disclosure>Handoff Interview — Implementation Intake (tier-aware, see references/handoff-interview.md)
a. Lead Developer reads plan, tasks, architecture, contracts, code-rules,
components, tokens.
b. At the top of each .forge/tasks/{lane}.md brief (or plan.md for
cross-lane issues), Lead records any blockers that prevent dispatch
(ambiguous lane boundaries, missing contracts, unclear dependency order,
unknown test strategy) and any consequential assumptions. Free-form
bullets, no structured Q template. Convert non-consequential uncertainty
into fact-check tasks or QA checks, not questions.
c. For each blocker, Lead pings the owner directly via SendMessage
(CTO for architecture/contract, Designer for UX, PM for spec intent).
No CEO triage hop.
d. At full tier only, additionally write .forge/handoff-interviews/develop.md
(phase gate enforces this).
e. Blockers resolved → dispatch begins. The task briefs are the understanding
record; no separate statement, no two-party sign-off for no-blocker cases.
Lead Developer reads:
Dispatch Analyst (forge:analyst) for impact analysis when the saved planning analysis is stale or incomplete:
Lead validates the planning output before dispatch:
.forge/plan.mdIf the plan needs refinement:
.forge/plan.md.forge/tasks/{lane}.mdFor each ready lane, Lead creates a worktree and confirms ownership:
node scripts/forge-worktree.mjs create --lane {id} --branch forge/{id}node scripts/forge-lane-runtime.mjs assign-owner --lane {module} --owner {agent}Lead dispatches agents per execution batch:
Use the execution order already defined in .forge/plan.md / runtime dependencies.
For each batch, dispatch all lanes simultaneously:
Agent(
subagent_type="forge:developer", // or "forge:publisher" for UI lanes
isolation="worktree",
run_in_background=true,
prompt="Implement lane {id}: {title}. Follow .forge/code-rules.md and .forge/contracts/."
)
The subagent-start hook automatically injects lane-scoped context:
Wait for each batch to complete before starting the next batch.
If the task contains separable UI/API/state/test surfaces, split it so compatible lanes run in parallel.
If the task is truly single-scope, keep one lane and drive it to completion instead of manufacturing coordination overhead.
If any lane in the batch reaches review_state=approved, merge_state=ready, or merge_state=queued,
stop opening more implementation scope and land that lane first. Merge debt is a control-tower blocker,
not background work for later.
Batches with dependencies must run sequentially; lanes within a batch run in parallel.
Lead monitors completion:
node scripts/forge-lane-runtime.mjs summarize-lanes --json
Context budget (see references/context-budget.md):
Each developer implements their module:
a. Read assigned task definition (.forge/tasks/{module}.md)
b. Read relevant contracts (.forge/contracts/)
c. Read code-rules.md
d. Fact-check any uncertain technical claims before coding
e. Update lane status to in_progress
f. Implement the module
g. Run tests locally in the worktree
h. Write a handoff note before review:
node scripts/forge-lane-runtime.mjs write-handoff --lane {module} --note "{verification summary}"
i. Update lane status to in_review
j. If review requests changes, or the lane needs merge/rebase follow-up, reflect that state in runtime immediately instead of leaving it implicit in chat.
k. Create PR when all local tests pass
PR Review Pipeline (3 tiers):
Teams-based review (recommended for multi-turn feedback):
Sequential review (fallback — ALL tiers must approve):
Tier 1 — Automated Checks (instant):
Tier 2 — Lead Developer Review:
Tier 3 — CTO Review (architecture):
All tiers approve -> mark the lane review-approved / merge-ready in runtime, then merge to main:
node scripts/forge-lane-runtime.mjs mark-review-state --lane {module} --state approved --note "Lead/CTO review approved"
node scripts/forge-lane-runtime.mjs mark-merge-state --lane {module} --state ready --note "Ready to merge after review approval"
Leaving approved lanes unmerged creates merge debt and weakens the living standard for later lanes.
After each merge, update the lane record, then rebase all other active worktrees:
IMPORTANT — commit-based merge only (no diff/patch):
NEVER use git diff | git apply or git format-patch to integrate lane work.
Uncommitted worktree changes applied via text patches lose git's 3-way merge
capability and break when multiple lanes touch the same file.
Always use the commit → merge → rebase pipeline below.
Preferred — automated merge-lane command (commits + merges + rebases in one step):
node scripts/forge-worktree.mjs merge-lane --lane {module}
node scripts/forge-lane-runtime.mjs update-lane-status --lane {module} --status merged --note "Merged to main"
node scripts/forge-lane-runtime.mjs update-lane-status --lane {module} --status done --note "Worktree cleaned up"
merge-lane automatically: (a) commits any uncommitted changes, (b) merges the lane
branch into main with --no-ff, (c) rebases all remaining active worktrees onto main.
Fallback — manual steps (if merge-lane hits an edge case):
cd .forge/worktrees/{module} && git add -A && git commit -m "feat: {module} implementation"
git checkout main && git merge forge/{module} --no-ff
cd .forge/worktrees/{other-module} && git rebase main
Pre-merge check — before starting the merge sequence, verify all worktrees are committed:
node scripts/forge-worktree.mjs pre-merge
Repeat steps 7-9 until all PRs are merged
node scripts/forge-lane-runtime.mjs summarize-lanes to review the lane graph and blocked lanesCleanup worktrees: node scripts/forge-worktree.mjs remove --lane {module} (for each completed module)
Update state.json: phase=5, phase_name="qa"
node scripts/forge-lane-runtime.mjs set-company-gate --gate qa --gate-owner qa --delivery-state in_progressnode scripts/forge-lane-runtime.mjs write-session-handoff --summary "{what remains to verify}" --next-goal "Run QA and classify blockers" --next-owner qaCreate git tag: forge/v1-dev
Transition to Phase 5 (forge:qa)
<Worktree_Management> Create worktree: node scripts/forge-worktree.mjs create --lane {module} --branch forge/{module}
List active worktrees: node scripts/forge-worktree.mjs list
Rebase worktree after merge: cd .forge/worktrees/{module} && git rebase main
Remove worktree after merge: node scripts/forge-worktree.mjs remove --lane {module}
Prune stale worktrees: node scripts/forge-worktree.mjs prune </Worktree_Management>
<Lane_Runtime> Lane graph summary: node scripts/forge-lane-runtime.mjs summarize-lanes
Assign lane owner: node scripts/forge-lane-runtime.mjs assign-owner --lane {module} --owner {agent}
Update lane status: node scripts/forge-lane-runtime.mjs update-lane-status --lane {module} --status in_progress --note "{status note}"
Write handoff note: node scripts/forge-lane-runtime.mjs write-handoff --lane {module} --note "{handoff summary}"
Review and merge states:
in_review, blocked, merged, and done current in runtime as the lane moves through review and integration.<PR_Review_Checklist> Tier 1 — Automated: [ ] Lint: no warnings, no errors [ ] TypeScript: tsc --noEmit passes [ ] Tests: all test suites pass [ ] Secrets: no API keys, tokens, or credentials in diff [ ] Build: project builds successfully
Tier 2 — Lead Developer: [ ] Naming conventions match code-rules.md [ ] File structure matches code-rules.md [ ] Import patterns match code-rules.md [ ] Error handling matches code-rules.md [ ] Consistent with already-merged PRs (the living standard) [ ] Only touches files within assigned task scope [ ] Implements all required interface contracts [ ] No TODO/FIXME/HACK comments left unresolved
Tier 3 — CTO (when flagged): [ ] Module boundaries respected [ ] No circular dependencies introduced [ ] No hidden coupling between modules [ ] Performance implications acceptable [ ] Scalability concerns addressed </PR_Review_Checklist>
<Code_Consistency_Rule> The FIRST merged PR sets the living standard for the entire project.
All subsequent PRs must match:
When inconsistency is found, Lead rejects with explicit correction: "The already-merged code uses {pattern}. Please align to this standard:
<State_Changes>
<Tool_Usage>
node scripts/forge-worktree.mjs for worktree create/list/remove/prune (manual worktree path)node scripts/forge-lane-runtime.mjs for lane graph, owner, status, and handoff updates.forge/tasks/{module}.md from templates/task.md.forge/state.json and .forge/runtime.json
</Tool_Usage><Failure_Modes_To_Avoid>
.forge/runtime.json before dispatch<Auto_Chain> When development completes (all lanes merged, worktrees cleaned, forge/v1-dev tag created):