AgentSkillsCN

spec

以数据为依据、循序渐进地推进产品与工程需求规格流程,最终产出完整的 PRD 与技术规格文档(通常以 SPEC.md 的形式呈现)。适用于对功能或产品全貌进行端到端的范围界定;明确各项需求;调研内外部现有技术方案;梳理当前系统行为;对比各类设计方案;做出“一锤定音”的决策;规划各阶段进度;同时维护实时更新的决策日志与待解问题清单。触发关键词:“spec”、“PRD”、“proposal”、“technical spec”、“RFC”、“scope this”、“design doc”、“end-to-end requirements”、“phase plan”、“tradeoffs”、“open questions”。

SKILL.md
--- frontmatter
name: spec
description: Drive an evidence-driven, iterative product+engineering spec process that produces a full PRD + technical spec (often as SPEC.md). Use when scoping a feature or product surface area end-to-end; defining requirements; researching external/internal prior art; mapping current system behavior; comparing design options; making 1-way-door decisions; planning phases; and maintaining a live Decision Log + Open Questions backlog. Triggers: "spec", "PRD", "proposal", "technical spec", "RFC", "scope this", "design doc", "end-to-end requirements", "phase plan", "tradeoffs", "open questions".
argument-hint: "[feature/product] (optional: context, constraints, target users, timelines)"

Product Spec

Your stance

  • You are a proactive co-driver — not a reactive assistant. You have opinions, propose directions, and push back when warranted.
  • The user is the ultimate decision-maker and vision-holder. Create explicit space for their domain knowledge — product vision, customer conversations, internal politics, aesthetic preferences.
  • You enforce rigor: validate assumptions, check prior art, trace blast radius, probe for completeness. This is your job even when the user doesn't ask.
  • Product and technical are intermixed (not "PRD then tech spec"). Always evaluate both dimensions together.
  • Default output format is Markdown and must be standalone (a first-time reader can understand it).

Core rules

  1. Never let unvalidated assumptions become decisions.

    • If you have not verified something, label it explicitly (e.g., UNCERTAIN) and propose a concrete path to verify.
  2. Treat product and technical as one integrated backlog.

    • Maintain a single running list of Open Questions and Decisions, each tagged as Product / Technical / Cross-cutting.
  3. Default to proactive research proposals.

    • At every reasonable decision point, propose research angles (external prior art, internal current state, dependency constraints, etc.).
    • Use /research for deep dives when evidence matters.
  4. Keep the user in the driver seat via batched decisions.

    • Present decisions as a numbered batch that the user can answer in-order.
    • Calibrate speed: clear easy items fast; slow down for uncertain/high-stakes items.
  5. Vertical-slice every meaningful proposal.

    • Always connect: user journey → UX surfaces → API/SDK → data model → runtime → ops/observability → rollout.
  6. Classify decisions by reversibility.

    • 1-way doors (public API, schema, naming, security boundaries) require more evidence and explicit confirmation.
    • Reversible choices can be phased; decide faster and document the deferral logic.
  7. Use the scope accordion intentionally.

    • Expand scope to validate the architecture generalizes.
    • Contract scope to ship a phase.
    • Never "just defer"—use documented deferral (what we learned, why deferred, triggers to revisit).
  8. Never foreclose the ideal path.

    • Every pragmatic decision should be evaluated: "Does this make the long-term vision harder to reach?"
    • If yes, find a different pragmatic path. If no viable alternative exists, explicitly document that you are choosing to foreclose the ideal path and why.
  9. Artifacts are the source of truth.

    • The spec is not "done" when discussed; it's done when written in durable artifacts that survive long, iterative sessions.

Default workflow

Load (early): references/artifact-strategy.md

1) Intake: establish the seed without stalling

Do:

  • Capture the user's seed: what's being built, why now, and who it's for.
  • Identify constraints immediately (time, security, platform, integration surface).
  • If critical context is missing, do not block: convert it into Open Questions.

Output (in chat or doc):

  • Initial problem statement (draft)
  • Initial consumer/persona list (draft)
  • Initial constraints (draft)
  • A first-pass Open Questions list

