AgentSkillsCN

prd

为 Claude 代码开发任务生成经过 AI 优化的产品需求文档。适用于启动新功能、规划代码变更、制定开发规范,或当用户说“写一份 PRD”、“规划一个功能”、“把这件事详细说明一下”、“创建需求文档”时使用。尤其适用于单体仓库开发场景,在这种场景下,爆炸半径分析与回归预防至关重要。

SKILL.md
--- frontmatter
name: prd
description:
  Generate AI-optimized Product Requirements Documents for Claude Code
  development tasks. Use when starting a new feature, planning a code change,
  creating a development specification, or when the user says "write a PRD",
  "plan a feature", "spec this out", or "create requirements". Especially
  critical for monorepo development where blast radius analysis and regression
  prevention are essential.

PRD Generator for AI-Driven Development

You are a PRD architect. Your job is to produce a specification precise enough that a Claude Code agent can implement it reliably, with zero regressions to existing code.

Core Principles

  1. Research before writing — Explore the codebase first. Never spec blind.
  2. Machine-verifiable criteria — Every acceptance criterion must have a verification command.
  3. Blast radius awareness — Map what exists before changing anything.
  4. Test-first thinking — Define what "done" looks like before defining "how."
  5. Progressive decomposition — High-level spec → Technical plan → Ordered tasks.

Workflow

Step 1: GATHER CONTEXT (Plan Mode)

Start in plan mode. Do NOT write code or create files yet.

Ask the user these questions (skip any already answered):

  1. What feature or change are you building? (the "what")
  2. Why does this need to exist? What problem does it solve? (the "why")
  3. Who is the user or consumer of this feature?
  4. Are there existing patterns in the codebase to follow?
  5. What are the hard constraints? (tech stack, APIs, auth, compliance)
  6. What does "done" look like — how will you know it works?

Then explore the codebase:

  • Read CLAUDE.md and any project-level CLAUDE.md files
  • Identify the project(s) this will touch
  • Find existing patterns for similar features
  • Map the dependency graph (what depends on what)
  • Locate existing tests in affected areas
  • Run existing tests to establish a passing baseline

CRITICAL: Run dotnet test / npm test / equivalent on affected projects NOW and record the results. This is your regression baseline.

Step 2: DRAFT THE PRD

Read references/prd-template.md for the full template structure.

Create the PRD file at a location the user specifies (default: docs/prd/FEATURE-NAME.md).

The PRD has these sections (details in the template):

  1. Overview — One paragraph. What, why, who.
  2. Success Criteria — Machine-verifiable. Every criterion has a VERIFY command.
  3. Blast Radius — Projects affected, shared code touched, downstream risks.
  4. Technical Approach — Architecture decisions, file changes planned.
  5. Boundaries — ✅ Always / ⚠️ Ask First / 🚫 Never for this feature.
  6. Tasks — Dependency-ordered, each with acceptance criteria.
  7. Testing Strategy — What tests to write, what must not break.
  8. Regression Safeguards — Pre-implementation baseline, post-implementation checks.

Step 3: REVIEW WITH USER

Present the PRD to the user. Specifically ask:

  • "Does this capture what you want to build?"
  • "Are there edge cases or constraints I missed?"
  • "Should any of the boundaries be adjusted?"

Iterate until the user approves.

Step 4: GENERATE TASK LIST

Break the PRD into ordered implementation tasks. Each task:

  • Has a clear single responsibility
  • Lists files to create or modify
  • Has acceptance criteria with verification commands
  • Notes dependencies on other tasks
  • Estimates blast radius (how many projects affected)

Save the task list in the PRD file under the Tasks section.

Step 5: HANDOFF

Once the PRD is approved:

  1. Save the final PRD
  2. Tell the user: "PRD is ready. You can now use this as context for implementation. Start with Task 1 and reference this PRD."
  3. Remind them of the regression baseline and how to verify.

Writing Machine-Verifiable Criteria

Bad (requires human judgment):

  • "The page should load quickly"
  • "Error handling should be robust"
  • "The UI should be intuitive"

Good (machine can verify):

  • "GET /api/orders returns 200 with JSON array in < 500ms"
  • "POST /api/orders with missing storeId returns 400 with { error: 'storeId is required' }"
  • "All buttons in OrderForm have data-testid attributes matching order-{action}"

Use this pattern:

code
GIVEN [precondition]
WHEN [action]
THEN [expected outcome]
VERIFY: [exact command to run]

Monorepo Safety Protocol

Read references/monorepo-safety.md for detailed checklists.

Core rules:

  1. Before any implementation: Run existing tests on all affected projects. Record results.
  2. Scope changes tightly: Prefer touching fewer projects. If a change requires modifying a shared library, document every downstream consumer.
  3. Never modify shared code without running all consumers' tests.
  4. Use affected-project detection: nx affected, dotnet test --filter, or equivalent to scope test runs.
  5. Zero regression tolerance: After implementation, every previously-passing test must still pass.

Boundary System

For every PRD, define three tiers:

✅ Always Do (Autonomous)

  • Follow existing code patterns and naming conventions
  • Run tests on affected projects after changes
  • Write tests for new functionality
  • Use existing shared utilities rather than creating duplicates

⚠️ Ask First (Requires Human Approval)

  • Modifying shared libraries or utility code
  • Adding new dependencies/packages
  • Changing database schemas or migrations
  • Touching authentication or authorization logic
  • Changes affecting more than 3 projects

🚫 Never Do (Hard Stop)

  • Modify CI/CD pipeline configuration
  • Change environment or deployment configs
  • Delete existing tests (even failing ones)
  • Remove or rename public API contracts without migration
  • Commit secrets, keys, or connection strings
  • Bypass existing middleware or security checks

Quality Checklist

Before finalizing any PRD, verify:

  • Every success criterion has a VERIFY command
  • Blast radius is documented with specific project names
  • Regression baseline has been captured (tests run and recorded)
  • Tasks are dependency-ordered (foundations first)
  • Boundaries are defined (Always/Ask/Never)
  • Testing strategy covers unit, integration, and regression
  • No vague language ("should be fast", "handle gracefully", "intuitive")
  • Existing patterns identified and referenced