AgentSkillsCN

spec-philosophy

以规格说明书驱动的开发方法与工作流程。适用场景: - 当您开始开发新功能或新项目时(“新功能”、“实施”、“构建”); - 当用户的需求模糊不清时(“加点什么”、“让它更好一点”); - 当您需要坚持“先写规格”的开发方式时(“先写规格”、“创建规格说明书”); - 当有人只说“直接做吧”或想要跳过规划环节时; - 当您需要讨论需求、验收标准或项目范围时。 触发短语:规格说明书、PRD、需求文档、范围界定、功能规划。

SKILL.md
--- frontmatter
name: spec-philosophy
description: |
  Specification-Driven Development methodology and workflow. Use when:
  - Starting new features or projects ("new feature", "implement", "build")
  - User request is vague or unclear ("add something", "make it better")
  - Enforcing spec-first development ("write spec", "create specification")
  - Someone says "just build it" or wants to skip planning
  - Discussing requirements, acceptance criteria, or scope
  Trigger phrases: specification, PRD, requirements document, scope definition, feature planning
allowed-tools: Read, Write, Glob, AskUserQuestion
model: sonnet
user-invocable: true
context: fork
agent: general-purpose

Specification-Driven Development (SDD)

SDD is a disciplined approach to software development that requires explicit specifications before any implementation begins.

Core Principles

1. No Code Without Spec

RULE: Never write implementation code without an approved specification.

  • Prevents scope creep
  • Forces upfront thinking
  • Creates audit trail
  • Enables accurate estimation

2. Code-Free Spec (NEW)

RULE: Specifications describe WHAT to build, never HOW to code it.

Specs MUST contain:

  • User Stories (INVEST principle: Independent, Negotiable, Valuable, Estimatable, Small, Testable)
  • Acceptance Criteria (Gherkin format: Given-When-Then)
  • Non-Functional Requirements (measurable targets: "< 200ms p95", not "fast")
  • Edge Cases and error scenarios
  • Out of Scope (explicit exclusions)
  • Success Metrics (verifiable completion criteria)

Specs MUST NOT contain:

  • Implementation code or code snippets
  • Pseudocode or algorithm details
  • Function signatures or class definitions
  • Specific tool/library versions (use "current stable" or omit)
  • Step-by-step implementation instructions

Code References:

  • Use file:line pointers to existing patterns: "Follow pattern at src/services/auth.ts:23"
  • Describe what to reference, not the code itself: "Use the error handling pattern in utils/errors.ts"
  • NEVER copy code into specification documents

Why this matters for AI agents:

  • Specifications are contracts defining WHAT, not tutorials on HOW
  • AI agents perform better with goal-oriented specs than prescriptive instructions
  • Code in specs creates confusion: is it the requirement or just an example?
  • Keeps specs technology-agnostic and reusable

3. Ambiguity Tolerance Zero

RULE: If requirements are vague, DO NOT GUESS. Ask questions.

  • Assumptions cause rework
  • Clarification is cheaper than bugs
  • Users know what they want (with help)

4. Specification as Contract

RULE: The spec is the source of truth for implementation.

The spec defines:

  • What to build (functional requirements)
  • How well to build it (non-functional requirements)
  • When it's done (acceptance criteria)
  • What NOT to build (out of scope)

Development Phases

PhaseNameActionOutput
1AmbiguityReceive vague requestUnderstanding of intent
2ClarificationInvoke interview skillRequirements summary
3DefinitionCreate spec in docs/specs/Approved specification
4ExecutionImplement per specWorking code
5VerificationValidate against specPassing tests

Relationship to Plan→Review→Implement Commands

The 5-phase model above is the logical abstraction. The plan→review→implement commands expand this into an operational workflow:

Logical PhaseCommand / PhaseDetails
1. Ambiguity/spec-plan: DiscoveryInitial requirements gathering
2. Clarification/spec-plan: Exploration + Clarifying QuestionsCodebase analysis and user interview
3. Definition/spec-plan: Spec Drafting + Architecture DesignSpecification and design with self-review
4. Review/spec-review: Interactive FeedbackUser-driven plan review and refinement
5. Execution/spec-implement: ImplementationTDD-driven development

Quick Reference

Spec File Location

code
docs/specs/
├── SPEC-TEMPLATE.md      # Template for new specs
└── feature-*.md          # Feature specifications

Agent Integration

AgentRole in SDD
product-managerCreates specs
system-architectSystem-level design (ADRs, schemas)
code-architectFeature implementation blueprints
*-specialistImplements specs
qa-engineerVerifies specs
security-auditorAudits security NFRs

Additional Resources

For detailed information:

Balancing Structure with Flexibility

SDD provides structure, but rigid adherence can hinder effective problem-solving.

Goal-Oriented Approach

From Claude Code Best Practices:

"Claude often performs better with high level instructions rather than step-by-step prescriptive guidance."

Apply to SDD:

  • Phases define WHAT to achieve, not exactly HOW
  • Adapt approach based on task complexity
  • Skip phases when genuinely unnecessary (e.g., typo fixes)

When to Apply Full SDD

ScenarioFull Plan→ImplementAbbreviated
New featureYes
Complex changeYes
Architecture decisionYes
Bug fixYes /debug
Typo/config changeYes /quick-impl
Clear, scoped taskYes /quick-impl

Flexibility Clause

The SDD workflow is a framework, not a checklist.

If you identify that a situation warrants deviation:

  1. Confirm all L1 rules are still respected (no code without understanding, no skipping security)
  2. Explain why the standard approach doesn't fit
  3. Proceed with the adapted approach

L1 Rules (Never Skip):

  • Understanding requirements before implementation
  • Security review for security-sensitive code
  • Approval for scope changes

L2/L3 (Adapt as Needed):

  • Number of exploration agents
  • Spec document format
  • Phase ordering for simple tasks

Rules (L1 - Hard)

  • NEVER implement without understanding requirements
  • ALWAYS clarify before assuming
  • NEVER add scope without approval
  • ALWAYS document significant deviations
  • NEVER include code snippets, pseudocode, or implementation details in specifications
  • ALWAYS use file:line references instead of copying code into specs

Defaults (L2 - Soft)

  • Create formal spec for features > 1 day effort
  • Use /spec-plan for new features (can use /quick-impl for obvious small tasks)
  • Acceptance criteria should be testable

Guidelines (L3)

  • Consider TDD for complex logic
  • Prefer parallel agent execution when independent
  • Document architectural decisions in ADRs