From cwf
Orchestrates plan implementation by decomposing into parallelizable tasks, spawning domain agents, and verifying BDD criteria. Triggers on 'cwf:impl' or 'implement this plan'.
npx claudepluginhub corca-ai/claude-plugins --plugin cwfThis skill uses the workspace's default tool permissions.
Execute an approved plan predictably while preserving constraints, dependencies, and BDD validation.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Execute an approved plan predictably while preserving constraints, dependencies, and BDD validation.
cwf:impl # Auto-detect most recent plan.md
cwf:impl <path/to/plan.md> # Explicit plan path
cwf:impl --skip-branch # Skip Phase 0.5 branch gate (stay on current branch)
cwf:impl --skip-clarify # Skip Phase 1.0 clarify pre-condition check
Use the live-state helper for scalar fields, then initialize list fields in the resolved live-state file:
bash {CWF_PLUGIN_DIR}/scripts/cwf-live-state.sh set . \
phase="impl" \
task="{plan goal summary}"
live_state_file=$(bash {CWF_PLUGIN_DIR}/scripts/cwf-live-state.sh resolve)
In {live_state_file}, set live.key_files to the plan's key files list and initialize live.decision_journal as an empty list:
live:
phase: "impl"
task: "{plan goal summary}"
decision_journal: []
Throughout Phases 2-4, append significant decisions to live.decision_journal in the resolved live-state file (bash {CWF_PLUGIN_DIR}/scripts/cwf-live-state.sh resolve). Record decisions when:
Format each entry as a timestamped string:
decision_journal:
- "Phase 2: chose per-pattern commits — changes are cross-cutting"
- "Phase 3b: agent-2 deviated from plan — added error handling for edge case"
The compact recovery hook reads this field to restore decision context after auto-compaction. Keep entries concise (one line each, max ~80 chars).
Apply the Branch Gate. Never proceed on a base branch.
Find and parse the plan that drives implementation.
Apply the Clarify Completion Gate. Hard-blocks unless --skip-clarify is provided.
If an explicit path was provided, use it. Otherwise:
.cwf/projects/*/plan.md using Glob.plan.md exists inside live.dir from the resolved live-state file, prefer it.updated_at, created_at, generated_at, date).plan.md modification time.Ambiguity behavior (fail-closed):
If no plan is found, report to the user and stop:
No plan.md found in .cwf/projects/. Run cwf:plan first.
Check for a phase-handoff.md in the same directory as the discovered plan.md:
dirname {plan.md path}phase-handoff.md exists in that directoryIf phase-handoff.md is not found, proceed normally with plan.md only. Phase handoff is optional.
Read the plan and extract these sections (all optional except Steps):
| Section | Key Content |
|---|---|
| Context | Background, rationale |
| Goal | Desired outcome |
| Steps | Ordered implementation steps (REQUIRED) |
| Files to Create/Modify | File paths with actions |
| Success Criteria — Behavioral (BDD) | Given/When/Then scenarios |
| Success Criteria — Qualitative | Non-functional quality attributes |
| Don't Touch | Files explicitly out of scope |
| Deferred Actions | Items not for this session |
If the Steps section is missing or empty, report to the user and stop.
Present a summary and confirm before proceeding:
## Plan Loaded
**Source**: {path to plan.md}
**Goal**: {goal from plan}
**Steps**: {count} steps
**Files**: {count} files to create/modify
**BDD Criteria**: {count} scenarios
**Don't Touch**: {list or "none specified"}
**Phase Handoff**: {path to phase-handoff.md, or "not found (proceeding with plan only)"}
**Phase Protocols**: {count} protocols to follow
**Phase Do NOT**: {count} prohibitions
Proceed with implementation?
Use AskUserQuestion with options: "Proceed", "Review plan first", "Cancel".
Resolve lessons.md in the same directory as the selected plan.md.
lessons.md does not exist, create it immediately using the structure from plan-protocol.md.Break the plan into parallelizable work items and size the agent team.
Read {SKILL_DIR}/references/agent-prompts.md Section "Domain Signal Table".
For each step, identify the primary domain by matching:
Read {SKILL_DIR}/references/agent-prompts.md Section "Dependency Detection Heuristics".
Analyze step-to-step dependencies:
Group steps into work items:
Read {SKILL_DIR}/../../references/agent-patterns.md for general agent principles.
| Work Items | Agents | Strategy |
|---|---|---|
| 1 (≤3 files) | 0 | Direct execution — Phase 3a |
| 2-3 | 2 | Group related items per agent |
| 4-6 | 3 | Balance parallelism vs coordination |
| 7+ | 4 (hard cap) | Beyond 4, overhead exceeds gains |
Before finalizing work items, detect browser-runtime debugging scope from step text and file signals (for example: console, DOM, CDP, DevTools, click/focus/navigation regressions, viewport or mobile regressions, HTML/CSS/SPA runtime files).
If detected:
web-debugsession_dir from live.dir in the resolved live-state file, then reserve {session_dir}/debug/{timestamp}-{slug}/Before finalizing decomposition, assess whether changes are cross-cutting:
Commit Group column to group files by the concept they implement, regardless of work item assignment.Commit Group needed.Show the decomposition before executing:
## Decomposition
### Work Items
| # | Steps | Domain | Files | Parallel | Commit Group |
|---|-------|--------|-------|----------|--------------|
| 1 | 1, 2 | {domain} | {file list} | yes | {group or "—"} |
| 2 | 3 | {domain} | {file list} | yes | {group or "—"} |
| 3 | 4, 5 | {domain} | {file list} | after #1 | {group or "—"} |
### Execution Strategy
- **Mode**: {Direct (3a) | Agent Team (3b)}
- **Agents**: {count}
- **Batches**: {count} (sequential batches of parallel items)
- **Commit Strategy**: {per work item | per change pattern}
### Don't Touch (enforced)
- {files from plan's Don't Touch section}
If Agent Team mode: use AskUserQuestion with "Execute", "Adjust grouping", "Cancel". If Direct mode: proceed without confirmation.
For simple plans (1 work item, ≤3 files).
Execute each step in the work item sequentially
Use Write, Edit, Bash, and other allowed tools directly
Follow the plan's step descriptions precisely
If the item is web-debug, run Web Debug Loop Protocol and persist before/after evidence under {session_dir}/debug/{timestamp}-{slug}/
Respect the "Don't Touch" list — never modify those files
If phase-handoff.md was loaded, apply its Implementation Hints during execution and respect its "Do NOT" constraints
Append newly discovered learnings to lessons.md before commit (user language).
Commit Gate: Apply the Commit Gate. Stage specific files and commit with Conventional Commit format.
After commit, proceed to Phase 4
For complex plans requiring parallel work.
For each work item, build an agent prompt using the template from {SKILL_DIR}/references/agent-prompts.md Section "Implementation Agent Prompt Template". The prompt includes:
web-debug items, explicit instruction to run Web Debug Loop Protocol and persist evidence paths in the final reportLaunch agents for parallel-safe work items in a single message with multiple Task tool calls:
# All parallel items in one message
Task tool (item 1):
subagent_type: general-purpose
mode: bypassPermissions
prompt: |
{constructed prompt from 3b.1}
Task tool (item 2):
subagent_type: general-purpose
mode: bypassPermissions
prompt: |
{constructed prompt from 3b.1}
If some work items depend on others:
Between batches, briefly verify that prior batch outputs exist and are valid before launching the next batch.
After each batch completes (before launching the next batch), apply the Commit Gate.
File-to-work-item mapping: The orchestrator maintains a map derived from Phase 2 decomposition ({work_item_id → [file_paths]}). Each agent's prompt (from 3b.1) MUST include the list of files it is expected to modify. After batch completion, use this map to attribute files to work items. If an agent modifies unexpected files, include them in that work item's commit with a note.
Commit granularity: Determined by Phase 2.6 cross-cutting assessment:
Report after all commits in the batch:
Batch {N} committed:
- {short-hash} type(scope): summary
Apply the Lesson-Driven Commits protocol. Lesson-driven changes get separate commits with "Driven by lesson:" reference.
After each batch (and before launching the next), update lessons.md with any new findings:
Keep entries concise and in the user's language.
For each completed agent, append a structured result record (session artifact):
{session_dir}/impl-result-provenance.mdFor each row, capture:
source (REAL_EXECUTION | CACHED | FALLBACK)tool (for example claude-task, codex, gemini)agent_id (or slot identifier)started_at_utc, finished_at_utc, duration_msIf any provenance field is unavailable, persist — explicitly (never omit key columns).
Check implementation against the plan's success criteria.
For each BDD scenario from the plan (and from phase-handoff.md Success Criteria, if present):
For each qualitative criterion, briefly note how the implementation addresses it (or flag if it doesn't).
Present the verification results:
## Implementation Complete
### BDD Criteria Coverage
| # | Scenario | Status | Notes |
|---|----------|--------|-------|
| 1 | {Given/When/Then summary} | Covered | {brief note} |
| 2 | {Given/When/Then summary} | Uncovered | {what's missing} |
### Qualitative Assessment
| Criterion | Assessment |
|-----------|------------|
| {criterion} | {how it's addressed} |
### Files Modified
| File | Action | Agent |
|------|--------|-------|
| {path} | Created | {agent # or "direct"} |
### Issues
- {any deviations, failures, or concerns}
If any BDD criteria are uncovered:
Run the session completeness check:
bash {CWF_PLUGIN_DIR}/scripts/check-session.sh --impl
If any FAIL items are reported, fix them before suggesting review. This ensures all required artifacts (plan.md, lessons.md, next-session.md) exist and cwf-state.yaml is properly updated.
After presenting the summary:
Implementation complete. To review the code quality and verify against
the plan's success criteria, run:
cwf:review --mode code
phase-handoff.md is present, its "Protocols to Follow" and "Do NOT" sections carry the same weight as plan constraints. They are not suggestions.plan.md alone. Phase handoff enriches but is never required.--skip-branch.git add -A: Only stage files known to belong to the current work item. Prevent accidental inclusion of unrelated changes.lessons.md as implementation progresses, not only at the end.source_ref, source_recommendation, triage_action, runtime_caller_check, deletion_premortem, and decision_id. If source_recommendation is missing, stop and complete triage context first. If triage_action diverges from source_recommendation, ask the user before proceeding. For deletion actions, do not continue until runtime-caller check and pre-mortem are both recorded.lessons.md stays in the user's language.web-debug must include before/after browser evidence and a reproducible path using Web Debug Loop Protocol.