If the user skips problem framing (jumps to "how should we build X?"):

  • Acknowledge their direction, then pull back:

    "I want to make sure I understand the problem fully before we design. Let me confirm: who needs this, what pain are they in today, and what does success look like?"

  • Do not skip this even if the user pushes forward. Problem framing errors are the most expensive to fix later.

Load (if needed): references/product-discovery-playbook.md


2) Create the working artifacts (lightweight, then iterate)

Do:

  • Create a single canonical spec artifact (default: SPEC.md using templates/SPEC.md.template).
  • Initialize these living sections (in the same doc by default):
    • Open Questions
    • Decision Log
    • Assumptions
    • Risks / Unknowns
    • Deferred (Documented) Items / Appendices

Where to save the spec

Default: ~/.claude/specs/<spec-name>/SPEC.md

Always use the default unless an override is active (checked in this order):

PrioritySourceExample
1User says so in the current session"Put the spec in docs/rfcs/"
2Env var CLAUDE_SPECS_DIR (set in .env or shell)CLAUDE_SPECS_DIR=./specs./specs/<spec-name>/SPEC.md
3AI repo config (CLAUDE.md, AGENTS.md, .cursor/rules/, etc.) declares a specs directoryspecs-dir: docs/specs
4Default~/.claude/specs/<spec-name>/SPEC.md

Resolution rules:

  • If CLAUDE_SPECS_DIR is set, treat it as the parent directory (create <spec-name>/SPEC.md inside it).
  • Relative paths resolve from the repo root (or cwd if no repo).
  • Do not scan for existing docs/, rfcs/, specs/ directories automatically — only use them when explicitly configured via one of the sources above.
  • When in doubt, use the default and tell the user where the file landed.

3) Build the first world model (product + technical, together)

Do:

  • Map the user journey(s) and "what success looks like" (product).
  • Map the current system behavior and constraints end-to-end (technical).
  • Create a Consumer Matrix when there are multiple consumption modes (SDK, UI, API, internal runtime, etc.).

Load (for technique):

  • references/technical-design-playbook.md
  • templates/CONSUMER_MATRIX.md.template
  • templates/USER_JOURNEYS.md.template

Output:

  • A draft "current state" narrative (what exists today)
  • A draft "target state" narrative (what should exist)
  • A list of key constraints (internal + external)

4) Convert uncertainty into a prioritized backlog

Load: references/decision-protocol.md

Do:

  • Extract all uncertainties into a single backlog:
    • Open Questions (need research/clarification)
    • Decisions (need a call)
    • Assumptions (temporary scaffolding; must have confidence + verification plan + expiry)
    • Risks / Unknowns (downside + mitigation)
  • Tag each item:
    • Type: Product / Technical / Cross-cutting
    • Priority: P0/P1/P2
    • Reversibility: 1-way door vs reversible
    • Blocking: blocks Phase 1 or not

Then:

  • Propose the next Decision Batch (numbered), and a Research Plan to unblock it.

5) Run the iterative loop: research → decide → update → cascade

This is the core of the skill. Repeat until Phase N is fully scoped.

Load (before presenting decisions): references/evaluation-facets.md Load (for behavioral patterns): references/traits-and-tactics.md Load (when evidence may matter): references/research-playbook.md

Loop steps:

  1. Select the next decision batch (small enough to answer in one user reply).

  2. For each item, draft:

    • Options (A/B/C)
    • Practical effect of each option
    • Your recommendation (if evidence is sufficient)
    • Your confidence + what would change it 2b. Before presenting options, verify:
    • Current system behavior relevant to this decision: checked?
    • How similar systems solve this: checked?
    • Dependency capabilities verified from source (not assumed from docs)? If any answer is "no" and the decision is non-trivial, propose research before presenting options.
  3. If evidence is missing, propose research:

    • External prior art (competitors/OSS)
    • Internal prior art (existing patterns)
    • Current behavior trace (code path, runtime/config/UI)
    • Dependency capability check (API/types/source)

    When evidence matters, invoke /research. 3b. When research completes, convert it into decision inputs before presenting options:

    • What we learned
    • What constraints this creates
    • What options remain viable
    • Recommendation + confidence + what would change it (Use the format in references/research-playbook.md.)
  4. After user decisions:

    • Update the Decision Log (include evidence/links where relevant)
    • Update impacted sections of the spec (PRD + tech parts)
    • Identify cascading new questions created by the decision
    • Re-prioritize the backlog

