一键导入
prp-plan
Create a comprehensive implementation plan by analyzing the codebase, discovering patterns, and producing a step-by-step actionable plan document.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create a comprehensive implementation plan by analyzing the codebase, discovering patterns, and producing a step-by-step actionable plan document.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Multi-agent PR review — spawns parallel specialized agents for deep code review.
Multi-agent PR review — spawns parallel specialized agents for deep code review.
Execute an implementation plan with rigorous validation loops — typecheck, lint, test, and build after every change. TDD approach with automatic failure recovery.
Create a comprehensive implementation plan by analyzing the codebase, discovering patterns, and producing a step-by-step actionable plan document.
Execute an implementation plan with rigorous validation loops — typecheck, lint, test, and build after every change. TDD approach with automatic failure recovery.
Execute the complete PRP lifecycle end-to-end — issue context, smart plan, implement, commit, PR, review-fix loop (until 0 issues), merge, and cleanup. Supports --issue, --merge, --max-review-rounds, --fast, --ralph, --skip-plan, --skip-review, --no-pr, --resume, --no-interact, --dry-run, --fix-severity, --verify, --qa-delegate=<agent>, --done options.
| name | prp-plan |
| description | Create a comprehensive implementation plan by analyzing the codebase, discovering patterns, and producing a step-by-step actionable plan document. |
| metadata | {"short-description":"Create implementation plan"} |
If your input context contains [WORKSPACE CONTEXT] (injected by a multi-agents framework),
you are running as a sub-agent. Apply these optimizations:
toolchain JSON
block with runner/commands, use those directly instead of re-detecting.All other phases (codebase pattern extraction, research, plan generation) run unchanged — these are where quality comes from.
Feature description or path to PRD file: $ARGUMENTS
Format: <feature description | path/to/prd.md> [--fast] [--no-interact]
Transform the input into a battle-tested implementation plan through systematic codebase exploration, pattern extraction, and strategic research.
Run these to understand project structure:
ls -la
ls -la */ 2>/dev/null | head -50
src/ — alternatives: app/, lib/, packages/, cmd/, internal/, pkg/Parse flags first (remove from input before type detection):
| Flag | Effect |
|---|---|
--fast | Fast-track mode (lighter analysis) |
--no-interact | Never ask questions — use best judgment |
--package <name> | Scope to a specific monorepo package (e.g., --package api). Sets MONOREPO_PACKAGE. |
| Input Pattern | Type | Action |
|---|---|---|
Ends with .prd.md | PRD file | Parse PRD, select next phase |
Ends with .md + "Implementation Phases" | PRD file | Parse PRD, select next phase |
| File path that exists | Document | Read and extract feature description |
| Free-form text | Description | Use directly as feature input |
| Empty/blank | Conversation | Use conversation context as input |
{path}. Verify the path and try again."Status: pending. If the PRD has no "Implementation Phases" table (no table with Status/Phase columns), STOP: "PRD file has no Implementation Phases table. Add a phases table with Status column, or use free-form text input instead."completePHASE: {phase number and name}
GOAL: {from phase details}
SCOPE: {from phase details}
SUCCESS SIGNAL: {from phase details}
PRD CONTEXT: {problem statement, user, hypothesis from PRD}
PRD: {prd file path}
Selected Phase: #{number} - {name}
{If parallel phases available:}
Note: Phase {X} can also run in parallel (in separate worktree).
Proceeding with Phase #{number}...
Proceed directly to Phase 1 with the input as feature description.
GATE: If requirements are AMBIGUOUS:
--no-interact: Do NOT ask. Use best judgment, state assumptions in "## Assumptions" section.PHASE_0_CHECKPOINT:
| File Found | Package Manager | Runner |
|---|---|---|
bun.lockb | bun | bun / bun run |
pnpm-lock.yaml | pnpm | pnpm / pnpm run |
yarn.lock | yarn | yarn / yarn run |
package-lock.json | npm | npm run |
pyproject.toml | uv/pip | uv run / python |
Cargo.toml | cargo | cargo |
go.mod | go | go |
Priority: bun > pnpm > yarn > npm. Fallback: If no lock file → placeholder with WARNING.
Read package.json (or equivalent) for exact script names:
| Category | Common Names | Example Command |
|---|---|---|
| Type checking | type-check, typecheck, tsc | bun run type-check |
| Linting | lint, lint:fix | bun run lint |
| Testing | test, test:unit, test:integration | bun test |
| Building | build, compile | bun run build |
Runner: {detected runner}
Type Check: {runner} run {script-name}
Lint: {runner} run {script-name}
Test: {runner} {test-command}
Build: {runner} run {script-name}
Check for monorepo configuration files at project root:
| File Found | Monorepo Type |
|---|---|
pnpm-workspace.yaml | pnpm workspaces |
turbo.json | Turborepo |
nx.json | Nx |
lerna.json | Lerna |
root package.json with "workspaces" field | yarn/npm workspaces |
If --package flag provided but NO monorepo config detected:
WARNING:
--package {name}specified but no monorepo configuration found (no pnpm-workspace.yaml, turbo.json, nx.json, lerna.json, or workspaces field in package.json). Ignoring--packageflag — proceeding as single-package project.
If monorepo detected:
Discover workspace directories — read the actual workspace config:
# pnpm: read pnpm-workspace.yaml → packages: glob patterns
cat pnpm-workspace.yaml
# yarn/npm: read package.json → "workspaces" field
cat package.json | jq '.workspaces'
# Nx: read workspace.json or project.json files
# Turbo: read turbo.json → relies on package.json workspaces
# Fallback: scan common directories
ls -d packages/*/ apps/*/ libs/*/ services/*/ modules/*/ 2>/dev/null
List available packages from discovered workspace directories:
# Find all package.json files in workspace dirs
find {workspace-dirs} -maxdepth 2 -name "package.json" -exec dirname {} \;
Determine target package:
| Condition | Action |
|---|---|
--package <name> flag provided | Use that package. Set MONOREPO_PACKAGE = <name> |
| Feature description mentions a specific package | Auto-detect. Confirm with user (unless --no-interact) |
| Neither | Ask user to specify (unless --no-interact → scope to root/all) |
Resolve package path from discovered workspaces:
# Find the actual directory for the package name
PACKAGE_DIR=$(find {workspace-dirs} -maxdepth 2 -name "package.json" \
-exec grep -l "\"name\".*\"$MONOREPO_PACKAGE\"" {} \; | head -1 | xargs dirname)
Verify the directory exists. If not → STOP with error listing available packages.
Scope toolchain commands (override 0.5.3) — syntax varies by monorepo tool:
| Monorepo Type | Scoped Command Pattern | Example (package: api, script: lint) |
|---|---|---|
| pnpm workspaces | pnpm --filter {pkg} run {script} | pnpm --filter api run lint |
| Turborepo | turbo run {script} --filter={pkg} | turbo run lint --filter=api |
| Nx | nx run {pkg}:{script} | nx run api:lint |
| Lerna | lerna run {script} --scope={pkg} | lerna run lint --scope=api |
| yarn workspaces | yarn workspace {pkg} run {script} | yarn workspace api run lint |
| npm workspaces | npm run {script} -w {pkg} | npm run lint -w api |
Generate scoped commands for plan metadata:
Type Check: {scoped command for type-check}
Lint: {scoped command for lint}
Test: {scoped command for test}
Build: {scoped command for build}
Store monorepo metadata:
Monorepo: {type}
Package: {MONOREPO_PACKAGE}
Package Dir: {PACKAGE_DIR}
Monorepo Tool: {pnpm|turbo|nx|lerna|yarn|npm}
If no monorepo detected and no --package flag: Skip this section entirely. No impact on workflow.
PHASE_0_5_CHECKPOINT:
Extract from input:
Complexity Triggers (determines conditional sections):
| Flag | Condition | Effect |
|---|---|---|
NEEDS_INTEGRATION_TESTS | Complexity ≥ MEDIUM AND crosses service boundary | Include Integration Tests section |
NEEDS_PERF_BENCH | Involves DB queries, API endpoints, or data processing | Include Performance Benchmarks |
SECURITY_SENSITIVE | Handles user input, auth, data storage | Include security edge cases |
Formulate user story:
As a <user type>
I want to <action/goal>
So that <benefit/value>
--fast)When --fast flag provided:
Mode: fast-trackWarning (complexity mismatch): If complexity > LOW detected:
WARNING: Feature appears too complex for fast-track. Detected: {reason}.
Consider running without --fast for full planning.
Proceeding with fast-track anyway...
PHASE_1_CHECKPOINT:
If monorepo with MONOREPO_PACKAGE set: Focus exploration on {PACKAGE_DIR} first, then check shared packages (e.g., packages/shared/, packages/common/). Only explore other packages if cross-package integration is needed.
Before spawning Explore agents or reading files, gather structured codebase context via code-knowledge MCP tools (if available):
Check ck availability: Verify the target repo is indexed by running ck_query or checking ck repos via Bash.
Architecture overview: Call ck_onboard("{repo_name}")
Targeted search: Call ck_query("{repo_name}", "{feature keywords from Phase 1}")
Blast radius (if modifying existing code): Call ck_impact("{repo_name}", "{symbol_to_change}")
ck results reduce the Explore scope: Instead of reading 15-20 files, read only 3-5 files identified by ck. Pass ck results as pre-loaded context to any Explore agent spawned in step 2.1.
Thoroughly explore the codebase to discover (scope to ck-identified files when available):
Document discoveries in table format:
| Category | File:Lines | Pattern Description | Code Snippet |
|---|---|---|---|
| NAMING | src/features/X/service.ts:10-15 | camelCase functions | export function createThing() |
| ERRORS | src/features/X/errors.ts:5-20 | Custom error classes | class ThingNotFoundError |
| LOGGING | src/core/logging/index.ts:1-10 | getLogger pattern | const logger = getLogger("domain") |
| TESTS | src/features/X/tests/service.test.ts:1-30 | describe/it blocks | describe("service", () => { |
| TYPES | src/features/X/models.ts:1-20 | Drizzle inference | type Thing = typeof things.$inferSelect |
If fewer than 3 relevant patterns found, expand search:
Tag each source:
SOURCE: codebase (file:line) — primary, highest trustSOURCE: analogous (file:line) — similar concept, different domainSOURCE: external ({library} v{version} docs) — official documentationSOURCE: convention ({framework} standard) — framework conventionToken Budget: Max 20K tokens for exploration (typically 5-8K when ck pre-loads context). If hitting limit, document "Exploration incomplete."
PHASE_2_CHECKPOINT:
ONLY AFTER Phase 2 is complete. Solutions must fit existing codebase patterns first.
Search for:
Format references:
- [Library Docs v{version}](url#specific-section)
- KEY_INSIGHT: {what we learned}
- APPLIES_TO: {which task/file}
- GOTCHA: {pitfall and mitigation}
PHASE_3_CHECKPOINT:
Analyze:
Document:
APPROACH_CHOSEN: {description}
RATIONALE: {why this over alternatives — reference codebase patterns}
ALTERNATIVES_REJECTED:
- {Alt 1}: Rejected because {reason}
- {Alt 2}: Rejected because {reason}
NOT_BUILDING (explicit scope limits):
- {Item 1 — out of scope and why}
- {Item 2 — out of scope and why}
ls .prp-output/designs/{feature}-design-*.md 2>/dev/null
If found: incorporate API contracts, DB schema, NFRs. Design doc takes precedence over Explore findings.
Include if: Complexity HIGH, OR new API endpoints, DB schema changes, multi-service integration. Skip if: Complexity LOW, simple enhancement/bug fix.
PHASE_4_CHECKPOINT:
Architecture constraints from Phase 4 should inform UX design decisions.
Create Before/After ASCII diagrams showing:
Interaction Changes table:
| Location | Before | After | User_Action | Impact |
|---|---|---|---|---|
/route | State A | State B | Click X | Can now Y |
PHASE_5_CHECKPOINT:
TIMESTAMP=$(date +%Y%m%d-%H%M)
ls .prp-output/plans/{kebab-case-feature-name}*.plan.md 2>/dev/null
Path: .prp-output/plans/{kebab-case-feature-name}-{TIMESTAMP}.plan.md
Create directory: mkdir -p .prp-output/plans
| Declared | Expected Scope | If Mismatch |
|---|---|---|
| LOW | ≤3 tasks, no API/DB changes | WARN: "Consider MEDIUM" |
| MEDIUM | 4-10 tasks, OR API/DB changes | WARN if >10 tasks |
| HIGH | >10 tasks, OR multi-service | OK |
The plan file MUST include lifecycle frontmatter (status: pending, runner, mode) and ALL these sections:
packages/docs/ pages need updating and include docs + translation as implementation steps (the implementing agent writes EN docs + translates to 13 locales in the same PR). Blank = ⚠️ warning at gate audit.## Gate Compliance section that maps the project's /gate operational checklists to plan tasks so the pre-implement gate-audit (Layer 3) can verify completeness. Classify the change and scale the content (tiered — never silently omit):
new_feature + epic_kickoff + post_ship item to an owning plan task/phase: smoke-test L1/L2 for new endpoints, seed-uat-roles for new entities, nav entry points for new pages, ALTER TYPE … ADD VALUE for new enums, feature-flag verify-all-envs, docs redeploy, post-ship rollback/version-bump/branch-cleanup.Gate Compliance: N/A — <enumerated reason>. A blanket "N/A — no new features" is REJECTED (mirrors the Docs Impact N/A bar): enumerate what was checked (no packages/web pages, no /api routes, no schema/entities, no flags/billing) and why none apply./gate skill (e.g. claude-code/codex), run /gate audit pre-implement to verify this section (other toolchains: skip — this line degrades gracefully).IMPORTANT: The saved plan file MUST NOT contain any unfilled {...} placeholders in Validation Commands section. Pre-fill with actual detected commands.
Save file to: .prp-output/plans/{kebab-case-feature-name}-{TIMESTAMP}.plan.md
After saving, verify the file was written:
test -f ".prp-output/plans/{filename}" || echo "FATAL: Plan file write failed"
If verification fails, STOP — do not report success.
If from PRD: Update PRD status to in-progress, link plan file path. After update, verify the PRD file was modified (re-read and confirm status changed). If update fails, WARN: "Could not update PRD status. Manually update the phase status to in-progress."
Commit the plan artifact for durable git history (agent-devops#801): the plan (and any design/review artifacts under .prp-output/) should live in git, not only on disk. After saving, commit the artifact — but ONLY on a real feature branch:
BR=$(git branch --show-current) # empty on detached HEAD
if [ -n "$BR" ] && [ "$BR" != "main" ] && [ "$BR" != "master" ]; then
git add -f .prp-output/plans/{filename}
if git commit -q -m "docs(plan): {kebab-case-feature-name} plan artifact"; then
echo "Plan committed on $BR: $(git rev-parse --short HEAD)"
else
echo "WARNING: plan commit did not succeed (nothing staged / hook / unset git identity) — commit the artifact manually before it is lost (#801)"
fi
else
echo "WARNING: on '${BR:-<detached HEAD>}' — NOT committing plan to main/master or a detached HEAD. Create a feature branch and commit the artifact so it isn't lost (repeatedly flagged by Warden — #801)."
fi
The [ -n "$BR" ] guard is essential — on a detached HEAD git branch --show-current is empty and "" != "main" would otherwise pass, orphaning the commit. Never commit plan artifacts directly to main/master. Report the commit outcome (sha or the WARNING) in the "Report to user" block below so it is auditable. (Epics: EPIC-ORCHESTRATION kickoff carries a matching 'commit plan/design artifacts to the feature branch' item.)
Report to user:
## Plan Created
**File**: `.prp-output/plans/{feature-name}-{TIMESTAMP}.plan.md`
{If from PRD:}
**Source PRD**: `{prd-file-path}`
**Phase**: #{number} - {phase name}
**PRD Updated**: Status set to `in-progress`, plan linked
{If parallel phases:}
**Parallel Opportunity**: Phase {X} can run concurrently.
**Summary**: {2-3 sentence overview}
**Complexity**: {LOW/MEDIUM/HIGH} - {brief rationale}
**Scope**:
- {N} files to CREATE
- {M} files to UPDATE
- {K} total tasks
**Key Patterns**:
- {Pattern 1 from codebase with file:line}
- {Pattern 2 from codebase with file:line}
**External Research**:
- {Key doc 1 with version}
**UX Transformation**:
- BEFORE: {one-line current state}
- AFTER: {one-line new state}
**Risks**:
- {Primary risk}: {mitigation}
**Confidence Score**: {X}/10 (P:{p} G:{g} I:{i} V:{v} T:{t})
**Next Step**: `/prp-implement .prp-output/plans/{feature-name}-{TIMESTAMP}.plan.md`
Before saving, verify:
Context Completeness:
Implementation Readiness:
Pattern Faithfulness:
Validation Coverage:
UX Clarity:
NO_PRIOR_KNOWLEDGE_TEST: Could an agent unfamiliar with this codebase implement using ONLY the plan?