MoonSpec Specify
Use this skill to perform the MoonSpec specify workflow.
When To Use
Use this skill when the user wants to create or update a MoonSpec spec.md from:
- A natural language feature request.
- A referenced declarative design, contract, or source requirements document.
- A request to run or reproduce
/moonspec.specify.
Do not use this skill to split a broad design into multiple specs; use /moonspec.breakdown for that.
Inputs
- Treat the user's request text as the feature description.
spec.mdis a temporary execution artifact and downstream adapter derived from the request or its canonical source document. It is never the source of truth for desired state (seedocs/Workflows/MoonSpecDocumentModel.md).- Do not ask the user to repeat the request unless it is empty or no independently testable story can be derived.
- If the feature description is empty, stop with:
ERROR "No feature description provided". - Preserve the original feature description verbatim in the generated spec's
**Input**field. Do not summarize or normalize it;/moonspec.verifyrelies on this source request. - If the request references a source design file, contract, or declarative design artifact, resolve and read it before generating the spec.
- Default the intent to implemented system behavior. Use documentation-only intent only when the user explicitly asks for docs-only or documentation alignment work.
Intent And Source Designs
Before creating artifacts, classify the request:
runtime: The spec should describe behavior the product/system must implement and validate. This is the default.docs: The spec should describe documentation changes only. Use this only when the user explicitly asks for docs-only output.
If the prompt says to implement, build, support, or verify behavior described by a document, treat the document as source requirements for runtime intent, not as the implementation target.
For source-backed requests:
Read the resolved moonspec-verify/references/acceptance-policy.md before
extracting requirements. Preserve source conditions, optionality, and nonblocking
evidence exceptions in every derived requirement and acceptance scenario. Do not
turn reporting an external claim into commissioning its verification, or add a
mandatory acceptance gate from an assumption or a proposed diagnostic.
- Resolve the referenced path relative to the repo root unless the path is absolute.
- Read the source artifact before drafting the spec.
- Extract only concrete, testable source requirements:
- Normative terms such as must, shall, required, forbidden, cannot, should when used as a requirement.
- Behavior tables, acceptance criteria, invariants, limits, failure handling, and compatibility constraints.
- Explicit non-goals or exclusions that constrain scope.
- Build a source packet from the source artifact. Record the source document path, document class, viewpoint, owning surface, stable claim IDs, and source issue traceability when present. For canonical docs, derive viewpoint and owning surface from the document metadata header,
docs/DocumentationArchitecture.md, file path, title, and authority text. If the source already has stable IDs, preserve them. If a concrete source claim has no stable ID, assignCLAIM-001,CLAIM-002, and so on within the generated packet; do not treat line numbers as stable IDs. - Assign source requirement IDs:
DESIGN-REQ-001,DESIGN-REQ-002, and so on. Link eachDESIGN-REQ-*to its stable claim ID, or state why no stable source claim applies. - If the source artifact contains multiple independent stories, do not collapse them into one spec. Ask the user to choose one story, or direct them to
/moonspec.breakdownwhen the goal is to extract stories from a broader technical or declarative design. - If a source requirement is intentionally out of scope for the selected story, keep it in the source mapping as out of scope with a short rationale. Do not silently drop it.
- Record the packet in
spec.mdimmediately below**Input**as## Source Packet. Include:
**Artifact Role**: state thatspec.mdis a temporary adapter derived from the canonical request or source document, not authoritative desired state.**Source Document**: repo-relative source path, ororiginal request onlywhen no document exists.**Document Class**: perdocs/Workflows/MoonSpecDocumentModel.md.**Viewpoint**: canonical documentation viewpoint, ornonewith reason.**Owning Surface**: authority scope, module, feature, contract surface, ornonewith reason.**Stable Claim IDs**: existing source claim IDs and generatedCLAIM-*IDs used by the selected story, ornonewith reason.**Source Issue Traceability**: preserve issue lineage such asMM-933and source issueMM-927when present.- When the request comes from a
moonspec-breakdownstory whosesourceReferencecontains stable canonicalclaimIds, list those claim IDs exactly as supplied in**Stable Claim IDs**and keep the generatedDESIGN-REQ-*mapping in the Source Design Requirements section.
- When the current task explicitly authorizes a change to behavior described by an existing document, carry that change into the spec and identify the required in-place documentation correction as ordinary implementation work. For a conflict whose scope or authority remains unresolved by the task and applicable
AGENTS.md, flag the concrete decision with[NEEDS CLARIFICATION]; do not silently choose either side or request approval already supplied by the task.
Complete source reading, requirement extraction, and single-story selection before creating the feature directory.
Pre-Spec Hooks
Before creating the spec, check for extension hooks:
- If
.specify/extensions.ymlexists, read it and look forhooks.before_specify. - If the YAML cannot be parsed or is invalid, skip hook checking silently.
- Ignore hooks where
enabledis explicitlyfalse; hooks withoutenabledare enabled. - Do not evaluate non-empty
conditionexpressions. Treat hooks with no condition, null condition, or empty condition as executable. Skip hooks with non-empty conditions. - For each executable hook:
- Optional hook (
optional: true): print:
## Extension Hooks
**Optional Pre-Hook**: {extension}
Command: `/{command}`
Description: {description}
Prompt: {prompt}
To execute: `/{command}`
- Mandatory hook (
optional: false): print:
## Extension Hooks
**Automatic Pre-Hook**: {extension}
Executing: `/{command}`
EXECUTE_COMMAND: {command}
Wait for the result of the hook command before proceeding to the Outline.
If a successful before_specify hook created or switched branches and returns BRANCH_NAME or FEATURE_NUM, keep them for reference only. The branch name does not determine the spec directory name. If the user explicitly provides GIT_BRANCH_NAME, pass it to the hook unchanged.
Create Feature Directory
Generate a short name first:
- Use 2-4 words.
- Prefer action-noun style:
add-user-auth,oauth2-api-integration,analytics-dashboard,fix-payment-timeout. - Preserve meaningful technical terms and acronyms.
Resolve SPECIFY_FEATURE_DIRECTORY:
- If the user explicitly provided
SPECIFY_FEATURE_DIRECTORYthrough arguments, environment, or configuration, use it as-is. - Otherwise create one under
specs/:
- Read
.specify/init-options.jsonif present. - If
branch_numberingis"timestamp", use prefixYYYYMMDD-HHMMSS. - If
branch_numberingis"sequential"or absent, use the next available 3-digit prefix after scanning existing directories inspecs/. - Directory name is
<prefix>-<short-name>, for example003-user-auth.
Create artifacts:
- Create
SPECIFY_FEATURE_DIRECTORY. - Copy
templates/spec-template.mdtoSPECIFY_FEATURE_DIRECTORY/spec.md. - Set
SPEC_FILEto thatspec.md. - Write
.specify/feature.jsonwith the actual resolved feature directory path:
{
"feature_directory": "<resolved feature dir>"
}
Important constraints:
- Create only one feature per invocation.
- Generate exactly one user story in the spec.
- Do not generate P1/P2/P3 stories or multiple story sections.
- If the input describes multiple independent stories, choose the primary story only when obvious and record the rest as out of scope; otherwise ask for clarification or direct the user to
/moonspec.breakdownwhen starting from a technical or declarative design. - If the request is too ambiguous to identify one independently testable story, ask one targeted question before creating files.
- The spec directory name and git branch name are independent.
- The spec directory and file are created by this workflow, not by hooks.
- Do not use legacy branch-numbering logic to determine the feature directory.
.specify/feature.jsonis the downstream locator.
Generate The Spec
Load templates/spec-template.md and preserve its section order and headings. For source-backed requests only, add ## Source Design Requirements after ## Assumptions when that section is present; otherwise place it immediately before ## Requirements.
Fill the template with concrete details derived from the feature description:
- Extract actors, actions, data, constraints, and user value.
- Make informed guesses from context, industry standards, and common patterns.
- Add
[NEEDS CLARIFICATION: specific question]only when:
- The choice significantly impacts scope, security/privacy, or user experience.
- Multiple reasonable interpretations exist with different implications.
- No reasonable default exists.
- Use at most 3 clarification markers, prioritized as scope > security/privacy > user experience > technical details.
- Fill one
## User Story - ...section with:
SummaryGoalIndependent TestAcceptance ScenariosEdge Cases
- If no independently testable story can be derived, stop with:
ERROR "Cannot determine a single independently testable story". - Generate testable functional requirements.
- Document assumptions in
## Assumptionsonly when assumptions are used; remove the section if no assumptions were made. - For source-backed requests, add
## Source Design Requirementswith:
- Requirement ID.
- Stable claim ID from
## Source Packet, or an explicitNo stable source claim applies: <reason>entry. - Source citation such as heading, table name, or line number when available.
- Requirement summary in testable, implementation-agnostic language.
- Scope status: in scope or out of scope with rationale.
- Mapped functional requirement ID after functional requirements are generated.
- Ensure every in-scope
DESIGN-REQ-*maps to at least one functional requirement. - Define measurable, technology-agnostic success criteria.
- Include key entities only if the feature involves data.
- Apply the intent guard:
- For
runtimeintent, the spec must describe observable system behavior and validation outcomes, not merely edits to documentation. - For
docsintent, the spec may describe documentation outcomes, but still keep requirements testable and acceptance-based.
Guidelines:
- Focus on what users need and why.
- Avoid how to implement it: no tech stack, APIs, code structure, frameworks, or databases.
- Write for business stakeholders, not developers.
- Remove optional sections when irrelevant instead of writing
N/A. - Do not embed checklists in the spec.
- Keep source requirement mappings traceable without introducing implementation details.
Quality Checklist
After writing the initial spec, create SPECIFY_FEATURE_DIRECTORY/checklists/requirements.md:
# Specification Quality Checklist: [FEATURE NAME]
**Purpose**: Validate specification completeness and quality before proceeding to planning
**Created**: [DATE]
**Feature**: [Link to spec.md]
## Content Quality
- [ ] No implementation details (languages, frameworks, APIs)
- [ ] Focused on user value and business needs
- [ ] Written for non-technical stakeholders
- [ ] All mandatory sections completed
## Requirement Completeness
- [ ] No [NEEDS CLARIFICATION] markers remain
- [ ] Exactly one user story is defined
- [ ] Requirements are testable and unambiguous
- [ ] Runtime intent describes system behavior rather than docs-only changes, unless docs-only was explicitly requested
- [ ] Success criteria are measurable
- [ ] Success criteria are technology-agnostic (no implementation details)
- [ ] All acceptance scenarios are defined
- [ ] Independent Test describes how the story can be validated end-to-end
- [ ] Acceptance scenarios are concrete enough to derive unit and integration tests
- [ ] No in-scope source design requirements are unmapped from functional requirements
- [ ] Spec does not contradict its canonical source document, or contradictions are explicitly flagged
- [ ] Edge cases are identified
- [ ] Scope is clearly bounded
- [ ] Dependencies and assumptions identified
## Feature Readiness
- [ ] All functional requirements have clear acceptance criteria
- [ ] The single user story covers the primary flow
- [ ] Feature meets measurable outcomes defined in Success Criteria
- [ ] No implementation details leak into specification
## Notes
- Items marked incomplete require spec updates before `/moonspec.plan`
Validate the spec against every checklist item. Mark passing items complete. For failures, quote the relevant spec section in the notes.
If checklist items fail for reasons other than clarification markers:
- List failing items and specific issues.
- Update the spec to fix them.
- Re-run validation.
- Repeat up to 3 iterations.
- If still failing, document remaining issues in checklist notes and warn the user.
Clarifications
If [NEEDS CLARIFICATION] markers remain:
- Extract all markers.
- If more than 3 exist, keep only the 3 most critical and make informed guesses for the rest.
- Present all clarification questions together before waiting.
- Use this format for each question:
## Question [N]: [Topic]
**Context**: [Quote relevant spec section]
**What we need to know**: [Specific question from NEEDS CLARIFICATION marker]
**Suggested Answers**:
| Option | Answer | Implications |
|--------|--------|--------------|
| A | [First suggested answer] | [What this means for the feature] |
| B | [Second suggested answer] | [What this means for the feature] |
| C | [Third suggested answer] | [What this means for the feature] |
| Custom | Provide your own answer | [Explain how to provide custom input] |
**Your choice**: _[Wait for user response]_
After the user responds, replace each marker with the selected answer and re-run validation.
Reasonable Defaults
Do not ask for clarification when a safe, conventional default is available. Record the assumption instead.
Examples:
- Data retention: use domain-standard retention unless the request specifies legal or policy constraints.
- Error handling: require user-visible, recoverable failures where applicable.
- Performance: use normal product expectations unless the request names a threshold.
- Authentication: use the project's established auth pattern if one exists.
- Integration style: use the project's existing interface patterns rather than inventing a new one.
Success Criteria Guidance
Success criteria must be:
- Measurable: include time, percentage, count, rate, or similar metrics.
- Technology-agnostic: no frameworks, languages, databases, or tools.
- User-focused: describe user or business outcomes rather than internals.
- Verifiable: testable without knowing implementation details.
Good examples:
Users can complete checkout in under 3 minutesSystem supports 10,000 concurrent users95% of searches return results in under 1 secondTask completion rate improves by 40%
Bad examples:
API response time is under 200msDatabase can handle 1000 TPSReact components render efficientlyRedis cache hit rate above 80%
Outputs
SPECIFY_FEATURE_DIRECTORY/spec.mdSPECIFY_FEATURE_DIRECTORY/checklists/requirements.md.specify/feature.jsonpointing to the active feature directory- Source design mapping in
spec.mdwhen the request is source-backed
Source Acceptance Matrix
When the request is backed by a source document, issue, or external acceptance record, write artifacts/moonspec/source-acceptance.json using "schemaVersion": "v1" and a featureId that matches the active feature directory. Preserve source rows such as SRC-AC-*, implementation surfaces such as SRC-SURFACE-*, negative constraints such as SRC-NEG-*, and expected tests such as SRC-TEST-*. Mark rows with repoVerifiable: false when they require manual, provider, or external evidence, and include statusHint only as advisory input for assessment.
Report And Post-Spec Hooks
Report completion with:
SPECIFY_FEATURE_DIRECTORYSPEC_FILE- Checklist results summary
- Intent classification and source design mapping summary, when applicable
- Readiness for
/moonspec.plan
After reporting, check .specify/extensions.yml for hooks.after_specify using the same parsing, filtering, and condition rules as pre-spec hooks. For each executable hook:
- Optional hook (
optional: true): print:
## Extension Hooks
**Optional Hook**: {extension}
Command: `/{command}`
Description: {description}
Prompt: {prompt}
To execute: `/{command}`
- Mandatory hook (
optional: false): print:
## Extension Hooks
**Automatic Hook**: {extension}
Executing: `/{command}`
EXECUTE_COMMAND: {command}
If no hooks are registered or .specify/extensions.yml does not exist, skip silently.