AgentSkillsCN

spec-framework

采用三层框架(意图、设计、一致性)来规范结构,并明确边界类型与实施标准。在将规范内容分层组织或进行元素选型时使用。

SKILL.md
--- frontmatter
name: spec-framework
description: Structure specifications using the three-layer framework (Intent, Design, Consistency) with boundary types and implementation standards. Use when organizing spec content into layers or selecting elements.

Specification Framework

Detailed structure for each layer of a specification.

Applicability Rubric

ConditionPassFail
Structuring new specWriting a spec from scratchSpec structure already established
Layer completeness checkNeed to verify all layers are addressedLayers are already complete
Element selectionDeciding which elements to includeElements already chosen
Multi-layer coordinationEnsuring layers align with each otherSingle-layer change only

Apply when: Any condition passes

Core Principles

Intent Layer

Provides context for judgment calls:

ElementRoleCore
PurposeWhat problem the system solves
UsersWho uses it, what they accomplish
ImpactsWhat behavior changes indicate success (drives priority)
Success criteriaWhat defines "done" and "working"
Non-goalsWhat is explicitly out of scope

Without intent, implementers make technically correct but misaligned decisions.

Design Layer

Defines observable behaviors and boundaries:

ElementRoleFormatCore
System boundaryWhat's inside vs outsideSee Boundary types
User journeysTask flows achieving impactsContext → Action → Outcome
InterfacesContracts between internal modules-
PresenterHow system presents to usersUI: colors, layout / CLI: output format / API: response structure
BehaviorsOutcomes for each state × operationState + Operation → Result
Error scenariosHow failures are handled-

Boundary types:

TypeDefinesExample
ResponsibilityWhat system does / does not do"Validates input; does not store history"
InteractionInput assumptions / Output guarantees"Assumes authenticated user; Returns JSON only"
ControlWhat system controls / depends on"Controls order state; Depends on payment service"

Consistency Layer

Establishes patterns for uniform implementation (all items enhance quality, none required for minimal spec):

ConceptRoleExample
ContextShared understanding"This is event-driven"
TerminologySame concept uses same name throughout"Order" not "Purchase/Transaction/Request"
PatternRecurring situation → approach"State changes via events"
FormExpected structure"Events have type, payload", "Primary: #FF0000", "Errors to stderr"
ContractInteraction agreement"Handlers must be idempotent"

Weave these into relevant sections rather than listing separately.

Implementation Standards (Optional)

For projects requiring code-level consistency across multiple contributors or extended development periods.

CategoryPurposeExamples
ArchitectureModule boundaries and dependenciesClean Architecture, Hexagonal, Layered
Design PatternsReusable solutionsRepository, Factory, Strategy
Testing StyleTest structure and conventionsGiven-When-Then, Arrange-Act-Assert
Code OrganizationDirectory structure and namingFeature-based, layer-based, naming conventions

When to include:

  • Multiple contributors work on the codebase
  • Development spans extended periods
  • Codebase requires shared conventions

When to skip:

  • Simple scripts or single-file utilities
  • Prototypes or proof-of-concept
  • Short-lived projects

Layer Selection Guide

Project CharacteristicIntentDesignConsistencyImplementation Standards
Solo prototypeCore onlyCore onlySkipSkip
Small team (2-5)FullFullTerminology + PatternsOptional
Multi-teamFullFullFullRecommended
External API / Public contractFullFullFullRequired

Element Completeness Guide

Design ElementWhen to IncludeWhen to Skip
System boundaryExternal dependencies existSelf-contained utility
User journeysMultiple user-facing flowsSingle-purpose tool
InterfacesMultiple internal modulesMonolithic implementation
PresenterUser-facing output mattersInternal service
BehaviorsAlways (Core)Never skip
Error scenariosAlways (Core)Never skip

Completion Rubric

Before Applying Framework

CriterionPassFail
Scope understandingKnow what the system doesScope unclear
Layer necessity evaluatedDetermined which layers needed per project typeBlindly applying all layers
Existing content assessedReviewed any existing spec contentStarting without context

During Application

CriterionPassFail
Intent before DesignIntent layer completed before Design detailsDesign written without Intent
Core elements presentAll Core-marked elements addressedCore elements missing
Boundaries explicitSystem boundaries clearly definedBoundaries implied or missing
Layer selection justifiedLayer depth matches project characteristicOver/under-layered for context

After Application

CriterionPassFail
Intra-layer consistencyElements within each layer do not contradictInternal contradictions
Cross-layer alignmentDesign serves Intent; Consistency supports DesignLayers misaligned
Element completenessIncluded elements fully specifiedPartial elements left incomplete