.codex/skills/plan/SKILL.md
Design intent → research → branch + worktree + task list
npx skillsauth add harshanandak/forge .codex/skills/planInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Plan a feature from scratch: brainstorm design intent, research technical approach, then set up branch, worktree, and a complete task list ready for /dev.
This command runs in 3 phases. Each phase ends with a HARD-GATE. Do not skip phases.
<HARD-GATE: /plan entry — worktree isolation>
Before ANY planning work begins:
1. Run: git branch --show-current
2. If the current branch is NOT master/main:
- STOP. Do not begin Phase 1.
- Tell the user: "You are on '<branch>'. Planning must start from a clean worktree on master.
Run: git checkout master — then re-run /plan."
3. If on master, create the worktree NOW before asking any questions:
a. bd worktree create .worktrees/<slug> --branch feat/<slug>
b. cd .worktrees/<slug>
4. Confirm: "Working in isolated worktree: .worktrees/<slug> (branch: feat/<slug>)"
5. Create the epic issue and record the stage transition:
```bash
bd create --title="<feature-name>" --type=epic
bd update <id> --status=in_progress
bash scripts/beads-context.sh stage-transition <id> none plan
Rationale: Planning commits (design docs, task lists) belong only to this feature's branch. If planning runs in the main directory on a non-master branch, those commits contaminate whatever branch is currently checked out. The worktree ensures zero cross-contamination between parallel features or sessions. </HARD-GATE>
---
## Usage
```bash
/plan <feature-slug>
/plan <feature-slug> --strategic # Major architecture change: creates design doc PR before Phase 2
/plan <feature-slug> --continue # After --strategic PR is merged: run Phase 2 + 3
Before proceeding to Phase 1, check for cross-developer conflicts:
# Auto-sync to get latest team state
forge sync || true
# Check for conflicts with this issue's planned work area
bash scripts/conflict-detect.sh --issue <beads-id>
If exit code 2 (validation error): show error message, abort — do not show conflict prompt.
If exit code 1 (conflicts found):
n: exit cleanly, no side effectsy: log override via bd comments add <id> "Conflict override: proceeding despite overlap with <conflicting-issues>", then continue to Phase 1If exit code 0: proceed silently to Phase 1.
Before proceeding to Phase 1, check for merge conflicts and dependency issues with in-flight PRs:
# Run merge simulation if on a feature branch
current_branch="$(git branch --show-current)"
if [[ "$current_branch" != "master" ]] && [[ "$current_branch" != "main" ]]; then
bash scripts/pr-coordinator.sh merge-sim "$current_branch" 2>&1 || true
fi
# Show current merge queue
bash scripts/pr-coordinator.sh merge-order 2>&1 || true
# Check for stale worktrees (informational)
bash scripts/pr-coordinator.sh stale-worktrees 2>&1 || true
If merge conflicts or unmet dependencies are found:
n: exit cleanly, no side effectsy: log override via bd comments add <id> "PR coordination override: proceeding despite in-flight conflicts", then continue to Phase 1Before starting planning, verify team identity is mapped:
forge team verify 2>&1 || true
If verify reports issues, address them before proceeding (the output will include FORGE_AGENT_7f3a:PROMPT: directives with exact commands to run).
Goal: Capture WHAT to build — purpose, constraints, success criteria, edge cases, approach.
Before exploring context or asking questions, check for potential conflicts with in-flight work:
# If a Beads issue ID is known (e.g., from /status or bd ready):
bash scripts/dep-guard.sh check-ripple <beads-issue-id>
# If no issue exists yet (first-time plan):
bd list --status=open,in_progress
Review the output. If overlaps are detected:
When check-ripple detects overlapping issues AND contract metadata is available, spawn a Ripple Analyst subagent with this prompt:
Input to agent:
extract-contracts output)find-consumers output for each changed contract)Agent instructions:
bd dep add <source> <target>)Output format:
Impact: [NONE|LOW|HIGH|CRITICAL]
Confidence: [high|medium|low]
Break scenarios:
1. [scenario description]
2. [scenario description]
Recommendation: [action]
Reason: [why this action]
This agent is advisory only. The developer always makes the final decision.
Before asking any questions, read relevant files:
Ask each question in sequence. Wait for user response. Use multiple choice where possible.
Questions to cover (adapt to feature, don't ask mechanical copies):
Propose 2-3 concrete approaches with:
Save to docs/plans/YYYY-MM-DD-<slug>-design.md with these sections:
Commit the design doc:
git add docs/plans/YYYY-MM-DD-<slug>-design.md
git commit -m "docs: add design doc for <slug>"
--strategic flag (for major architecture changes):
After committing the design doc, push to a proposal branch and open PR:
git checkout -b feat/<slug>-proposal
git push -u origin feat/<slug>-proposal
gh pr create --title "Design: <feature-name>" \
--body "Design doc for review. See docs/plans/YYYY-MM-DD-<slug>-design.md"
STOP here. Present the PR URL. Wait for the user to merge the proposal PR.
After merge, run /plan <slug> --continue to proceed to Phase 2 + 3.
<HARD-GATE: Phase 1 exit>
Do NOT begin Phase 2 (web research) until:
1. User has approved the design in this session
2. Design doc exists at docs/plans/YYYY-MM-DD-<slug>-design.md
3. Design doc includes: success criteria, edge cases, out-of-scope, ambiguity policy
4. Design doc is committed to git
</HARD-GATE>
Goal: Find HOW to build it — best practices, known issues, security risks, TDD scenarios.
Record the phase transition before starting research:
bash scripts/beads-context.sh stage-transition <id> plan research
Run these in parallel:
Skill("parallel-deep-research")
Search for:
For this feature's risk surface, document each relevant OWASP category:
Before finalizing the approach, run Grep/Glob/Read searches for existing implementations of the planned function or pattern. Do not rely on memory or assumptions — execute the searches.
Grep(searchTerm) # e.g., the function or concept name
Glob("**/*.js") # narrow to affected file types if needed
Read(matchedFile) # inspect any match in context
If a match is found:
If no match is found: proceed. The DRY gate is cleared.
If this feature involves removing, renaming, or replacing a concept, tool, or dependency:
Grep the ENTIRE codebase for the thing being removed/renamed:
Grep("<thing-being-removed>") # exact name
Grep("<thing-being-removed>", -i) # case-insensitive variant
Glob("**/*<thing>*") # files named after it
For EVERY match found:
Common hiding spots to check:
package.json (scripts, dependencies, description)install.sh / setup scripts.github/workflows/)lib/agents/, .cursorrules, etc.)docs/, README.md, AGENTS.md)If no removal/rename is involved, this section is skipped.
Identify at minimum 3 test scenarios:
Append all research findings to the design doc under a ## Technical Research section (not a separate file).
<HARD-GATE: Phase 2 exit>
Do NOT begin Phase 3 (setup) until:
1. OWASP analysis is documented in design doc
2. At least 3 TDD test scenarios are identified
3. Approach selection is confirmed (which library/pattern to use)
4. If feature involves removal/rename: blast-radius search completed, all references added to task list
</HARD-GATE>
Goal: Create branch, worktree, and a complete task list ready for /dev.
Record the phase transition before starting setup:
bash scripts/beads-context.sh stage-transition <id> research setup
The epic was created in the Entry HARD-GATE (Phase 1 entry). If this feature requires child issues (sub-tasks tracked separately), create them now and link to the epic:
bd create --title="<sub-task-name>" --type=feature --parent=<epic-id>
ALWAYS branch from master, never from the current branch. If the working directory is on any branch other than master, the new feature branch would inherit all unmerged changes from that branch — contaminating the new feature's history.
Note: If the Entry HARD-GATE already created the branch and worktree (and you are already inside .worktrees/<slug>), skip Steps 2b–2d — they are already done.
# Step 2a: Check if branch and worktree were already created by Entry HARD-GATE
CURRENT=$(git branch --show-current)
if [ "$CURRENT" = "feat/<slug>" ]; then
echo "✓ Branch feat/<slug> already exists (Entry HARD-GATE created it) — skipping 2b–2d"
else
# Step 2b: Verify .worktrees/ is gitignored — add if missing
git check-ignore -v .worktrees/ || echo ".worktrees/" >> .gitignore
# Step 2c: Create a Beads-aware worktree rooted on master
git checkout master
bd worktree create .worktrees/<slug> --branch feat/<slug>
cd .worktrees/<slug>
fi
Why this matters: Multiple parallel features or sessions each get their own isolated worktree. Changes to one feature never bleed into another. The main working directory can stay on any branch without affecting new feature branches.
Auto-detect and run install:
# e.g., bun install / npm install / pip install -r requirements.txt
# Run full test suite in worktree
bun test # or project test command
If tests fail: report which tests are failing and ask user whether to investigate or proceed anyway. Do not silently proceed past failing baseline tests.
Read the design doc. Break implementation into granular tasks.
Task format (each task MUST have ALL of these):
Task N: <descriptive title>
File(s): <exact file paths>
What to implement: <complete description — not "add feature X", but what specifically>
TDD steps:
1. Write test: <test file path, what assertion, what input/output>
2. Run test: confirm it fails with [specific expected error message]
3. Implement: <exact function/class/component to write>
4. Run test: confirm it passes
5. Commit: `<type>: <message>`
Expected output: <what running the test/code produces when done>
Ordering rules:
OWNS: line listing files it will modifyYAGNI filter (after initial task draft, before saving):
For each task, confirm it maps to a specific requirement, success criterion, or edge case in the design doc. Run applyYAGNIFilter({ task, designDoc }) for each task.
allFlagged: true and tell the user: "Design doc doesn't cover all tasks — needs amendment." Do not save the task list until the design doc is updated or tasks are removed.Before finalizing: flag any tasks that touch areas not fully specified in the design doc. Present flagged tasks to user for quick clarification before saving.
Save to docs/plans/YYYY-MM-DD-<slug>-tasks.md.
After saving the task list, attach design context and acceptance criteria to the Beads issue so downstream stages (/dev, /validate, /review) can retrieve it without re-reading the design doc.
# Link design metadata (task count + task file path) to the Beads issue
bash scripts/beads-context.sh set-design <id> <task-count> docs/plans/YYYY-MM-DD-<slug>-tasks.md
# Record the success criteria from the design doc on the issue
bash scripts/beads-context.sh set-acceptance <id> "<success-criteria from design doc>"
Both commands must exit with code 0. If either fails, investigate (wrong issue ID? missing script?) before continuing.
After saving the task list and Beads context, extract and store contract metadata, then run the logic-level Phase 3 dependency review:
# Extract contracts — only call store-contracts if extract succeeds (exit 0)
if bash scripts/dep-guard.sh extract-contracts docs/plans/YYYY-MM-DD-<slug>-tasks.md > /tmp/contracts.txt; then
bash scripts/dep-guard.sh store-contracts <id> "$(cat /tmp/contracts.txt)"
else
echo "No contracts found — skipping store-contracts"
fi
# Re-run ripple check using Beads JSON + logic-level analysis
bash scripts/dep-guard.sh check-ripple <id>
extract-contracts exits 1 when no contracts are found (not an error — just nothing to store). store-contracts must exit 0 if called.
check-ripple is now advisory but logic-aware. It should:
If the user approves a dependency mutation, apply it explicitly:
bash scripts/dep-guard.sh apply-decision <id> <dependent-id> <depends-on-id> "<approval rationale>"
That approval step must validate with bd dep cycles, show bd graph, summarize bd ready, and persist the decision via bd set-state plus bd comments. Beads remains the canonical machine-readable decision record; the plan docs hold only the concise summary.
Present the full task list. Allow the user to reorder, split, or remove tasks.
<HARD-GATE: /plan exit>
Do NOT proceed to /dev until ALL are confirmed:
1. git branch --show-current output shows feat/<slug>
2. git worktree list shows .worktrees/<slug>
3. Baseline tests ran — either passing OR user confirmed to proceed past failures
4. Beads issue is created with status=in_progress
5. Task list exists at docs/plans/YYYY-MM-DD-<slug>-tasks.md
6. User has confirmed task list is correct
7. `beads-context.sh set-design` ran successfully (exit code 0)
8. `beads-context.sh set-acceptance` ran successfully (exit code 0)
9. `dep-guard.sh store-contracts` ran successfully (exit code 0) — or skipped if no contracts found
10. `dep-guard.sh check-ripple` ran successfully and any proposed dependency mutation was reviewed with the user before calling `apply-decision`
</HARD-GATE>
After all HARD-GATE items pass, validate context and record the stage transition:
bash scripts/beads-context.sh validate <id>
bash scripts/beads-context.sh stage-transition <id> plan dev \
--summary "<design approach chosen, task count>" \
--decisions "<key trade-offs resolved during Q&A>" \
--artifacts "docs/plans/YYYY-MM-DD-<slug>-design.md docs/plans/YYYY-MM-DD-<slug>-tasks.md" \
--next "<first dev task focus area>"
✓ Phase 1: Design intent captured
- Design doc: docs/plans/<date>-<slug>-design.md
- Approach: <selected approach> (selected over <alternatives>)
- Ambiguity policy: Rubric scoring (>= 80% proceed, < 80% ask)
✓ Phase 2: Technical research complete
- OWASP Top 10: <N> risks identified, <N> mitigations planned
- TDD scenarios: <N> identified
- Sources: <N> references
✓ Phase 3: Setup complete
- Beads: <issue-id> (in_progress)
- Branch: feat/<slug>
- Worktree: .worktrees/<slug> (baseline: <N>/<N> tests passing)
- Task list: docs/plans/<date>-<slug>-tasks.md (<N> tasks)
⏸️ Task list ready for review. Confirm to proceed.
After confirming, run: /dev
Utility: /status → Understand current context before starting
Stage 1: /plan → Design intent → research → branch + worktree + task list (you are here)
Stage 2: /dev → Implement each task with subagent-driven TDD
Stage 3: /validate → Type check, lint, tests, security — all fresh output
Stage 4: /ship → Push + create PR
Stage 5: /review → Address GitHub Actions, Greptile, SonarCloud
Stage 6: /premerge → Update docs, hand off PR to user
Stage 7: /verify → Post-merge CI check on main
development
Pull issues, metrics, quality gates, and analysis data from SonarCloud. ALWAYS use this skill when the user mentions SonarCloud, asks about code quality metrics, wants to check PR quality gates, or needs to review security vulnerabilities and technical debt from static analysis. Also trigger during /review workflow when SonarCloud issues need addressing. Trigger on phrases like "SonarCloud", "quality gate", "code quality metrics", "technical debt", "coverage report", "static analysis issues", "security vulnerabilities from scan".
tools
Produces comprehensive research reports that go far beyond what built-in web search can achieve. Sends research tasks to Parallel AI's pro/ultra processors which spend 3-25 minutes autonomously crawling, reading, and synthesizing dozens of sources — returning structured reports with citations. Built-in WebSearch can only run a few queries; this skill runs an entire research pipeline externally. No binary install — requires PARALLEL_API_KEY in .env.local. ALWAYS use this skill instead of doing multiple WebSearch calls when the user needs a comprehensive report, market analysis, competitive landscape, industry deep-dive, strategic recommendations, or multi-source synthesis. This is the RIGHT tool for any research task that would require more than 3-4 web searches to answer properly. Also trigger during /plan Phase 2 research and /research workflows.
testing
Test content
testing
Test content