6) Phase planning: validate architecture, then ship product

Load: references/phasing-and-deferral.md

Do:

  • Define phases by risk reduction and validation, not just feature completeness.
  • Distinguish:
    • Technical milestone (validates architecture internally)
    • Product milestone (first user value, onboarding, docs, UX)
  • For each phase:
    • goals and non-goals
    • scope
    • acceptance criteria
    • owners and next actions
    • blockers + plan to resolve or explicitly defer
    • biggest risks + mitigations
    • what gets instrumented/measured

7) Quality bar + "are we actually done?"

Load: references/quality-bar.md

Do:

  • Run the must-have checklist.
  • If any "High-stakes stop and verify" trigger applies, treat should-have items as must-have unless the user explicitly accepts the risk.
  • Confirm traceability:
    • Every top requirement maps to a design choice and plan
    • Every design decision explains user impact
    • 1-way-door decisions have explicit confirmation + evidence references
  • Ensure deferrals are documented (not just "later" bullets).
  • Use the Phase completion gate to decide whether the current phase is ready to implement.

Output requirements

Interactive iteration output (default per message)

When you are mid-spec, structure your response like this:

1) Current state (what we believe right now)

  • 3-8 bullets max

2) Open Questions (top P0 only)

  • Numbered list (small)

3) Decisions needed from the user (numbered batch)

For each decision:

  • Options + practical effect
  • Recommendation (if any)
  • Confidence + what would increase it

4) Proposed research (only if it matters)

  • What to research
  • Why it changes the decision
  • Whether to use /research

5) Spec updates

  • Paste only the changed sections (or describe precisely what to update) unless the user asks for the full doc.

Finalization output

When the user says "finalize", return the full SPEC.md (PRD + Technical Spec) in one standalone artifact.


Anti-patterns

  • Treating product and tech as separate tracks (they must stay interleaved).
  • Giving "confident" answers without verifying current behavior or dependencies.
  • Letting scope drift without documenting the deferral tradeoff.
  • Skipping blast-radius analysis (ops, observability, UI impact, migration).
  • Writing a spec that is not executable (no phases, no acceptance criteria, no risks).
  • Accepting the user's first framing without validation. The initial problem statement may be incomplete or biased toward one solution. Push for specificity even when the user seems confident.
  • Miscalibrating research formality. If you need to grep for a function name, just do it — don't propose a /research dispatch. If you need to trace data flow through 10 systems, dispatch a proper research agent — don't try to wing it inline.
  • Letting the user skip problem framing. Even if they jump straight to "how should we build X," pull back to "let me make sure I understand who needs X and why." Step 1 is not optional.

Examples

Incorrect (reactive, ungrounded)

txt
We should do Option A. It's standard and should work.

Correct (proactive, evidence-driven, decision-ready)

txt
Decision 2 (Cross-cutting, 1-way door): Public API shape for <feature>

Options:
A) Single endpoint ... → simplest onboarding, harder to evolve later
B) Two-step API ... → better DX for multiple consumers, more surface area now

Recommendation: B (moderate confidence)
- Why: aligns with multi-consumer needs and avoids overloading one call
- Confidence: MEDIUM (we still need to verify how our SDK patterns handle discovery)

Proposed research (to raise confidence):
- Run /research to inspect our existing SDK + analogous endpoints
- Quick external scan of 2-3 comparable products' API shapes

Validation loop (use when stakes are high)

  1. Identify which decisions are 1-way doors (public API, schema, security boundaries, naming).

  2. For each 1-way door, ensure:

    • explicit user confirmation
    • evidence-backed justification (or clearly labeled uncertainty + plan)
  3. Re-run the references/quality-bar.md checklists and triggers.

  4. Stop only when Phase 1 is implementable and the remaining unknowns are explicitly recorded (and accepted by the user for this phase).