From cwf
Drafts reviewable execution plans for coding tasks by scoping goals, reusing evidence, researching gaps, applying BDD criteria, and persisting plans/lessons to files. Triggers: cwf:plan, plan this task.
npx claudepluginhub corca-ai/claude-plugins --plugin cwfThis skill uses the workspace's default tool permissions.
Create a reviewable execution contract (scope, files, success criteria) before code changes begin.
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.
Create a reviewable execution contract (scope, files, success criteria) before code changes begin.
cwf:plan <task description>
CWF v3 moved planning from runtime-specific plan-mode hooks to a runtime-independent skill (cwf:plan) with file-based contracts.
gather + clarify collect evidence and decision points before planning starts.lessons.md immediately, not after implementation.plan.md, lessons.md, and optional cwf:handoff --phase, instead of shifting context-management burden to the user.plan.md (WHAT) + phase-handoff.md (HOW, optional) + lessons.md (learned constraints) define a persistent contract for impl/review stages.Use the live-state helper (session-first write target):
bash {CWF_PLUGIN_DIR}/scripts/cwf-live-state.sh set . \
phase="plan" \
task="{task summary}"
## Task
"{user's task description verbatim}"
## Scope Summary
- **Goal**: {what we're trying to achieve}
- **Key Decisions**: {decisions that affect the plan}
- **Known Constraints**: {limitations, boundaries}
Resolve the effective live-state file, then read live.dir.
live_state_file=$(bash {CWF_PLUGIN_DIR}/scripts/cwf-live-state.sh resolve)
session_dir: "{live.dir value from resolved live-state file}"
Use persisted artifacts as the default planning evidence before launching any new research.
live.clarify_result_file when set.live.clarify_result_file){session_dir}/clarify-codebase-research.md{session_dir}/clarify-web-research.md{session_dir}/clarify-expert-alpha.md{session_dir}/clarify-expert-beta.md.meta.yaml) from the current session directoryIf no reusable artifacts are available, treat all unresolved decision points as gap candidates and continue to Phase 2.2.
Apply the context recovery protocol to these gap-fill output files:
| Agent | Output file |
|---|---|
| Prior Art Researcher | {session_dir}/plan-prior-art-research.md |
| Codebase Analyst | {session_dir}/plan-codebase-analysis.md |
Decision:
Assess each unresolved gap to decide which extra research lane is needed:
| Gap type | Agent decision |
|---|---|
| Gap is mainly repository-specific (existing architecture, constraints, local patterns) | Launch Codebase Analyst only |
| Gap is mainly external best practice / prior art | Launch Prior Art Researcher only |
| Gap spans both repository constraints and external practice | Launch both agents in parallel |
| Gap is already answerable from baseline after re-check | No launch for that gap |
When uncertain, prefer launching both agents.
Launch sub-agents simultaneously using the Task tool — only for lanes selected in Phase 2.3 and only when their result files are missing or invalid.
Task tool:
subagent_type: general-purpose
max_turns: 20
prompt: |
Research best practices, frameworks, and prior art relevant to this task.
## Web Research Protocol
Read the "Web Research Protocol" section of
{CWF_PLUGIN_DIR}/references/agent-patterns.md and follow it exactly.
Key points: discover URLs via WebSearch first (never guess URLs),
use WebFetch then fall back to agent-browser for JS-rendered pages,
skip failed domains, budget turns for writing output.
You have Bash access for agent-browser CLI commands.
Find:
- Established methodologies or patterns for this type of work
- Common pitfalls and how others avoided them
- Relevant tools, libraries, or approaches
Cite real sources with URLs. Report findings — do not make decisions.
Task:
{task description from Phase 1}
Key decisions:
{decisions from Phase 1}
Baseline evidence summary from gather/clarify:
{summary from Phase 2.1}
Unresolved evidence gaps to investigate:
{gap list for prior-art lane from Phase 2.3}
## Output Persistence
Write your complete findings to: {session_dir}/plan-prior-art-research.md
At the very end of the file, append this sentinel marker on its own line:
<!-- AGENT_COMPLETE -->
Task tool:
subagent_type: Explore
max_turns: 20
prompt: |
Analyze the codebase for patterns, dependencies, and constraints relevant
to this task. For each finding:
- Cite file paths and line numbers
- Assess impact on the plan (High/Medium/Low)
- Note existing patterns that should be followed
Report evidence only — do not make decisions.
Task:
{task description from Phase 1}
Key decisions:
{decisions from Phase 1}
Baseline evidence summary from gather/clarify:
{summary from Phase 2.1}
Unresolved evidence gaps to investigate:
{gap list for codebase lane from Phase 2.3}
## Output Persistence
Write your complete findings to: {session_dir}/plan-codebase-analysis.md
At the very end of the file, append this sentinel marker on its own line:
<!-- AGENT_COMPLETE -->
Wait for all launched sub-agents to complete. Re-validate each launched file using the context recovery protocol.
After sub-agents complete, read the result files from the session directory (not in-memory return values):
{session_dir}/plan-prior-art-research.md — Prior art research findings{session_dir}/plan-codebase-analysis.md — Codebase analysis findingsUse these file contents as additional input for Phase 3 synthesis.
Apply the stage-tier policy from the context recovery protocol when Phase 2.4 launched any gap-fill sub-agent:
plan-prior-art-research.md and plan-codebase-analysis.md are critical.PERSISTENCE_GATE=HARD_FAIL or equivalent).If no gap-fill sub-agent was launched, record PERSISTENCE_GATE=SKIP_NO_GAP and proceed.
Synthesize baseline evidence (from gather/clarify artifacts) and any additional gap-fill research into a structured plan. Read {SKILL_DIR}/../../references/plan-protocol.md for protocol rules on location, sections, and format.
Before finalizing Steps, scan for cross-cutting patterns:
Prohibited instructions in step descriptions:
Each step must either reference a shared file or contain self-contained instructions. Parallel agents cannot see each other's work, so sharing must be decided at plan level.
Before finalizing Steps, assess whether preparatory refactoring is needed:
Use plan-protocol.md as the single source of truth for:
lessons.md format and language policyKeep only these skill-specific additions in the generated plan:
Add a required ## Commit Strategy section:
Keep Success Criteria in the two-layer format:
Expand ## Decision Log to include evidence/source and resolution metadata:
| # | Decision Point | Evidence / Source (artifact or URL + confidence) | Alternatives Considered | Resolution | Status | Resolved By | Resolved At (UTC) |
|---|---|---|---|---|---|---|---|
| 1 | ... | ... | ... | ... | open/resolved | ... | ... |
Status=open: leave Resolution, Resolved By, and Resolved At as TBD.Status=resolved: cite concrete evidence (e.g., plan-codebase-analysis.md, plan-prior-art-research.md, URL).Determine the session directory following plan-protocol.md location rules:
{CWF_PLUGIN_DIR}/scripts/next-prompt-dir.sh --bootstrap <title> and use its output path.
--bootstrap creates the resolved directory, initializes missing plan.md/lessons.md, and pre-registers the session in cwf-state.yaml sessions when state exists.Write two files:
Write the complete plan from Phase 3, following plan-protocol.md and the skill-specific additions above (Commit Strategy, expanded Decision Log).
Initialize lessons.md using the shared format in plan-protocol.md (user language). If no learnings exist yet, create the file with a header and a short placeholder note.
Before finishing this skill, append plan-stage learnings captured during user ping-pong (for example: clarified constraints, corrected assumptions, revealed preferences). Do not defer these to implementation.
After writing plan artifacts, suggest review:
Plan drafted at .cwf/projects/{dir}/plan.md.
For a multi-perspective review before implementation, run:
cwf:review --mode plan
plan-prior-art-research.md or plan-codebase-analysis.md remains invalid after bounded retry, stop with explicit error instead of drafting from partial dataplan.md is in English; lessons.md is in the user's languagelessons.md during planning, not only after implementation