AgentSkillsCN

spec-principles

应用核心规范原则:IS/IS-NOT 区分、约束-设计-开放-实施,以及反模式检测。适用于创建、审查或评估任何规范文档时使用。

SKILL.md
--- frontmatter
name: spec-principles
description: Apply core specification principles: IS/IS-NOT distinction, constrain-design-open-implementation, and anti-pattern detection. Use when creating, reviewing, or evaluating any specification document.

Specification Principles

Foundational knowledge for working with software specifications.

Applicability Rubric

ConditionPassFail
New specification neededFeature/project has no SPEC.mdSpec already exists and is complete
Specification quality concernExisting spec is unclear or incompleteSpec is well-structured and implementable
Design direction guidanceImplementers need design directionImplementation path is already clear
Multi-person collaborationMultiple people implement from specSolo development, no coordination needed

Apply when: Any condition passes

Core Principles

What Makes a Good Specification

A specification describes the target state—what the system looks like when complete.

Specification ISSpecification is NOT
Target state descriptionImplementation plan
Problem context (why it exists)Decision rationale (why A over B)
Design decisions (what to build)Implementation choices (how to build)
Declarative statements and structured formatsProse narrative explanations

Specify vs Leave Open (for writing decisions; see spec-quality Balance Check for review verification):

QuestionSpecifyLeave to Implementer
User-visible?YesNo
Affects module contracts?YesNo
Could cause inconsistent interpretation?YesNo
Internal algorithm or data structure?Only if cross-implementer consistency requiredYes (default)

Over-specified vs Properly Constrained:

AspectOver-specifiedProperly Constrained
Error handling"Use try-catch with retry 3 times""Retry transient failures; report permanent failures to user"
Data storage"Store in PostgreSQL users table""Persist user profile across sessions"
UI layout"Use 16px grid with flexbox""Display items in a scannable list with clear hierarchy"

Constrain Design, Open Implementation

  • Specify all user-visible decisions
  • Leave internal implementation choices to implementers unless cross-implementer consistency requires shared conventions
  • If an implementer must guess a design decision, the specification is incomplete

Three-Layer Overview

Complete specifications address three layers:

LayerPurposeKey Question
IntentWhy this existsWhat problem for whom?
DesignWhat to buildWhat boundaries, interfaces, behaviors?
ConsistencyHow to stay unifiedWhat patterns for similar problems?

Anti-Patterns (prevention; see spec-quality Common Problems for diagnostic use)

Anti-PatternSymptomWhy It FailsRemedy
Explanatory notesNote: appears in specIf clarification is needed, the spec itself is unclearRewrite the statement directly
Phase markers(Future), (v2) in specSpec describes target state, not phasesRemove or split into separate spec
Optional markers(Optional) in specEither required for target state or notMove to Non-goals or make it required
Over-specificationAlgorithm details, framework choicesConstrains implementer without design benefitReplace with observable behavior
Prose narrative"First we do X, then Y happens"Mixes process with target stateUse declarative statements or structured formats (Context → Action → Outcome)
Vague language"Handle appropriately", "reasonable time"Different implementers interpret differentlyUse specific values or measurable criteria

Completion Rubric

Before Writing/Reviewing

CriterionPassFail
Problem understandingCan articulate the problem in one sentenceProblem is vague or undefined
User identificationKnow who will use thisUsers not identified
Scope definitionClear what is included and excludedScope is open-ended

During Writing/Reviewing

CriterionPassFail
Declarative statementsSpec uses "system does X" or structured formatsSpec uses prose narrative "first... then..."
Design vs implementationOnly observable behaviors specifiedInternal details included
Anti-pattern freeNo explanatory notes, phase markers, vague languageAnti-patterns present
Specify vs Leave OpenEach decision tested against the decision tableDecisions not evaluated

After Writing/Reviewing

CriterionPassFail
Implementer testAn implementer can build without clarifying questionsAmbiguity remains
Compatibility testTwo implementers would produce compatible resultsInterpretation varies
Balance check (spec-quality)No over-specification or under-specification detectedImbalance found