MoonSpec Plan
Use this skill after a feature spec exists and the user wants implementation planning artifacts for exactly one independently testable story.
When To Use
Use this skill when the user wants to:
- Run or reproduce
/moonspec.plan. - Create or update a feature
plan.md. - Generate
research.md,data-model.md,contracts/, orquickstart.md. - Resolve technical unknowns before task generation.
- Define unit and integration testing strategy for a single-story MoonSpec.
- Determine, from the current repo, whether each in-scope requirement needs code changes, tests only, or no new work.
Do not use this skill to create a spec from a request. Use moonspec-specify or moonspec-breakdown first.
Inputs
- Treat the user's text as optional planning guidance.
- Work from the active feature directory resolved by the setup script.
- The feature spec must contain exactly one independently testable user story.
- If the spec is missing, contains multiple user stories, or has unresolved story-critical clarifications after research, stop with an error.
- Use absolute paths in reports.
- Treat
spec.mdas the desired behavior contract. Do not remove a requirement from the story because similar behavior already exists in the codebase. plan.mdand its design artifacts are imperative, temporary execution artifacts (seedocs/Workflows/MoonSpecDocumentModel.md). Never copy their content into canonicaldocs/files.
Pre-Plan Hooks
Before setup, check for extension hooks:
- If
.specify/extensions.ymlexists, read it and look forhooks.before_plan. - 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 no hooks are registered or .specify/extensions.yml does not exist, skip silently.
Setup
Run the setup script from the repository root and parse its JSON output:
.specify/scripts/bash/setup-plan.sh --json
Parse:
FEATURE_SPECIMPL_PLANSPECS_DIRBRANCHHAS_GIT
The setup script creates the feature directory when needed and copies templates/plan-template.md to IMPL_PLAN.
For shell arguments containing single quotes, use shell-safe escaping such as 'I'\''m Groot', or double quotes when possible.
Load Context
Read:
FEATURE_SPECartifacts/moonspec/source-acceptance.jsonandartifacts/moonspec/acceptance-assessment.jsonwhen present and theirfeatureIdmatches the active feature. TreatVERIFIEDsource acceptance rows as regression constraints and use the matching assessment backlog for planned work.AGENTS.mdwhen present, especially project principles, testing discipline, and repo constraintsIMPL_PLAN- Relevant implementation files, tests, contracts, fixtures, migrations, and public interfaces for the story
Validate before planning:
FEATURE_SPEChas exactly one## User Story - ...section.- The story has a Summary, Goal, Independent Test, Acceptance Scenarios, Requirements, and Success Criteria.
- Source design mappings such as
DESIGN-REQ-*are preserved when present. - Source packet provenance is preserved when present: source document path, document class, viewpoint, owning surface, stable claim IDs, temporary-adapter role, and issue traceability such as
MM-933/MM-927. - Relevant
AGENTS.mdprinciples, testing discipline, andMUSTconstraints are reflected in the plan when present. - In-scope requirement IDs and scenario IDs can be identified for planning and traceability.
Fill plan.md
Follow templates/plan-template.md structure and preserve its headings.
Fill:
Branch,Date, andSpecInputas the single-story spec pathSummary: primary requirement, technical approach, test strategy, and repo gap-analysis outcomeTechnical Context:- Language/version
- Primary dependencies
- Storage
- Unit testing tool
- Integration testing tool
- Target platform
- Project type
- Performance goals
- Constraints
- Scale/scope
Principles Check: derive relevant checks fromAGENTS.mdproject principles, testing discipline, and repo constraints when presentProject Structure: replace placeholder trees with the actual repository layout for the featureComplexity Tracking: fill only when principle conflicts or unjustified complexity must be justified
Add a ## Requirement Status section after ## Summary with one row per in-scope item that materially affects delivery:
- stable source claim IDs from
## Source Packet, such asCLAIM-*,DESIGN-REQ-*, orDOC-REQ-* FR-*- acceptance scenarios or
SCN-* - measurable success criteria or
SC-*when they drive implementation or testing - in-scope
DESIGN-REQ-*orDOC-REQ-*
Use this table shape:
| ID | Status | Evidence | Planned Work | Required Tests |
| -------------- | ---------------------- | --------------------------- | ---------------------------- | ------------------------ |
| FR-001 | missing | none found | add code and tests | unit + integration |
| SCN-001 | implemented_unverified | src/..., no scenario test | add verification tests first, with implementation contingency if they fail | integration |
| SC-002 | unverified | reason: GPU unavailable; verifiableBy: GPU CI | disclosure only | none |
| DESIGN-REQ-004 | implemented_verified | src/..., tests/... | no new implementation | none beyond final verify |
When a row originates from a stable source claim, include the claim ID in the ID cell or in the evidence text so /moonspec.tasks can map every implementation task back to stable claim provenance. If no stable source claim applies, write No stable source claim applies: <reason> in the evidence text.
Allowed Status values:
needs_human: non-executable actual authority handoff; preserve the source ID and exact decision, owner, and action. It takes precedence overunverifiedand missing-work defaults; do not create executable or fallback tasks for the affected action. Continue independent authorized work, but do not claim the dependent operation complete.missing: no adequate implementation evidence foundpartial: some implementation exists, but the requirement is not fully satisfiedunverified: disclosure-only criterion whose check remains unavailable under the shared acceptance policyimplemented_unverified: behavior appears present and verification is feasible, but required proof is missing or insufficientimplemented_verified: behavior is already present and sufficiently covered by existing tests or other evidence
Unverified criteria are disclosure-only. Normalize issue-brief unverifiable and source-matrix UNVERIFIED to unverified, retaining the source ID and nonblank unverified.reason and unverified.verifiableBy (reason and verifiableBy in the plan table). This status takes precedence over implemented_unverified when the check remains outside the verifier's capabilities, access, or time after reasonable attempts. It creates no test, verification, or fallback implementation tasks, even for required criteria. Do not infer missing implementation from unavailable evidence. Observed defects still require remediation; classify those separately as missing, partial, or conflicting implementation work. Actual permission needed to perform an action uses needs_human, never an Unverified evidence waiver.
Rules:
- Existing code changes planned work, not story scope.
- For feasible checks, prefer
implemented_unverifiedoverimplemented_verifiedunless current evidence is strong; apply theunverifiedexception first. - Do not mark
implemented_verifiedunless the current code and current tests together satisfy the requirement and its acceptance evidence. - When uncertain, do not use
implemented_verified.
Mark technical unknowns as NEEDS CLARIFICATION only when they block defensible planning and cannot be resolved from the repo, spec, or conventional project patterns.
Principles Check
Evaluate relevant AGENTS.md principles, testing discipline, and repo constraints before Phase 0 research.
Rules:
- Error on unjustified principle conflicts.
- Record justified conflicts in
Complexity Trackingwith the reason and mitigation. - Do not continue with unresolved hard gate failures.
- Re-check relevant principles after Phase 1 design artifacts are generated.
Phase 0: Research And Repo Gap Analysis
Generate research.md in SPECS_DIR.
Research and resolve:
- Every
NEEDS CLARIFICATIONfromTechnical Context - Dependency choices and best practices
- Integration patterns
- Test tooling choices, with unit and integration test tools identified separately
- Any source design or repo-principle constraint that affects architecture
- Current repo coverage for each in-scope requirement or scenario
For each in-scope item, inspect relevant code and tests, then classify it:
needs_human-> preserve the authority handoff without executable tasksunverified-> disclosure only; preserve source ID, reason and verifiableBy without executable workmissing-> requires tests and implementationpartial-> requires tests and implementation changesimplemented_unverified-> requires tests or verification first, plus an explicit implementation contingency to execute if verification exposes a gapimplemented_verified-> requires no new implementation work, but must remain traceable in the plan and final verification
Use this format for each topic in research.md:
## [Topic or Requirement ID]
Decision: [choice, status, and/or planned work]
Evidence: [relevant file paths, tests, or contracts]
Rationale: [why this choice or status was chosen]
Alternatives considered: [what else was evaluated]
Test implications: [unit, integration, both, or none beyond final verify]
After research.md is complete:
- Update
plan.mdso no unresolved planningNEEDS CLARIFICATIONremains. - Update
## Requirement Statusto match the research. - Keep all in-scope requirements visible even when already implemented.
Phase 1: Design And Contracts
Generate design artifacts in SPECS_DIR:
data-model.md: entities, fields, relationships, validation rules, and state transitions when the story involves datacontracts/: public interfaces the project exposes to users or other systemsquickstart.md: test-first validation scenarios and commands for the planned implementation
Contract guidance:
- Use the contract format appropriate for the project type.
- Examples include API contracts, CLI command schemas, library public API specs, parser grammars, UI interaction contracts, or event/message contracts.
- Skip
contracts/only when the feature is purely internal and has no meaningful public or integration surface.
Quickstart guidance:
- Include unit/integration commands and required setup only for executable checks; use N/A for disclosure-only rows.
- Describe how to verify the single story end to end.
- Reflect requirement status decisions:
needs_human: authority handoff only; no action before permissionunverified: disclosure only; no runnable check or implementation contingencymissingandpartial: tests first, then implementationimplemented_unverified: verification tests first, then a planned implementation contingency if those tests failimplemented_verified: final verification only unless the user asks for stronger coverage
Agent Context
Keep feature technology and status in plan.md. Routine planning must not change
lasting repository guidance. The agent context script is a no-op by default.
Only when the user explicitly requests a lasting guidance edit, run:
.specify/scripts/bash/update-agent-context.sh --write __AGENT__
Replace __AGENT__ with the active integration key when known. If unknown, omit
the agent argument to update existing agent files. The --write flag records the
explicit request; it is not a routine planning prerequisite.
An authorized update must preserve manual additions, symlink targets and existing
file permissions. The script never creates or updates AGENTS.md from plan data, including through
an alias. Any explicitly requested repository-policy edit belongs in a separate,
intentional guidance change; a plan template cannot supply that policy. Report any update failure rather than claiming the
context was recorded.
Stop Point
This skill stops after planning and design artifacts. Do not generate tasks.md or implementation code.
Report:
- Branch
IMPL_PLANpath- Generated artifacts
- Unit test strategy
- Integration test strategy
- Principles check result
- Requirement status summary by ID and count
- Which items need code changes
- Which items need tests only
- Which items are already verified or disclosure-only
- Readiness for
/moonspec.tasks
Post-Plan Hooks
After reporting, check .specify/extensions.yml for hooks.after_plan using the same parsing, filtering, and condition rules as pre-plan 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.
Key Rules
- Use absolute paths.
- Plan exactly one user story.
- Keep TDD as the default strategy.
- Identify unit and integration testing separately.
- Use
planto decide whether work is code + tests, tests only, or no new implementation. - Existing code never removes a requirement from
spec.md; it only changes the planned work. - Apply disclosure-only
unverifiedstatus before executable planning. For feasible checks, prefer verification tests before implementation when behavior appears to already exist, with fallback implementation work forimplemented_unverifieditems only if verification fails. - Resolve all planning clarifications through
research.md. - Error on unjustified principle conflicts, multiple user stories, or unresolved clarifications.
- Generate design artifacts only; leave task generation to
/moonspec.tasks. tasks.mdshould consume## Requirement Statuswhen deciding whether to emit implementation tasks, verification-only tasks, or disclosure-onlyunverifiedrows and no new work for already-verified items.