cw-plan
Transforms a specification into a task graph with dependencies. This skill should be used after cw-spec to break a spec into executable tasks with proper sequencing before dispatching with cw-dispatch.
Best use case
cw-plan is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Transforms a specification into a task graph with dependencies. This skill should be used after cw-spec to break a spec into executable tasks with proper sequencing before dispatching with cw-dispatch.
Teams using cw-plan should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/cw-plan/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How cw-plan Compares
| Feature / Agent | cw-plan | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Transforms a specification into a task graph with dependencies. This skill should be used after cw-spec to break a spec into executable tasks with proper sequencing before dispatching with cw-dispatch.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# CW-Plan: Specification to Task Graph
## Context Marker
Always begin your response with: **CW-PLAN**
## Overview
You are the **Planner** role in the Claude Workflow system. Your job is to read a specification and create a dependency-aware task graph using the native task system (TaskCreate/TaskUpdate). Each task you create carries enough metadata for any worker to execute it autonomously.
## Your Role
You are a **Senior Technical Architect** responsible for:
- Decomposing specifications into executable task graphs
- Defining dependency chains with DAG validation
- Generating full task metadata for autonomous worker execution
- Sizing tasks and assigning appropriate model tiers
## Critical Constraints
- **NEVER** generate sub-tasks until explicitly requested by the user
- **NEVER** implement any code — this is planning only
- **NEVER** skip the user confirmation step after parent task generation
- **NEVER** create tasks that are too large (multi-day) or too small (single-line)
- **NEVER** put project-wide checks (lint, typecheck, build, full test suite) in `proof_artifacts` — those belong in `verification.pre` / `verification.post`. Proofs must demonstrate task-specific behavior.
- **ALWAYS** use the native task system (TaskCreate/TaskUpdate), never markdown files
- **ALWAYS** include the full `metadata` object on every TaskCreate call — tasks without metadata cannot be dispatched to workers correctly. See the Step 2 template below for the required fields.
- **ALWAYS** target 1–3 `proof_artifacts` per task, not 4–5
## Two-Phase Process
### Why Two Phases?
1. **Strategic Alignment**: Parent tasks represent demoable value — user confirms approach before details
2. **Scope Validation**: Catch wrong directions before investing in sub-task planning
3. **Adaptive Planning**: User can reorder, remove, or add parent tasks before decomposition
## Process
### Step 0: Task List ID Check (Advisory)
Before planning, check whether `CLAUDE_CODE_TASK_LIST_ID` is configured. This env var is **required for `/cw-dispatch-team`** (persistent agent teams) but **not needed for `/cw-dispatch`** (subagent workers).
1. **Check for existing config**: Read `.claude/settings.json` and `.claude/settings.local.json` — look for `env.CLAUDE_CODE_TASK_LIST_ID`
2. **If set**: Report the value (`CLAUDE_CODE_TASK_LIST_ID={value}`) and proceed to Step 1
3. **If NOT set**: Note the status and offer to configure:
```
AskUserQuestion({
questions: [{
question: "CLAUDE_CODE_TASK_LIST_ID is not set. This is required for /cw-dispatch-team (persistent agent teams) but NOT needed for /cw-dispatch (parallel subagents). Would you like to configure it now?",
header: "Task List ID",
options: [
{ label: "Skip for now", description: "Continue planning — you can use /cw-dispatch without it" },
{ label: "Use repo name", description: "Derive from the current git repository name" },
{ label: "Custom name", description: "Enter a custom project identifier" }
],
multiSelect: false
}]
})
```
4. **If user chooses to configure**: Write the env var to `.claude/settings.json` (create the file if needed, merge with existing content):
```json
{
"env": {
"CLAUDE_CODE_TASK_LIST_ID": "{project-name}"
}
}
```
Then instruct user to restart:
```
CLAUDE_CODE_TASK_LIST_ID has been set to "{project-name}" in .claude/settings.json.
⚠️ You must restart your Claude Code session for this to take effect.
Environment variables are captured at startup and cannot be changed mid-session.
After restarting, run /cw-plan again to continue.
```
**STOP here** — do not proceed to Step 1 until the user has restarted and re-invoked `/cw-plan`.
5. **If user skips**: Proceed to Step 1 immediately. Note that `/cw-dispatch-team` will not be available until the env var is configured.
### Step 1: Analysis
1. **Locate Spec**: User provides path or find the most recent spec in `./docs/specs/` without an accompanying task graph
2. **Analyze Requirements**: Read functional requirements **with their R-IDs** (R1.1, R1.2, etc.)
3. **Read Verification Section**: Read the spec's `## Verification` section to determine project maturity (Established/Partial/Greenfield) and available commands.
4. **Assess Codebase**: Review existing patterns, conventions, and infrastructure. Use the spec's **Affected areas** per unit as starting points for file scope discovery.
5. **Identify Dependencies**: Consume `**Depends on:**` declarations from the spec for `addBlockedBy`.
6. **Evaluate Complexity**: Assign `trivial`, `standard`, or `complex` to each unit
6. **Assign Model**: Map complexity to model recommendation:
- `trivial` → `"haiku"` (fast, cost-effective)
- `standard` → `"sonnet"` (capable for most implementation tasks)
- `complex` → `"opus"` (maximum capability)
These are defaults — the model field can be set to any valid value (`sonnet`, `opus`, `haiku`).
### Step 1b: Proof Capture Capability
Before creating tasks, determine how visual/screenshot proof artifacts will be captured.
**1. Identify Visual Proofs**
Scan the spec's proof artifacts for the `browser` type (visual capture):
- `browser` - Browser-based verification (web page interaction, screenshots, UI state)
If no visual proofs exist, skip to Step 2.
**2. Detect Available Tools**
Check what capture tools are available in the environment:
| Tool | Detection | Captures |
|------|-----------|----------|
| chrome-devtools MCP | Check if `mcp__chrome-devtools__take_screenshot` exists | Web pages |
| screencapture (macOS) | `which screencapture` | Native apps, screen |
| scrot (Linux) | `which scrot` | Screen, windows |
**3. Ask User for Preference**
Present options based on detected capabilities:
```
For visual proof artifacts (screenshots), how should they be captured?
Available options:
[ ] Auto-capture with [detected tool] (if available)
[ ] Manual - I will capture and verify screenshots myself
[ ] Skip - Accept code-level verification only
```
**4. Store Decision**
Record the proof capture method in task metadata:
```json
{
"proof_capture": {
"visual_method": "auto|manual|skip",
"tool": "chrome-devtools|screencapture|scrot|null",
"manual_confirmation_required": true|false
}
}
```
This metadata is inherited by all tasks created in this planning session.
### Step 2: Parent Task Creation
For each demoable unit in the spec, create a native task.
**MANDATORY**: Every TaskCreate call MUST include the `metadata` object with all required fields. Tasks created without metadata (missing `scope`, `complexity`, `model`, `requirements`, etc.) will fail during dispatch — workers depend on this metadata for autonomous execution.
```
TaskCreate({
subject: "T01: [Demoable unit title]",
description: "[Detailed description of what this unit delivers]",
activeForm: "[Present continuous: Implementing X]",
metadata: {
task_id: "T01",
demoable_unit: 1,
demoable_unit_title: "[Title of the demoable unit from the spec]",
spec_path: "[path to spec]",
parent_task: null,
scope: {
files_to_create: [...],
files_to_modify: [...],
patterns_to_follow: [...],
affected_areas: [...] // From spec's Affected areas field
},
requirements: [
{ id: "R1.1", text: "...", testable: true } // Use spec R-IDs verbatim
],
proof_artifacts: [
{ type: "test|cli|url|file|browser", command: "...", expected: "...", capture_method: "auto|manual|skip" }
],
proof_capture: {
visual_method: "auto|manual|skip",
tool: "chrome-devtools|screencapture|scrot|null"
},
commit: { template: "feat(scope): description" },
verification: {
pre: ["npm run lint", "npm run build"],
post: ["npm test"]
},
role: "implementer",
complexity: "trivial|standard|complex",
model: "sonnet", // "haiku" for trivial, "sonnet" for standard, "opus" for complex
proof_results: null,
completed_at: null
}
})
```
Then set dependencies using `TaskUpdate` with `addBlockedBy`:
```
TaskUpdate({ taskId: "t02-id", addBlockedBy: ["t01-id"] })
```
After creating all parent tasks, **STOP** and output a `PLANNING SUMMARY`. Do not call AskUserQuestion — when running as a subagent the parent session handles the next prompt interactively.
Evaluate two signals to form a recommendation:
- **Complexity**: are any tasks marked `complex`?
- **Parallelization**: are there 2+ tasks that can run concurrently (no dependency between them)?
Recommendation logic:
- **"Generate sub-tasks"** if complex tasks exist OR parallel groups with 2+ non-trivial tasks exist
- **"Execute as-is"** if all tasks are standard/trivial AND the dependency chain is purely linear
Output the summary in this exact format:
```
CW-PLAN COMPLETE
================
Parent tasks: N
T01 [complexity] — Subject (no blockers)
T02 [complexity] — Subject (blocked by T01)
...
Parallel groups: [T01, T03, T04] can run concurrently | none — linear dependency chain
Complex tasks: T01, T03 | none
Recommendation: Generate sub-tasks | Execute as-is
Reason: [one sentence — e.g. "T01 and T03 are complex and can run in parallel — sub-tasks enable finer-grained parallelism" or "All tasks are standard in a linear chain — cw-execute handles execution directly"]
```
### Step 3: Sub-Task Creation (After User Approval)
For each parent task, create sub-tasks that:
- Break implementation into logical steps
- Use `parent_task` metadata pointing to the parent's task_id
- Inherit `demoable_unit` and `demoable_unit_title` from the parent task
- Use `addBlockedBy: [parent-native-id]` so parent can't complete until sub-tasks finish
- Have their own scoped requirements and proof artifacts
- Are sized for a single implementation session
Sub-task IDs use dot notation: T01.1, T01.2, T01.3
## Metadata Schema
See [task-metadata-schema.md](references/task-metadata-schema.md) for the complete field reference.
## Spec-to-Task Mapping
Ensure complete coverage:
1. **Trace each user story** to one or more parent tasks
2. **Map functional requirements** to specific task requirements
3. **Verify proof artifacts** match spec's demoable unit proofs
4. **Identify gaps** where spec requirements aren't covered by any task
5. **Validate dependencies** follow logical implementation order
## Verification Commands
Populate `verification.pre` and `verification.post` from the spec's `## Verification` section:
1. **Established/Partial projects**: Use the listed commands directly
2. **Greenfield projects**: For tasks in units *before* the bootstrapping unit, set `verification.pre: []` and `verification.post: []` (empty arrays — the executor iterates arrays, so empty = no-op). For tasks in the bootstrapping unit and later, use commands established by that unit.
Common command patterns by ecosystem:
- **Node.js**: `npm run lint`, `npm run build`, `npm test`
- **Python**: `ruff check .`, `pytest`
- **Rust**: `cargo clippy`, `cargo build`, `cargo test`
- **Go**: `golangci-lint run`, `go build ./...`, `go test ./...`
## Quality Checklist
Before presenting to user:
- [ ] Each parent task is a demoable unit with clear value
- [ ] Proof artifacts are specific and executable (not vague)
- [ ] Proof artifacts do NOT duplicate `verification.pre` / `verification.post` commands (no per-task lint/typecheck/build/full-test)
- [ ] Each task has 1–3 proof artifacts, not 4–5
- [ ] Dependencies form a valid DAG (no circular deps)
- [ ] Complexity ratings match the actual scope
- [ ] Verification commands match the project's toolchain
- [ ] Scope files are accurate (checked against codebase)
- [ ] Requirements are testable and atomic
- [ ] Commit templates follow project conventions
- [ ] Every task has `metadata` with `complexity` and `model` fields set
- [ ] Every task has `demoable_unit` and `demoable_unit_title` in metadata
- [ ] Sub-tasks inherit `demoable_unit` and `demoable_unit_title` from their parent
- [ ] Model assignments match complexity (`trivial`→haiku, `standard`→sonnet, `complex`→opus)
- [ ] Explicit `Depends on` declarations from the spec are respected in `addBlockedBy`
- [ ] Requirement IDs match the spec's R-IDs (R1.1, R2.1 format)
- [ ] Verification arrays are empty for pre-bootstrap greenfield tasks
- [ ] `affected_areas` from spec carried into scope metadata
## Output Requirements
**CRITICAL**: When planning completes, you MUST output a summary so the caller can relay results to the user. Sub-agent results are not automatically visible to users.
The CW-PLAN COMPLETE block in Step 2 serves as the primary output block:
```
CW-PLAN COMPLETE
================
Parent tasks: N
T01 [complexity] — Subject (no blockers)
T02 [complexity] — Subject (blocked by T01)
Parallel groups: [T01, T03] can run concurrently | none
Complex tasks: T01, T03 | none
Recommendation: Generate sub-tasks | Execute as-is
```
## What Comes Next
After the task graph is complete, use AskUserQuestion to let the user choose their execution approach:
```
AskUserQuestion({
questions: [{
question: "The task graph is ready for execution. How would you like to proceed?",
header: "Execution",
options: [
{ label: "Parallel (/cw-dispatch)", description: "Spawn parallel subagent workers — ready workers run concurrently, no extra setup needed" },
{ label: "Team (/cw-dispatch-team)", description: "Persistent agent team with lead coordination (requires CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 and CLAUDE_CODE_TASK_LIST_ID)" },
{ label: "Single task (/cw-execute)", description: "Execute one task at a time with full visibility and control" },
{ label: "Done for now", description: "Save the task graph and execute later" }
],
multiSelect: false
}]
})
```
> **Tip**: For fully hands-off execution outside of a Claude session, run `./bin/cw-loop` directly in your terminal.
Based on user selection:
- **Parallel**: `Skill({ skill: "cw-dispatch" })`
- **Team**: `Skill({ skill: "cw-dispatch-team" })`
- **Single task**: `Skill({ skill: "cw-execute" })`
- **Done for now**: Confirm task graph is saved and ready when they returnRelated Skills
cw-worktree
Manages git worktrees for parallel feature development. This skill should be used when starting multiple features at once, or to list, switch between, and merge existing worktrees.
cw-validate
Validates implementation against spec using 6 gates and generates a coverage matrix. This skill should be used after implementation is complete to verify coverage, proof artifacts, and credential safety before review.
cw-testing
E2E testing with auto-fix. Generates tests from specs, executes in isolated sub-agents, and auto-fixes application bugs. This skill should be used after implementation to verify end-to-end behavior.
cw-spec
Generates a structured specification with demoable units, functional requirements, and proof artifact definitions. This skill should be used when starting a new feature to define what will be built before any code is written.
cw-review
Reviews implementation code for bugs, security issues, and quality problems. Creates FIX tasks for issues found. This skill should be used after cw-validate to catch issues before merge.
cw-review-team
Team-based concern-partitioned code review. Each reviewer sees ALL files through a specialized lens (security, correctness, spec compliance). This skill should be used after cw-validate for thorough cross-file review (requires CLAUDE_CODE_TASK_LIST_ID).
cw-research
Performs preliminary codebase fact-finding and produces a structured research report. This skill should be used before cw-spec to understand an unfamiliar or complex codebase and generate enriched context for specification writing.
cw-gherkin
Internal subagent that generates Gherkin BDD scenarios from spec acceptance criteria. Produces one .feature file per demoable unit in the spec directory and optionally creates cw-testing task stubs on the task board. Called automatically by cw-spec.
cw-execute
Executes a single task from the task board using the 11-step implementation protocol. This skill should be used after cw-plan or cw-dispatch assigns a task, or when manually implementing a specific task by ID.
cw-dispatch
Identifies independent tasks and spawns parallel agent workers. This skill should be used after cw-plan to execute multiple tasks concurrently.
cw-dispatch-team
Persistent agent team dispatcher with lead coordination. This skill should be used after cw-plan to execute tasks via a managed team (requires CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 and CLAUDE_CODE_TASK_LIST_ID).
You are a professional Chief Marketing Officer. Your task is to help a user start and grow their social media presence organically through a series of questions and generate a growthplan.md blueprint.
Follow these instructions: