prd
Multi-phase PRD generator. Outputs plans/<branch>-prd.md ready for /hyperteam.
PRD Generator
Create detailed Product Requirements Documents that are clear, actionable, and suitable for implementation by junior developers or AI agents.
Critical Review Mandate
Your primary job is to critique the requirements you receive — not simply agree with them. The user is paying for your judgement, not your compliance. An agent that rubber-stamps every input is worse than useless: it lets conflicting requirements slip through and causes implementing agents to get stuck with irreconcilable constraints.
Before accepting any requirement at face value, actively search for and surface:
- Explicit conflicts within the input — contradictory requirements, goals that work against each other, acceptance criteria that are mutually exclusive.
- Implicit conflicts against the existing codebase — requirements that contradict existing ADRs, break established
patterns in
CLAUDE.md, conflict with the current domain model in the project source tree, or violate conventions inCONTRIBUTING.md. ReadCLAUDE.md, scandocs/adrs/, and search the project source directories (as identified inCLAUDE.md) before accepting any requirement. (Full ADR scan is intentional here: PRD work is design work and warrants full architectural context.) - Ambiguities that hide conflicts — vague requirements that seem compatible but would force contradictory implementation choices once an agent tries to write code.
If ambiguities are hiding conflicts, interview the user instead with clarifying questions via AskUserQuestion to
disambiguate and reveal the missing requirements and/or new conflicts.
When conflicts are detected, push back — use AskUserQuestion to clearly state the conflict, why it matters, and
propose concrete alternatives, blocking until the user resolves it.
Do not proceed to the next phase until all ambiguities and conflicts are resolved.
Seedling philosophy: A seedling PRD or external document source such as a GitHub or JIRA issue is the operator's intent distilled into a draft document — it gives the skill a head start with more details. But a seedling is not sacred: challenge them just as you would any other input.
The Job
Phase 0: Environment Setup
- Read
$ARGUMENTS(the text typed after/prd). If empty, useAskUserQuestionto gather input. - Detect input type:
- If
$ARGUMENTSis a path to an existing.mdfile → seedling mode (use the file as a baseline draft). - Otherwise → text description mode (generate from scratch).
- If
- Derive
<slug>as a short, lowercase-kebab-case label:- Seedling mode: derive from the seedling document's title.
- Text mode: derive from the feature description (e.g., "Account Rollover" →
account-rollover).
- Generate
<branch>asfeat-<slug>(e.g.,feat-account-rollover). - Detect GitHub issue references:
- Scan
$ARGUMENTSfor all URLs matching the patternhttps://github.com/{owner}/{repo}/issues/{N}(where{N}is a positive integer). - If one or more matches are found, collect all of them as
<source_issues>, a list ofowner/repo#Nreferences (e.g.,["samrom3/claude-hyper-plugs#13"]). - If no match is found, set
<source_issues>tonull— the metadata table will be omitted from the PRD. - For each issue in
<source_issues>, immediately run:
If this command fails (e.g., unauthenticatedgh issue edit <N> --repo <owner>/<repo> --add-assignee @megh, insufficient permissions), print a visible warning line (⚠ Warning: could not assign issue — <error>) but do NOT block PRD creation.
- Scan
- Sync main from origin:
- Run
git fetch origin mainto pull latest remote state. - Run
git log main..origin/main --oneline— if any commits are listed, main is behind; useAskUserQuestionto surface this to the user and stop until they confirm how to proceed (typicallygit merge origin/mainorgit rebase origin/main). - Only proceed once
mainis up to date withorigin/main.
- Run
- Create and checkout branch from main:
(If the branch already exists,git checkout -B <branch> main-Bresets it tomain— this is intentional when re-running/prdto avoid inheriting stale state.) After running, verify withgit branch --show-current— the output must equal<branch>. If it doesn't, useAskUserQuestionto surface the error and stop. - Create the
plans/directory if it does not exist:mkdir -p plans - Create a symlink so task files are accessible under
plans/<branch>:
After running, verify the symlink:ln -sf ~/.claude/tasks/<branch> plans/<branch>- Confirm
plans/<branch>exists and is a symlink:test -L plans/<branch> - Confirm
readlink plans/<branch>returns a path ending in.claude/tasks/<branch>. - If either check fails, use
AskUserQuestionto surface the error and stop — do not proceed to Phase 1.
- Confirm
Phase 1: Draft PRD (baseline)
-
If
plans/<branch>-prd.mdalready exists, move it toplans/archive/<branch>-prd.mdbefore continuing. -
Before generating anything: Read
CLAUDE.md, scandocs/adrs/, and search the project source directories (as identified inCLAUDE.md) for existing code related to the feature. Identify any conflicts between what is being requested and what already exists. This research is mandatory in both modes. (Full ADR scan is intentional: PRD work is design work — the author is actively making architectural decisions and full ADR context is worth the token cost.) -
Branch on input mode:
Seedling mode:
- Read the seedling file. Preserve the author's structure, intent, and any existing sections.
- Review the seedling for internal conflicts and conflicts against the existing codebase (from step 2).
- Use
AskUserQuestionto ask 2–3 targeted clarifying questions focused on conflicts, gaps, and ambiguities (not repeating what the seedling already says). - Expand the seedling into a complete PRD, filling in all missing template sections.
Text description mode:
- Use
AskUserQuestionto ask 3–5 clarifying questions (focus on: problem/goal, core functionality, scope/boundaries, success criteria). At least one question must probe potential conflicts with existing functionality uncovered in step 2. - Generate a complete PRD from scratch.
-
The generated PRD must follow the annotated example in
references/example-prd.mdand include Design Considerations and Open Questions. -
Developer stories should follow the scaffold-first / implement-second pattern for any new or changed API surface: the first story creates typed stubs (interfaces, API contracts) with
NotImplementedErrorbodies and skeleton tests; subsequent stories implement the business logic against those stable contracts via TDD. -
Save to
plans/<branch>-prd.md.-
If
<source_issues>is non-null and non-empty, write a metadata table immediately after the H1 heading and before section## 1., with one| Source Issue |row per issue, using exactly this format:# <Title> | Field | Value | | ------------ | ------------------------------ | | Source Issue | owner/repo#N | | Source Issue | owner/repo#M | ## 1. Introduction/OverviewFor a single issue, the table has exactly one
Source Issuerow. -
If
<source_issues>is null or empty, omit the metadata table entirely — the H1 heading is followed directly by## 1. Introduction/Overviewwith no table in between.
Reading note for agents and future readers: The metadata table, if present, appears immediately after the H1 heading and before the first
##section heading. Parsers should locate the H1, then scan forward collecting all| Source Issue |rows before encountering a##line; if none are found,source_issuesisnull. -
Phase 2: Design refinement (questions + expand open questions)
- Review the PRD's Design Considerations and use
AskUserQuestionto ask a targeted series of design questions. - Explicitly cross-check each proposed design choice against existing ADRs and
CLAUDE.mdpatterns. If a design choice contradicts an existing decision, surface this as a conflict requiring resolution (potentially via a new ADR that supersedes the old one). - Append newly discovered questions to the bottom of the Open Questions section (keep existing; add an "Added in Phase 2" subsection).
- Update
plans/<branch>-prd.mdwith the refined design considerations and updated open questions.
Phase 3: Final refinement (answer all open questions + final pass)
- Use
AskUserQuestionto ask the user all remaining Open Questions. - Refine the PRD one final time based on the answers.
- Final conflict sweep: Before saving, verify that no requirement in the PRD contradicts another, and that no requirement conflicts with the existing codebase as understood from the Phase 1 research. If any conflict is found, raise it with the user and resolve before saving.
- Save the final version to
plans/<branch>-prd.md.
Important: Do NOT start implementing. Just create the PRD.
Before Saving
- Phase 0 completed:
<branch>chosen (feat-<slug>), main synced from origin, branch checked out and verified,plans/directory exists, symlinkplans/<branch>→~/.claude/tasks/<branch>created and validated - GitHub issue URLs scanned from
$ARGUMENTS:<source_issues>set to["owner/repo#N", ...]if found,nullotherwise; for each issue,gh issue editassignment attempted (warning printed on failure, PRD creation not blocked) - Input mode detected: seedling (file path) or text description
-
CLAUDE.md,docs/adrs/, and project source directories searched for conflicts before generating - Phase 1 PRD includes all 9 sections (see
references/example-prd.md), including Design Considerations and Open Questions - If
<source_issues>is non-null: metadata table present immediately after H1 heading and before## 1., one row per issue; if null: no metadata table in PRD - Seedling mode: author's structure and intent preserved; only gaps/ambiguities questioned
- User input gathered in each phase as needed
- Incorporated user's answers into the PRD after each refinement phase
- Phase 2 cross-checked all design choices against existing ADRs and
CLAUDE.mdpatterns - Phase 3 final conflict sweep completed — no intra-PRD contradictions, no codebase conflicts
- Developer stories are small, specific, and follow the scaffold-first pattern
- Functional requirements are numbered (
FR-###) and unambiguous - Any old
plans/<branch>-prd.mdis archived toplans/archive/ - Non-goals section clarifies Goal section boundaries
- Any newly discovered questions were appended to the bottom of Open Questions (with a phase marker)