phased-implement
Skill148 starsChanged 4 months agoMITView on GitHub
Coordinator workflow for multi-phase implementation across workmux worktrees. Generates or loads a master plan, dispatches phase agents using presets, verifies sentinels, merges serially, and performs integration verification.
The file
Show its rules and text
We split this skill into the rules it gives an agent
39 rules. About 0 are common, 23 are distinctive, and 16 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈23
Distinctive · estimate
This author's own choices. Worth a look.
16
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 9
Do not use Claude Code built-in worktree features.
- Very specific: line 18
Use bounded waits. Avoid tight polling and inspect workmux status on timeouts.
- Distinctive: line 20
Treat merge conflicts as merge failures for that phase, not as reasons to destroy the worktree.
- Distinctive: line 21
Read the master plan YAML semantically.
- Very specific: line 22
Keep all coordinator artifacts in one shared history/<date>-phased-<slug>/ run directory so worktrees can read prompts and write sentinels.
- Very specific: line 54
Write coordinator artifacts under history/ using a dated run directory:
- Distinctive: line 75
Do not require ADRs or feedback ledgers.
- Distinctive: line 89
Stop if unrelated uncommitted changes make orchestration unsafe.
- Very specific: line 102
If --plan <path> is provided, copy or write it to $PLAN_DIR/plan.md, read it, and validate it.
- Very specific: line 104
If no plan is provided, generate a master phased plan at $PLAN_DIR/plan.md.
- Distinctive: line 166
Before dispatch, validate the plan:
- Distinctive: line 168
Every phase id is unique.
- Distinctive: line 169
Every dependency names an existing phase.
- Distinctive: line 171
Every phase has a valid preset.
- Distinctive: line 172
Every phase has acceptance criteria.
- Distinctive: line 178
If validation fails, update the master plan directly and rerun validation.
- Distinctive: line 184
Use the exact local workmux command syntax when running commands in this repo.
- Very specific: line 190
If the ready set is empty and no phase is working, done-unverified, or merging, proceed to final integration validation.
- Distinctive: line 212
Wait for the next transition in bounded chunks:
- Very specific: line 219
If timeout occurs, inspect workmux status.
- Very specific: line 221
Treat done as unverified completion, not success.
- Distinctive: line 223
After every done handle has been verified and merged or marked failed, recompute the ready set.
- Very specific: line 227
When a phase becomes failed or blocked, stop spawning new dependent phases.
- Distinctive: line 235
Write one prompt file per phase:
- Very specific: line 312
When a handle transitions to done, capture output before deciding whether it succeeded:
- Very specific: line 329
If the sentinel is missing, reports blocked or failed, or fails verification, do not merge that phase.
- Distinctive: line 335
Use the existing merge skill in the phase worktree:
- Distinctive: line 345
Wait for merge completion in bounded chunks so conflicts or prompts are detected:
- Distinctive: line 356
Verify the post-merge worktree tip is an ancestor of the integration branch:
- Very specific: line 363
If ancestry verification passes, record POST_MERGE_TIP as the merged phase commit and remove the workmux worktree:
- Distinctive: line 369
If ancestry verification fails, capture output, keep the worktree, stop merging, and report the phase as blocked.
- Very specific: line 371
Do not use workmux remove before the merge and post-merge ancestry verification succeed.
- Distinctive: line 376
After each successful merge:
- Distinctive: line 383
If a phase fails, keep unrelated ready phases running only when their dependencies and paths are unaffected.
- Distinctive: line 387
When all phases merge:
- Very specific: line 389
Run the final integration validation command from the master plan or --validation.
- Distinctive: line 412
Only auto-fix localized must-fix issues with one clear answer.
- Very specific: line 416
Write a final summary under history/ and print it:
- Distinctive: line 458
If phases failed or blocked, list preserved worktrees and the capture files to inspect.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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
Coordinate multi-phase implementation across workmux worktrees. The coordinator owns the master plan, phase dispatch, merge order, ancestry checks, final integration validation, and final summary. The coordinator does not edit source files for feature work.
Do not use Claude Code built-in worktree features. Use workmux for worktree orchestration.
Operating principles
- Coordinator never writes source. All implementation happens inside spawned worktree agents through
/implement. workmux doneis not success. A phase succeeds only when its result sentinel reportsstatus: successand the coordinator verifies it.- Merges are serialized. At most one
/merge --keepruns at a time. - Dependents spawn only after every dependency is merged. No exceptions.
- Drain completed handles before dispatching dependents.
workmux wait --anycan return after one transition while sibling phases also finished. - Use bounded waits. Avoid tight polling and inspect
workmux statuson timeouts. - Preserve failed and blocked worktrees for inspection. Remove worktrees only after merge and ancestry verification succeed.
- Treat merge conflicts as merge failures for that phase, not as reasons to destroy the worktree.
- Read the master plan YAML semantically. Do not write shell parsers for YAML.
- Keep all coordinator artifacts in one shared
history/<date>-phased-<slug>/run directory so worktrees can read prompts and write sentinels.
Argument handling
Arguments are $ARGUMENTS.
Parse these flags before starting:
--plan <path>: load an existing master plan instead of generating one.--integration-branch <branch>: branch that receives phase merges. Default: current branch.--preset light|standard|design|strict: default preset for generated phases.--validation <command>: final integration validation command.--reviewer <selector>: consult-llm selector for optional integration review. Repeatable.--reviewers <selector,selector>: comma-separated reviewer selectors.--integration-review none|auto|full: final integration review policy. Default:auto.
Everything else is the requested multi-phase implementation.
Preset semantics:
light: established local pattern, focused validation, no external reviewstandard: bounded implementation with acceptance evidence and applicable runtime exercisedesign: meaningful ownership, API, or architecture choice, with one source-grounded technical-shape reviewstrict: real trust, persistence, protocol, migration, destructive, concurrency, or FFI boundary, with boundary evidence and one final diff review
Presets increase evidence, not planning or architecture.
Required artifacts
Write coordinator artifacts under history/ using a dated run directory:
history/<YYYY-MM-DD>-phased-<slug>/
plan.md
prompts/
captures/
summary.mdRequired:
- master phased plan at
history/<run>/plan.md - per-phase result sentinel at
history/<run>/captures/<phase-id>.result.md - final summary at
history/<run>/summary.md
Optional:
- external review capture
- debug notes
Do not require ADRs or feedback ledgers.
Phase A: snapshot and plan
Record the integration branch and start commit:
START_HEAD=$(git rev-parse HEAD) INTEGRATION_BRANCH=<integration-branch or current branch> git branch --show-current git rev-parse --verify "$INTEGRATION_BRANCH" git status --short- Stop if unrelated uncommitted changes make orchestration unsafe. The integration branch must exist and must not be a detached HEAD.
Pick a topic slug and create the shared run directory:
PLAN_DIR="history/<YYYY-MM-DD>-phased-<slug>" mkdir -p "$PLAN_DIR/prompts" "$PLAN_DIR/captures"history/is gitignored and shared across workmux worktrees in this repo style. Do not commit files from this directory.- Track phase state in coordinator memory with these statuses:
pending,working,done-unverified,merging,merged,failed,blocked. - If
--plan <path>is provided, copy or write it to$PLAN_DIR/plan.md, read it, and validate it. If no plan is provided, generate a master phased plan at
$PLAN_DIR/plan.md. Gather source context first with Glob, Grep, and Read. The master plan should be scheduling-focused, not code-heavy. Assign phase presets by risk:lightfor routine mechanical phases from a clear master planstandardfor non-trivial phases with known approachdesignfor uncertain, cross-module, or approach-heavy phasesstrictfor public contracts, data formats, security-sensitive work, migrations, or high regression risk
Generated plans should mark non-trivial phases as at least standard.
Master plan schema
The master plan must contain one YAML block and one brief per phase.
# <Feature> Master Plan
**Goal:** <one sentence>
**Integration branch:** <branch>
**Start commit:** <sha>
**Final validation:** `<command>`
```yaml
phases:
- id: api-contract
description: Define the public API contract for X.
depends_on: []
paths:
- "src/api/**"
- "tests/api/**"
preset: design
acceptance:
- "Given a valid request, when the API is called, then it returns the new response shape."
validation: npm test -- tests/api
```
## Phase briefs
### api-contract
**Intent:** why this phase exists
**Current problem:** what is wrong now
**Desired shape:** target behavior and boundaries
**Preserve:** behavior that must not change
**Avoid:** overreach and later-phase ownership
**Dependencies:** previous phase outputsRequired YAML fields per phase:
id: stable slug, unique across phasesdescription: one sentencedepends_on: list of phase idspaths: expected owned paths or globspreset:light,standard,design, orstrictacceptance: list of acceptance criteria
Optional field:
validation: phase-specific validation command
DAG validation
Before dispatch, validate the plan:
- Every phase id is unique.
- Every dependency names an existing phase.
- The graph has no cycles.
- Every phase has a valid preset.
- Every phase has acceptance criteria.
- Phase briefs exist for every phase.
- Phase path ownership is specific enough to detect obvious overlap.
- Overlapping paths are allowed only when dependencies serialize those phases or the brief explains the boundary.
- A final validation command exists or can be inferred.
If validation fails, update the master plan directly and rerun validation.
Phase B: dispatch loop
Dispatch phases whose dependencies have succeeded and merged. Parallel phases may run at the same time when dependencies are satisfied and path ownership is safe.
Use the exact local workmux command syntax when running commands in this repo. Do not switch to Claude Code worktrees.
Loop:
- Drain completed handles before spawning new work. Run Phase C and Phase D for every tracked handle that is already
donebefore recomputing the ready set. - Compute the ready set: phases with status
pendingwhose every dependency has statusmerged. - If the ready set is empty and no phase is
working,done-unverified, ormerging, proceed to final integration validation. For each ready phase:
- Resolve the preset and phase validation command.
- Write
$PLAN_DIR/prompts/<phase-id>.md. - Spawn a workmux worktree from the integration branch.
- Track the workmux handle and set phase status to
working.
workmux add <phase-id> -b --base "$INTEGRATION_BRANCH" -P "$PLAN_DIR/prompts/<phase-id>.md"Confirm newly spawned handles started with a bounded wait:
workmux wait <handles> --status working --timeout 120On timeout, inspect
workmux status. A fast phase may have moved straight todone; treatdoneas valid. Mark a handle failed only if it is missing, exited unexpectedly, or is stuck before it starts.- Recompute the live working handle set before every wait. Exclude phases that are already
done-unverified,merging,merged,failed, orblocked. Wait for the next transition in bounded chunks:
workmux wait <working-handles> --any --timeout 300 workmux status <working-handles>If timeout occurs, inspect
workmux status. If any handle iswaiting, capture it, mark itblocked, and halt its dependents. Otherwise continue waiting. If a handle exited unexpectedly, mark itfailed.- Treat
doneas unverified completion, not success. Set status todone-unverified, capture output, and run Phase C. - After every done handle has been verified and merged or marked failed, recompute the ready set. Skipping this drain can spawn dependents against a stale integration branch.
Halt logic:
- When a phase becomes
failedorblocked, stop spawning new dependent phases. - Mark every transitive dependent as
blockedwith the blocker phase id. - Let currently working phases that are not transitive dependents finish when their paths and dependencies are unaffected.
- Preserve failed and blocked worktrees for inspection.
- Continue to final summary after the loop drains or no safe progress remains.
Phase prompt template
Write one prompt file per phase:
# Phase Agent Prompt: <phase-id>
You are implementing one phase in a workmux worktree.
## Hard rules
- Work only on this phase.
- Invoke `/implement` for this phase with the resolved preset and phase context.
- Preserve the phase boundaries, acceptance criteria, and dependencies below.
- Commit successful changes in the phase worktree.
- Write the result sentinel exactly as requested.
## Invoke
Run this implementation workflow:
`/implement --preset <preset> --parent-plan <master-plan-path> --validation '<phase-validation-command>' <phase description and acceptance>`
## Phase context
- Phase id: `<phase-id>`
- Description: <description>
- Paths: <paths>
- Preset: `<preset>`
- Master plan: `<path>`
- Dependencies: <dependencies>
## Acceptance criteria
- <criterion>
## Phase brief
<brief from master plan>
## Result sentinel
Write `<plan-dir>/captures/<phase-id>.result.md`:
```markdown
# Phase Result: <phase-id>
status: success | blocked | failed
phase_id: <phase-id>
preset: light | standard | design | strict
worktree: <workmux worktree name>
base_commit: <sha>
head_commit: <sha>
commit: <sha>
validation: <command>
validation_status: passed | failed | skipped
## Summary
- <what changed>
## Acceptance
- <criterion>: met | not met | unknown
## Files changed
- <path>
## Blockers
- <blocker or none>
The phase agent should write the sentinel as its final action and treat a missing sentinel as failure.
## Phase C: result verification
When a handle transitions to `done`, capture output before deciding whether it succeeded:
```bash
workmux capture <phase-id> > "$PLAN_DIR/captures/<phase-id>.tail"Then read $PLAN_DIR/captures/<phase-id>.result.md. For each completed phase, the coordinator verifies:
- The result sentinel exists.
statusissuccess.head_commitandcommitare present.- The phase committed its work.
- Validation passed or any skipped validation is justified.
- Files changed are within phase scope or explained by the brief.
- Acceptance criteria are marked met or have clear explanation.
- Blockers are
none.
If the sentinel is missing, reports blocked or failed, or fails verification, do not merge that phase. Capture the workmux output, mark the phase failed or blocked, preserve the worktree, and halt dependents.
Phase D: merge workflow
Merge successful phases serially into the integration branch. Before each merge, ensure the integration branch is checked out and current.
Use the existing merge skill in the phase worktree:
/merge --keepAt a high level:
- Capture the phase tip from the sentinel before merge for diagnostics:
head_commit. - Send
/merge --keepto the phase worktree agent with workmux. Wait for merge completion in bounded chunks so conflicts or prompts are detected:
workmux send <phase-id> "/merge --keep" workmux wait <phase-id> --timeout 60 workmux status <phase-id>Repeat the wait/status cycle until the merge finishes, a bounded timeout is reached, or the handle enters
waiting. If it enterswaiting, capture output to$PLAN_DIR/captures/<phase-id>.merge.tail, keep the worktree, mark the phase blocked, and stop merging dependents.- Because
/mergemay rebase the phase before merging, read the worktree tip after/merge --keepreturns. The pre-mergehead_commitfrom the sentinel is not a stable ancestry token. Verify the post-merge worktree tip is an ancestor of the integration branch:
POST_MERGE_TIP=$(workmux run <phase-id> -- git rev-parse HEAD) git merge-base --is-ancestor "$POST_MERGE_TIP" <integration-branch>If ancestry verification passes, record
POST_MERGE_TIPas the merged phase commit and remove the workmux worktree:workmux remove <phase-id>- If ancestry verification fails, capture output, keep the worktree, stop merging, and report the phase as blocked.
Do not use workmux remove before the merge and post-merge ancestry verification succeed.
The sentinel's pre-merge head_commit is for diagnostics only, not ancestry verification.
Phase E: continue the DAG
After each successful merge:
- Mark the phase as merged.
- Recompute ready phases.
- Dispatch newly unblocked phases.
- Continue until every phase is merged or no progress can be made.
If a phase fails, keep unrelated ready phases running only when their dependencies and paths are unaffected. Otherwise stop and summarize.
Phase F: final integration validation
When all phases merge:
- Run the final integration validation command from the master plan or
--validation. - Inspect the integration diff and phase summaries.
- Confirm that acceptance criteria across phases are covered.
- Confirm there is no obvious cross-phase drift or conflict.
Final integration review policy:
none: skip external integration review.auto: run full external integration review when any phase useddesignorstrict, or when multiple phases changed shared contracts. Otherwise skip.full: always run full external integration review.
For final integration review, load the consult-llm skill before calling consult-llm. Attach the master plan, phase sentinels, and relevant diffs or files. Use --task review, supplied reviewer selectors if present, quoted heredoc terminator __CONSULT_LLM_END__, and Bash timeout 600000.
Prompt shape:
Review the integrated result of this multi-phase implementation.
Check whether the merged phases satisfy the master plan acceptance criteria. Focus on cross-phase compatibility, public contracts, regression risk, edge cases, validation adequacy, and security where relevant.
Return only actionable must-fix or should-fix issues. If the result is acceptable, say so directly.Only auto-fix localized must-fix issues with one clear answer. If review finds design or scope issues, stop and summarize them.
Final summary
Write a final summary under history/ and print it:
# Phased Implementation Summary: <feature>
status: success | blocked | failed
integration_branch: <branch>
start_commit: <sha>
end_commit: <sha>
master_plan: <path>
final_validation: <command>
final_validation_status: passed | failed | skipped
integration_review: none | skipped | passed | failed
## Phases
| Phase | Preset | Status | Commit | Sentinel |
| --- | --- | --- | --- | --- |
| <id> | <preset> | merged | <sha> | <path> |
## Acceptance
- <criterion>: met | not met | unknown
## Merges
- <phase>: merged and ancestry verified against post-merge tip `<post-merge-tip>`
## Blockers
- <blocker or none>
## Artifacts
- Prompts: `<plan-dir>/prompts/`
- Captures: `<plan-dir>/captures/`
## Next steps
- <only if needed>If phases failed or blocked, list preserved worktrees and the capture files to inspect. Report the final validation result, integration review result, merged phase commits, and blockers. If all phases merged and validation passed, state success plainly.
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.

