mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-05-15 13:23:13 +08:00
feat: add PRD planning command flow
This commit is contained in:
committed by
Affaan Mustafa
parent
940135ea47
commit
f8070dd640
@@ -99,7 +99,7 @@ If PR not found, stop with error. Store PR metadata for later phases.
|
||||
Build review context:
|
||||
|
||||
1. **Project rules** — Read `CLAUDE.md`, `.claude/docs/`, and any contributing guidelines
|
||||
2. **PRP artifacts** — Check `.claude/PRPs/reports/` and `.claude/PRPs/plans/` for implementation context related to this PR
|
||||
2. **Planning artifacts** — Check `.claude/prds/`, `.claude/plans/`, `.claude/reviews/`, and legacy `.claude/PRPs/{prds,plans,reports,reviews}/` for context related to this PR
|
||||
3. **PR intent** — Parse PR description for goals, linked issues, test plans
|
||||
4. **Changed files** — List all modified files and categorize by type (source, test, config, docs)
|
||||
|
||||
@@ -188,7 +188,7 @@ Special cases:
|
||||
|
||||
### Phase 6 — REPORT
|
||||
|
||||
Create review artifact at `.claude/PRPs/reviews/pr-<NUMBER>-review.md`:
|
||||
Create review artifact at `.claude/reviews/pr-<NUMBER>-review.md` unless the repo already uses legacy `.claude/PRPs/reviews/` for this workstream:
|
||||
|
||||
```markdown
|
||||
# PR Review: #<NUMBER> — <TITLE>
|
||||
@@ -273,7 +273,7 @@ Issues: <critical_count> critical, <high_count> high, <medium_count> medium, <lo
|
||||
Validation: <pass_count>/<total_count> checks passed
|
||||
|
||||
Artifacts:
|
||||
Review: .claude/PRPs/reviews/pr-<NUMBER>-review.md
|
||||
Review: .claude/reviews/pr-<NUMBER>-review.md
|
||||
GitHub: <PR URL>
|
||||
|
||||
Next steps:
|
||||
|
||||
160
commands/plan-prd.md
Normal file
160
commands/plan-prd.md
Normal file
@@ -0,0 +1,160 @@
|
||||
---
|
||||
description: "Generate a lean, problem-first PRD and hand off to /plan for implementation planning."
|
||||
argument-hint: "[product/feature idea] (blank = start with questions)"
|
||||
---
|
||||
|
||||
# PRD Command
|
||||
|
||||
Produces a **Product Requirements Document** — the requirements-phase artifact of the SDLC. Captures *what* must be true for success and *why*, and stops before *how*. Implementation decomposition is delegated to `/plan`.
|
||||
|
||||
**Input**: `$ARGUMENTS`
|
||||
|
||||
## Scope of this command
|
||||
|
||||
| This command does | This command does NOT do |
|
||||
|---|---|
|
||||
| Frame the problem and users | Design the architecture |
|
||||
| Capture success criteria and scope | Pick files or write patterns |
|
||||
| List open questions and risks | Enumerate implementation tasks |
|
||||
| Write `.claude/prds/{name}.prd.md` | Produce an implementation plan — that's `/plan` |
|
||||
|
||||
If you find yourself writing implementation detail, stop and cut it. It belongs in `/plan`.
|
||||
|
||||
**Anti-fluff rule**: When information is missing, write `TBD — needs validation via {method}`. Never invent plausible-sounding requirements.
|
||||
|
||||
## Workflow
|
||||
|
||||
Four phases. Each phase is a single gate — ask the questions, wait for the user, then move on. No nested loops, no parallel research ceremony.
|
||||
|
||||
### Phase 1 — FRAME
|
||||
|
||||
If `$ARGUMENTS` is empty, ask:
|
||||
|
||||
> What do you want to build? One or two sentences.
|
||||
|
||||
If provided, restate in one sentence and ask:
|
||||
|
||||
> I understand: *{restated}*. Correct, or should I adjust?
|
||||
|
||||
Then ask the framing questions in a single set:
|
||||
|
||||
> 1. **Who** has this problem? (specific role or segment)
|
||||
> 2. **What** is the observable pain? (describe behavior, not assumed needs)
|
||||
> 3. **Why** can't they solve it with what exists today?
|
||||
> 4. **Why now?** — what changed that makes this worth doing?
|
||||
|
||||
Wait for the user. Do not proceed without answers (or explicit "skip").
|
||||
|
||||
### Phase 2 — GROUND
|
||||
|
||||
Ask for evidence. This is the shortest phase and the most load-bearing:
|
||||
|
||||
> What evidence do you have that this problem is real and worth solving? (user quotes, support tickets, metrics, observed behavior, failed workarounds — anything concrete)
|
||||
|
||||
If the user has none, record the PRD's Evidence section as `Assumption — needs validation via {user research | analytics | prototype}`. This keeps the PRD honest.
|
||||
|
||||
### Phase 3 — DECIDE
|
||||
|
||||
Scope and hypothesis in a single set:
|
||||
|
||||
> 1. **Hypothesis** — Complete: *We believe **{capability}** will **{solve problem}** for **{users}**. We'll know we're right when **{measurable outcome}**.*
|
||||
> 2. **MVP** — The minimum needed to test the hypothesis?
|
||||
> 3. **Out of scope** — What are you explicitly **not** building (even if users ask)?
|
||||
> 4. **Open questions** — Uncertainties that could change the approach?
|
||||
|
||||
Wait for responses.
|
||||
|
||||
### Phase 4 — GENERATE & HAND OFF
|
||||
|
||||
Create the directory if needed, write the PRD, and report.
|
||||
|
||||
```bash
|
||||
mkdir -p .claude/prds
|
||||
```
|
||||
|
||||
**Output path**: `.claude/prds/{kebab-case-name}.prd.md`
|
||||
|
||||
#### PRD Template
|
||||
|
||||
```markdown
|
||||
# {Product / Feature Name}
|
||||
|
||||
## Problem
|
||||
{2–3 sentences: who has what problem, and what's the cost of leaving it unsolved?}
|
||||
|
||||
## Evidence
|
||||
- {User quote, data point, or observation}
|
||||
- {OR: "Assumption — needs validation via {method}"}
|
||||
|
||||
## Users
|
||||
- **Primary**: {role, context, what triggers the need}
|
||||
- **Not for**: {who this explicitly excludes}
|
||||
|
||||
## Hypothesis
|
||||
We believe **{capability}** will **{solve problem}** for **{users}**.
|
||||
We'll know we're right when **{measurable outcome}**.
|
||||
|
||||
## Success Metrics
|
||||
| Metric | Target | How measured |
|
||||
|---|---|---|
|
||||
| {primary} | {number} | {method} |
|
||||
|
||||
## Scope
|
||||
**MVP** — {the minimum to test the hypothesis}
|
||||
|
||||
**Out of scope**
|
||||
- {item} — {why deferred}
|
||||
|
||||
## Delivery Milestones
|
||||
<!-- Business outcomes, not engineering tasks. /plan turns each into a plan. -->
|
||||
<!-- Status: pending | in-progress | complete -->
|
||||
|
||||
| # | Milestone | Outcome | Status | Plan |
|
||||
|---|---|---|---|---|
|
||||
| 1 | {name} | {user-visible change} | pending | — |
|
||||
| 2 | {name} | {user-visible change} | pending | — |
|
||||
|
||||
## Open Questions
|
||||
- [ ] {question that could change scope or approach}
|
||||
|
||||
## Risks
|
||||
| Risk | Likelihood | Impact | Mitigation |
|
||||
|---|---|---|---|
|
||||
|
||||
---
|
||||
*Status: DRAFT — requirements only. Implementation planning pending via /plan.*
|
||||
```
|
||||
|
||||
#### Report to user
|
||||
|
||||
```
|
||||
PRD created: .claude/prds/{name}.prd.md
|
||||
|
||||
Problem: {one line}
|
||||
Hypothesis: {one line}
|
||||
MVP: {one line}
|
||||
|
||||
Validation status:
|
||||
Problem {validated | assumption}
|
||||
Users {concrete | generic — refine}
|
||||
Metrics {defined | TBD}
|
||||
|
||||
Open questions: {count}
|
||||
|
||||
Next step: /plan .claude/prds/{name}.prd.md
|
||||
→ /plan will pick the next pending milestone and produce an implementation plan.
|
||||
```
|
||||
|
||||
## Integration
|
||||
|
||||
- `/plan <prd-path>` — consume the PRD and produce an implementation plan for the next pending milestone.
|
||||
- `tdd-workflow` skill — implement the plan test-first.
|
||||
- `/pr` — open a PR that references the PRD and plan.
|
||||
|
||||
## Success criteria
|
||||
|
||||
- **PROBLEM_CLEAR**: problem is specific and evidenced (or flagged as assumption).
|
||||
- **USER_CONCRETE**: primary user is a specific role, not "users".
|
||||
- **HYPOTHESIS_TESTABLE**: measurable outcome included.
|
||||
- **SCOPE_BOUNDED**: explicit MVP and explicit out-of-scope.
|
||||
- **NO_IMPLEMENTATION_DETAIL**: file paths, libraries, or task breakdowns are absent — if they appeared, move them to the `/plan` step.
|
||||
@@ -1,10 +1,11 @@
|
||||
---
|
||||
description: Restate requirements, assess risks, and create step-by-step implementation plan. WAIT for user CONFIRM before touching any code.
|
||||
argument-hint: "[feature description | path/to/*.prd.md]"
|
||||
---
|
||||
|
||||
# Plan Command
|
||||
|
||||
This command creates a comprehensive implementation plan before writing any code.
|
||||
This command creates a comprehensive implementation plan before writing any code. It accepts either free-form requirements or a PRD markdown file.
|
||||
|
||||
Run inline by default. Do not call the Task tool or any subagent by default. This keeps `/plan` usable from plugin installs that ship commands without agent files.
|
||||
|
||||
@@ -29,11 +30,86 @@ Use `/plan` when:
|
||||
The assistant will:
|
||||
|
||||
1. **Analyze the request** and restate requirements in clear terms
|
||||
2. **Break down into phases** with specific, actionable steps
|
||||
3. **Identify dependencies** between components
|
||||
4. **Assess risks** and potential blockers
|
||||
5. **Estimate complexity** (High/Medium/Low)
|
||||
6. **Present the plan** and WAIT for your explicit confirmation
|
||||
2. **Ground the plan** in relevant codebase patterns when the repo is available
|
||||
3. **Break down into phases** with specific, actionable steps
|
||||
4. **Identify dependencies** between components
|
||||
5. **Assess risks** and potential blockers
|
||||
6. **Estimate complexity** (High/Medium/Low)
|
||||
7. **Present the plan** and WAIT for your explicit confirmation
|
||||
|
||||
## Input Modes
|
||||
|
||||
| Input | Mode | Behavior |
|
||||
|---|---|---|
|
||||
| `path/to/name.prd.md` | PRD artifact mode | Read the PRD, pick the next pending delivery milestone or implementation phase, and write `.claude/plans/{name}.plan.md` |
|
||||
| Any other markdown path | Reference mode | Read the file as context and produce an inline plan |
|
||||
| Free-form text | Conversational mode | Produce an inline plan |
|
||||
| Empty input | Clarification mode | Ask what should be planned |
|
||||
|
||||
In PRD artifact mode, create `.claude/plans/` if needed. If the PRD contains a `Delivery Milestones` table, update only the selected row from `pending` to `in-progress` and set its `Plan` cell to the generated plan path. If the PRD uses the legacy `.claude/PRPs/prds/` format with `Implementation Phases`, read it without migrating paths.
|
||||
|
||||
## Pattern Grounding
|
||||
|
||||
Before writing the plan, search the codebase for conventions the implementation should mirror. Capture the top example for each relevant category with file references:
|
||||
|
||||
| Category | What to capture |
|
||||
|---|---|
|
||||
| Naming | File, function, type, command, or script naming in the affected area |
|
||||
| Error handling | How failures are raised, returned, logged, or handled gracefully |
|
||||
| Logging | Levels, format, and what gets logged |
|
||||
| Data access | Repository, service, query, or filesystem patterns |
|
||||
| Tests | Test file location, framework, fixtures, and assertion style |
|
||||
|
||||
If no similar code exists, state that explicitly. Do not invent a pattern.
|
||||
|
||||
## PRD Artifact Output
|
||||
|
||||
When called with a `.prd.md` file, write the plan to `.claude/plans/{kebab-case-name}.plan.md` using this structure:
|
||||
|
||||
````markdown
|
||||
# Plan: {Feature Name}
|
||||
|
||||
**Source PRD**: {path}
|
||||
**Selected Milestone**: {milestone or phase name}
|
||||
**Complexity**: {Small | Medium | Large}
|
||||
|
||||
## Summary
|
||||
{2-3 sentences}
|
||||
|
||||
## Patterns to Mirror
|
||||
| Category | Source | Pattern |
|
||||
|---|---|---|
|
||||
| Naming | `path:line` | {short description} |
|
||||
| Errors | `path:line` | {short description} |
|
||||
| Tests | `path:line` | {short description} |
|
||||
|
||||
## Files to Change
|
||||
| File | Action | Why |
|
||||
|---|---|---|
|
||||
| `path` | CREATE / UPDATE / DELETE | {reason} |
|
||||
|
||||
## Tasks
|
||||
### Task 1: {name}
|
||||
- **Action**: {what to do}
|
||||
- **Mirror**: {pattern to follow}
|
||||
- **Validate**: {command that proves correctness}
|
||||
|
||||
## Validation
|
||||
```bash
|
||||
{project-specific validation commands}
|
||||
```
|
||||
|
||||
## Risks
|
||||
| Risk | Likelihood | Mitigation |
|
||||
|---|---|---|
|
||||
|
||||
## Acceptance
|
||||
- [ ] All tasks complete
|
||||
- [ ] Validation passes
|
||||
- [ ] Patterns mirrored, not reinvented
|
||||
````
|
||||
|
||||
After writing the artifact, report its path and WAIT for confirmation before writing code.
|
||||
|
||||
## Example Usage
|
||||
|
||||
@@ -108,8 +184,11 @@ After planning:
|
||||
- Use the `tdd-workflow` skill to implement with test-driven development
|
||||
- Use `/build-fix` if build errors occur
|
||||
- Use `/code-review` to review completed implementation
|
||||
- Use `/pr` or `/prp-pr` to open a pull request
|
||||
|
||||
> **Need deeper planning?** Use `/prp-plan` for artifact-producing planning with PRD integration, codebase analysis, and pattern extraction. Use `/prp-implement` to execute those plans with rigorous validation loops.
|
||||
> **Need requirements first?** Use `/plan-prd` for a lean PRD at `.claude/prds/{name}.prd.md`.
|
||||
>
|
||||
> **Need the legacy PRP flow?** Use `/prp-plan` for deep PRP planning with `.claude/PRPs/` artifacts. Use `/prp-implement` to execute those plans with rigorous validation loops.
|
||||
|
||||
## Optional Planner Agent
|
||||
|
||||
|
||||
184
commands/pr.md
Normal file
184
commands/pr.md
Normal file
@@ -0,0 +1,184 @@
|
||||
---
|
||||
description: "Create a GitHub PR from current branch with unpushed commits — discovers templates, analyzes changes, pushes"
|
||||
argument-hint: "[base-branch] (default: main)"
|
||||
---
|
||||
|
||||
# Create Pull Request
|
||||
|
||||
**Input**: `$ARGUMENTS` — optional, may contain a base branch name and/or flags (e.g., `--draft`).
|
||||
|
||||
**Parse `$ARGUMENTS`**:
|
||||
- Extract any recognized flags (`--draft`)
|
||||
- Treat remaining non-flag text as the base branch name
|
||||
- Default base branch to `main` if none specified
|
||||
|
||||
---
|
||||
|
||||
## Phase 1 — VALIDATE
|
||||
|
||||
Check preconditions:
|
||||
|
||||
```bash
|
||||
git branch --show-current
|
||||
git status --short
|
||||
git log origin/<base>..HEAD --oneline
|
||||
```
|
||||
|
||||
| Check | Condition | Action if Failed |
|
||||
|---|---|---|
|
||||
| Not on base branch | Current branch ≠ base | Stop: "Switch to a feature branch first." |
|
||||
| Clean working directory | No uncommitted changes | Warn: "You have uncommitted changes. Commit or stash first." |
|
||||
| Has commits ahead | `git log origin/<base>..HEAD` not empty | Stop: "No commits ahead of `<base>`. Nothing to PR." |
|
||||
| No existing PR | `gh pr list --head <branch> --json number` is empty | Stop: "PR already exists: #<number>. Use `gh pr view <number> --web` to open it." |
|
||||
|
||||
If all checks pass, proceed.
|
||||
|
||||
---
|
||||
|
||||
## Phase 2 — DISCOVER
|
||||
|
||||
### PR Template
|
||||
|
||||
Search for PR template in order:
|
||||
|
||||
1. `.github/PULL_REQUEST_TEMPLATE/` directory — if exists, list files and let user choose (or use `default.md`)
|
||||
2. `.github/PULL_REQUEST_TEMPLATE.md`
|
||||
3. `.github/pull_request_template.md`
|
||||
4. `docs/pull_request_template.md`
|
||||
|
||||
If found, read it and use its structure for the PR body.
|
||||
|
||||
### Commit Analysis
|
||||
|
||||
```bash
|
||||
git log origin/<base>..HEAD --format="%h %s" --reverse
|
||||
```
|
||||
|
||||
Analyze commits to determine:
|
||||
- **PR title**: Use conventional commit format with type prefix — `feat: ...`, `fix: ...`, etc.
|
||||
- If multiple types, use the dominant one
|
||||
- If single commit, use its message as-is
|
||||
- **Change summary**: Group commits by type/area
|
||||
|
||||
### File Analysis
|
||||
|
||||
```bash
|
||||
git diff origin/<base>..HEAD --stat
|
||||
git diff origin/<base>..HEAD --name-only
|
||||
```
|
||||
|
||||
Categorize changed files: source, tests, docs, config, migrations.
|
||||
|
||||
### Planning Artifacts
|
||||
|
||||
Check for related artifacts produced by `/plan-prd`, `/plan`, or the legacy PRP workflow:
|
||||
- `.claude/prds/` — PRDs this PR implements a milestone of
|
||||
- `.claude/plans/` — Plans executed by this PR
|
||||
- `.claude/PRPs/prds/` — legacy PRP PRDs
|
||||
- `.claude/PRPs/plans/` — legacy PRP implementation plans
|
||||
- `.claude/PRPs/reports/` — legacy PRP implementation reports
|
||||
|
||||
Reference these in the PR body if they exist.
|
||||
|
||||
---
|
||||
|
||||
## Phase 3 — PUSH
|
||||
|
||||
```bash
|
||||
git push -u origin HEAD
|
||||
```
|
||||
|
||||
If push fails due to divergence:
|
||||
```bash
|
||||
git fetch origin
|
||||
git rebase origin/<base>
|
||||
git push -u origin HEAD
|
||||
```
|
||||
|
||||
If rebase conflicts occur, stop and inform the user.
|
||||
|
||||
---
|
||||
|
||||
## Phase 4 — CREATE
|
||||
|
||||
### With Template
|
||||
|
||||
If a PR template was found in Phase 2, fill in each section using the commit and file analysis. Preserve all template sections — leave sections as "N/A" if not applicable rather than removing them.
|
||||
|
||||
### Without Template
|
||||
|
||||
Use this default format:
|
||||
|
||||
```markdown
|
||||
## Summary
|
||||
|
||||
<1-2 sentence description of what this PR does and why>
|
||||
|
||||
## Changes
|
||||
|
||||
<bulleted list of changes grouped by area>
|
||||
|
||||
## Files Changed
|
||||
|
||||
<table or list of changed files with change type: Added/Modified/Deleted>
|
||||
|
||||
## Testing
|
||||
|
||||
<description of how changes were tested, or "Needs testing">
|
||||
|
||||
## Related Issues
|
||||
|
||||
<linked issues with Closes/Fixes/Relates to #N, or "None">
|
||||
```
|
||||
|
||||
### Create the PR
|
||||
|
||||
```bash
|
||||
gh pr create \
|
||||
--title "<PR title>" \
|
||||
--base <base-branch> \
|
||||
--body "<PR body>"
|
||||
# Add --draft if the --draft flag was parsed from $ARGUMENTS
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 5 — VERIFY
|
||||
|
||||
```bash
|
||||
gh pr view --json number,url,title,state,baseRefName,headRefName,additions,deletions,changedFiles
|
||||
gh pr checks --json name,status,conclusion 2>/dev/null || true
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 6 — OUTPUT
|
||||
|
||||
Report to user:
|
||||
|
||||
```
|
||||
PR #<number>: <title>
|
||||
URL: <url>
|
||||
Branch: <head> → <base>
|
||||
Changes: +<additions> -<deletions> across <changedFiles> files
|
||||
|
||||
CI Checks: <status summary or "pending" or "none configured">
|
||||
|
||||
Artifacts referenced:
|
||||
- <any PRDs/plans linked in PR body>
|
||||
|
||||
Next steps:
|
||||
- gh pr view <number> --web → open in browser
|
||||
- /code-review <number> → review the PR
|
||||
- gh pr merge <number> → merge when ready
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- **No `gh` CLI**: Stop with: "GitHub CLI (`gh`) is required. Install: <https://cli.github.com/>"
|
||||
- **Not authenticated**: Stop with: "Run `gh auth login` first."
|
||||
- **Force push needed**: If remote has diverged and rebase was done, use `git push --force-with-lease` (never `--force`).
|
||||
- **Multiple PR templates**: If `.github/PULL_REQUEST_TEMPLATE/` has multiple files, list them and ask user to choose.
|
||||
- **Large PR (>20 files)**: Warn about PR size. Suggest splitting if changes are logically separable.
|
||||
Reference in New Issue
Block a user