MoonSpec Tasks
Use this skill to generate an executable tasks.md for one MoonSpec story.
Scope
Generate task artifacts only. Do not implement application code, run the implementation, create issues, or split broad designs. Use moonspec-breakdown for broad technical or declarative designs, moonspec-specify for creating a one-story spec, and moonspec-plan for planning artifacts.
The generated task list must:
- Cover exactly one independently testable story from
spec.md. - Follow TDD by default.
- For executable implementation work, include applicable unit and integration tests with red-first confirmation before production code.
- Preserve traceability to the original request or source design preserved in
spec.md. - Carry forward docs-native packet provenance from
spec.md: source document path, document class, viewpoint, owning surface, stable claim IDs, temporary-adapter role, and source issue traceability such asMM-933/MM-927. - Include final
/moonspec.verifywork after any executable work finishes; it validates evidence and disclosures, not unavailable checks.
tasks.md is an imperative, temporary execution artifact (see docs/Workflows/MoonSpecDocumentModel.md). Never copy its content into canonical docs/ files.
Inputs
- Treat the user's text as optional task-generation guidance.
- Work from the active feature directory resolved by the prerequisite script.
- Require
spec.mdandplan.md. - Use
templates/tasks-template.mdas the output structure. - Use absolute paths in reports.
Stop if spec.md is missing, plan.md is missing, or the spec contains more than one user story. Tell the user to run /moonspec.breakdown for broad designs or /moonspec.specify for a one-story replacement.
Pre-Tasks Hooks
Before generating tasks, check for extension hooks:
- If
.specify/extensions.ymlexists, read it and look forhooks.before_tasks. - 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 task generation.
If no hooks are registered or .specify/extensions.yml does not exist, skip silently.
Setup
Run the prerequisite script from the repository root:
.specify/scripts/bash/check-prerequisites.sh --json
Parse FEATURE_DIR and AVAILABLE_DOCS, then derive:
SPEC = FEATURE_DIR/spec.mdPLAN = FEATURE_DIR/plan.mdTASKS = FEATURE_DIR/tasks.md- optional docs from
AVAILABLE_DOCS REPO_GUIDANCE = AGENTS.mdwhen present
If shell arguments contain single quotes, use shell-safe escaping such as 'I'\''m Groot', or double quotes when possible.
Load Context
Read:
plan.md: tech stack, libraries, project structure, unit test tooling, integration test tooling, constraints, validation commands, and any## Requirement Statustable.spec.md: preserved**Input**,## Source Packet, single user story, goal, independent test, acceptance scenarios, edge cases, functional requirements, success criteria, assumptions, and source design mappings such asCLAIM-*,DESIGN-REQ-*orDOC-REQ-*.AGENTS.mdwhen present: project principles, repo constraints, and test discipline.data-model.mdwhen present: entities, relationships, validation rules, and state transitions.contracts/when present: public interfaces and contract or integration test obligations.research.mdwhen present: technical decisions that affect setup or implementation tasks.quickstart.mdwhen present: validation commands and end-to-end scenarios.specs/breakdown.mdwhen present: source design coverage and cross-spec dependency context.
Source Acceptance Coverage
Use the matching assessment and plan to separate executable work from disclosure-only rows before generating tasks. Missing, partial, or conflicting implementation needs tests and remediation. Apply the status rules below to all source rows, including negative constraints.
Build a traceability inventory before writing tasks:
- One row per
FR-*. - One row per acceptance scenario or
SCN-*. - One row per meaningful edge case.
- One row per measurable success criterion or
SC-*. - One row per in-scope stable source claim ID from
## Source Packet, such asCLAIM-*,DESIGN-REQ-*orDOC-REQ-*. - One row per relevant AGENTS.md principle, repo constraint, or testing-discipline requirement that affects implementation or testing.
For each row, carry forward the matching ## Requirement Status entry from plan.md when present. Allowed statuses are needs_human, missing, partial, unverified, implemented_unverified, and implemented_verified; apply assessment disclosure precedence before treating an otherwise unclassified row as missing.
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. When every row is unverified, retain disclosures and the final report verification task only; do not create setup, test-tool installation, red-first, implementation, or polish work. 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.
Status handling:
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.
unverified: disclosure-only; preserve source ID, reason and verifiableBy outside executable tasks and the remediation backlog.
missing: generate failing unit and/or integration test tasks, red-first confirmation tasks, and implementation tasks.partial: generate failing tests for the missing behavior, red-first confirmation tasks, and implementation tasks that complete the requirement.implemented_unverified: generate verification tests first, red-first confirmation tasks when the expected behavior is not already covered, and explicit fallback implementation tasks to run if verification fails.implemented_verified: do not generate new implementation tasks by default, but preserve traceability and include final validation so the existing evidence remains checked.
Each executable inventory row needs task coverage appropriate to its status and either unit or integration test coverage unless it is implemented_verified with strong existing evidence. For executable rows, acceptance scenarios, external boundaries, workflows, persistence, contracts, CLI/API/UI behavior, and service interactions require integration test coverage unless the spec clearly makes integration irrelevant or the row is already implemented_verified by existing integration evidence.
Generate tasks.md
Create or replace FEATURE_DIR/tasks.md using templates/tasks-template.md. Preserve the template's headings. Remove unused sample tasks; populate only work required by executable rows and final report verification.
Fill:
- Feature name.
- Input paths.
- Prerequisites.
- Applicable unit/integration test commands, or N/A when no executable checks are planned.
- Source traceability summary.
- Source packet summary: source document path, viewpoint, owning surface, stable claim IDs, temporary-adapter role, and source issue traceability when present.
- Story summary.
- Independent test.
- Story traceability IDs.
- Applicable unit/integration test plan, or N/A for disclosure-only work.
- Task phases.
- Dependencies and execution order.
- Parallel examples.
- Implementation strategy.
When plan.md includes ## Requirement Status, reflect those statuses in the source traceability summary and implementation strategy. The task list must distinguish code-and-test work, verification-only work, contingency implementation work, already-verified rows, and disclosure-only rows.
The output must be immediately executable by an LLM without extra context.
Task Format
Every generated task must use this exact checklist shape:
- [ ] [TaskID] [P?] Description with file path
Rules:
- Start every task with
- [ ]. - Use sequential task IDs:
T001,T002,T003, and so on. - Use
[P]only for tasks that can run in parallel because they touch different files and do not depend on incomplete tasks. - Include exact file paths.
- Include requirement, scenario, or stable source claim IDs when the task implements or validates behavior.
- Every task must map to stable claim IDs from
## Source Packet,DESIGN-REQ-*, orDOC-REQ-*, or stateNo source claim applies: <reason>in the task description. - Do not include story labels such as
[US1]; this task list covers one story.
Good examples:
- [ ] T001 Create project structure in src/ and tests/ per implementation plan
- [ ] T012 [P] Add failing unit test for validation FR-001 in tests/unit/test_user.py
- [ ] T013 [P] Add failing integration test for signup scenario SCN-001 in tests/integration/test_signup.py
- [ ] T014 Implement UserService for FR-001 in src/services/user_service.py
Bad examples:
- [ ] Create User model
T001 Create model
- [ ] [US1] Create User model
- [ ] T010 Write tests later if needed
Task Organization
Use these phase headings, leaving phases with no executable work empty or marked N/A.
Phase 1: Setup
Include project initialization or tool configuration only when executable work needs it:
- Shared project structure.
- Dependency or package configuration.
- Linting and formatting.
- Unit test tooling.
- Integration test tooling.
Phase 2: Foundational
Include only blocking prerequisites for the story:
- Shared infrastructure the story truly depends on.
- Base schema, migrations, fixtures, or seed data.
- Authentication, routing, middleware, configuration, logging, or error handling when required.
- Integration-only runtime dependencies such as Docker, service containers, external emulators, test fixtures, or contract harnesses.
No story implementation work can begin until this phase is complete.
Phase 3: Story
Create exactly one story phase. Include its summary and disclosures; include the following work items only when required by executable rows:
- Story summary.
- Independent test.
- Traceability IDs.
- Applicable unit/integration test plan, or N/A for disclosure-only work.
- Applicable test tasks and red-first confirmations.
- Needed implementation tasks.
- Feasible story validation tasks.
Order applicable executable story work as follows; omit inapplicable steps:
- Unit tests.
- Integration tests.
- Red-first confirmation.
- Fallback implementation tasks for
implemented_unverifiedrows, explicitly conditional on verification failure. - Models or entities.
- Services or domain logic.
- Endpoints, UI, CLI, public API, or contracts.
- Integration wiring.
- Story validation.
Unit and integration tests must be written and confirmed failing before implementation tasks for missing and partial rows. For implemented_unverified rows, verification tests should be run before fallback implementation tasks; if they pass, the fallback implementation tasks are skipped and final verification preserves traceability.
Final Phase: Polish And Verification
Include only work that strengthens the completed story without adding hidden scope:
- Refactoring.
- Documentation.
- Performance tuning.
- Security hardening.
- Additional edge-case coverage.
- Additional operational integration coverage.
- Quickstart validation.
- A final task to run
/moonspec.verifyafter any executable work finishes, preserving Unverified disclosures even when no tests can run; preserve any pendingneeds_humanhandoff.
Coverage Rules
Coverage rules below apply only to executable rows. unverified and needs_human rows of every kind, including acceptance scenarios, public boundaries, negative constraints, contracts, and required checks, remain non-executable; preserve disclosures or authority handoffs rather than generating task coverage or fallback work.
- Each
FR-*with statusmissingorpartialmust map to at least one implementation task and at least one unit or integration test task. - Each
FR-*with statusimplemented_unverifiedmust map to at least one verification test task and one conditional fallback implementation task. - Each
FR-*with statusimplemented_verifiedmust map to existing evidence and a final validation task; do not add implementation work unless the user asks for stronger coverage. - Each acceptance scenario must map to at least one integration test task unless it is
implemented_verifiedby existing integration evidence. - Each source design workflow or public boundary must map to at least one integration test task unless it is
implemented_verifiedby existing integration evidence. - Each source design rule, invariant, edge case, or failure mode must map to at least one unit test task where applicable unless it is
implemented_verifiedby existing unit or integration evidence. - Each explicit non-goal or constraint must map to a guardrail test, validation task, or documented scope check when it affects implementation.
- Each contract must map to a contract or integration test before implementation.
- Each task that validates behavior must name the file path and requirement/scenario/source IDs.
- Each implementation task must name stable claim IDs from
## Source Packet,DESIGN-REQ-*, orDOC-REQ-*, or stateNo source claim applies: <reason>.
Do not generate tasks for future stories, broad refactors, speculative infrastructure, or implementation layers that are not needed by the single story.
Parallelization Rules
Mark a task [P] only when:
- It touches different files from other parallel tasks.
- It has no dependency on incomplete work.
- Its output is not required by another task in the same parallel group.
Safe parallel candidates often include:
- Independent setup config files.
- Different unit test files.
- Different integration test files.
- Independent models.
- Independent documentation or polish tasks.
Do not mark tasks [P] when they modify the same file, share generated artifacts, require ordered red-first confirmation, or depend on a common uncompleted fixture.
Validation
Before reporting, verify:
tasks.mdexists inFEATURE_DIR.- Every task follows
- [ ] T### [P?] Description with file path. - Task IDs are sequential.
- Exactly one story phase exists.
- No P1/P2/P3 or multi-story phases exist.
- When production code tasks exist, applicable test tasks and red-first confirmations precede them.
- Every executable traceability inventory row has task coverage; disclosure-only
unverifiedrows retain their source IDs, reason and verifiableBy without tasks. - Every task maps to stable claim IDs or explicitly explains why none apply.
## Requirement Statusrows fromplan.md, when present, preserveunverifieddisclosures without executable tasks and avoid unnecessary implementation tasks forimplemented_verifiedrows.implemented_unverifiedrows include fallback implementation tasks that are conditional on verification failure.- Final
/moonspec.verifytask exists.
If validation fails, update tasks.md and validate again before reporting.
Report
Report:
tasks.mdpath.- Total task count.
- Task count per phase.
- Parallel opportunities.
- Independent test criteria.
- Source design or original request coverage summary.
- Source packet provenance summary: source document path, viewpoint, owning surface, stable claim IDs, temporary-adapter role, and source issue traceability.
- Requirement status coverage summary, including code-and-test, verification-only, conditional fallback, already-verified, and disclosure-only Unverified counts when
plan.mdprovides statuses. - Unit/integration test coverage and tooling for executable rows, or N/A when none.
- Final verification task status.
- Confirmation that the task list covers exactly one story.
- Format validation result.
Post-Tasks Hooks
After reporting, check .specify/extensions.yml for hooks.after_tasks using the same parsing, filtering, and condition rules as pre-tasks 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
- Generate tasks for one story only.
- Keep TDD as the default strategy.
- Apply unit/integration testing and red-first requirements only to executable work under the status rules above.
- Preserve traceability to
spec.md**Input**and source design mappings. - Preserve docs-native packet provenance from
spec.mdwithout treating generated artifacts as authoritative. - Consume
plan.md## Requirement Statuswhen present so tasks match planned code, verification-only, conditional fallback, already-verified work, or disclosures. - Use concrete file paths and requirement/scenario/stable claim IDs, or explain why no source claim applies.
- Include final
/moonspec.verify. - Do not implement code from this skill.