Moonspec specify

From MoonLadderStudios/MoonMind · View interactive version

Moonspec specify is an AI agent skill from the GitHub repository MoonLadderStudios/MoonMind. Create or update a MoonSpec feature specification from a natural language feature request or referenced declarative design. Use when the user asks to run or reproduce `/moonspec.specify`, create a `spec.md`, initialize a feature directory under `specs/`, preserve the original feature request for lat

How to use this skill

Skill file

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:

Do not use this skill to split a broad design into multiple specs; use /moonspec.breakdown for that.

Inputs

Intent And Source Designs

Before creating artifacts, classify the request:

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.

  1. Resolve the referenced path relative to the repo root unless the path is absolute.
  2. Read the source artifact before drafting the spec.
  3. Extract only concrete, testable source requirements:
  1. 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, assign CLAIM-001, CLAIM-002, and so on within the generated packet; do not treat line numbers as stable IDs.
  2. Assign source requirement IDs: DESIGN-REQ-001, DESIGN-REQ-002, and so on. Link each DESIGN-REQ-* to its stable claim ID, or state why no stable source claim applies.
  3. 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.breakdown when the goal is to extract stories from a broader technical or declarative design.
  4. 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.
  5. Record the packet in spec.md immediately below **Input** as ## Source Packet. Include:
  1. 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:

  1. If .specify/extensions.yml exists, read it and look for hooks.before_specify.
  2. If the YAML cannot be parsed or is invalid, skip hook checking silently.
  3. Ignore hooks where enabled is explicitly false; hooks without enabled are enabled.
  4. Do not evaluate non-empty condition expressions. Treat hooks with no condition, null condition, or empty condition as executable. Skip hooks with non-empty conditions.
  5. For each executable hook:
## Extension Hooks

**Optional Pre-Hook**: {extension}
Command: `/{command}`
Description: {description}

Prompt: {prompt}
To execute: `/{command}`
## 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:

Resolve SPECIFY_FEATURE_DIRECTORY:

  1. If the user explicitly provided SPECIFY_FEATURE_DIRECTORY through arguments, environment, or configuration, use it as-is.
  2. Otherwise create one under specs/:

Create artifacts:

{
  "feature_directory": "<resolved feature dir>"
}

Important constraints:

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:

  1. Extract actors, actions, data, constraints, and user value.
  2. Make informed guesses from context, industry standards, and common patterns.
  3. Add [NEEDS CLARIFICATION: specific question] only when:
  1. Use at most 3 clarification markers, prioritized as scope > security/privacy > user experience > technical details.
  2. Fill one ## User Story - ... section with:
  1. If no independently testable story can be derived, stop with: ERROR "Cannot determine a single independently testable story".
  2. Generate testable functional requirements.
  3. Document assumptions in ## Assumptions only when assumptions are used; remove the section if no assumptions were made.
  4. For source-backed requests, add ## Source Design Requirements with:
  1. Ensure every in-scope DESIGN-REQ-* maps to at least one functional requirement.
  2. Define measurable, technology-agnostic success criteria.
  3. Include key entities only if the feature involves data.
  4. Apply the intent guard:

Guidelines:

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:

  1. List failing items and specific issues.
  2. Update the spec to fix them.
  3. Re-run validation.
  4. Repeat up to 3 iterations.
  5. If still failing, document remaining issues in checklist notes and warn the user.

Clarifications

If [NEEDS CLARIFICATION] markers remain:

  1. Extract all markers.
  2. If more than 3 exist, keep only the 3 most critical and make informed guesses for the rest.
  3. Present all clarification questions together before waiting.
  4. 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:

Success Criteria Guidance

Success criteria must be:

Good examples:

Bad examples:

Outputs

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:

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:

## Extension Hooks

**Optional Hook**: {extension}
Command: `/{command}`
Description: {description}

Prompt: {prompt}
To execute: `/{command}`
## Extension Hooks

**Automatic Hook**: {extension}
Executing: `/{command}`
EXECUTE_COMMAND: {command}

If no hooks are registered or .specify/extensions.yml does not exist, skip silently.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.