spec-code — Implement a Single Task from Specs
Autonomously implement one task from the spec documents, understanding the full project context before writing code.
Language Rules
- Auto-detect input language → output in the same language
- Japanese input → Japanese output, use
references/code-guide.ja.md - English input → English output, use
references/code-guide.md - Explicit override takes priority
Options
| Option | Description |
|---|---|
--issue {N} |
GitHub Issue number for context |
--spec {path} |
Path to .specs/ directory |
--task {task-id} |
Task ID to implement (e.g., T-007) |
--feedback {file} |
Feedback mode: read review or test result file and address findings |
Execution Flow
Step 0: Context Loading (Phase A / Phase B)
Phase A — First invocation (full context):
Locate and read workflow (search order:
docs/development/issue-to-pr-workflow.md→docs/→ find):- Identify your role as implementer
- Read Agent definition file if referenced (e.g.,
.claude/agents/workflow-implementer.md)
Read Issue (if
--issueprovided):- Run
gh issue view {N} --json title,bodyto understand the feature overview
- Run
Read all spec files in
--specdirectory:requirement.md— what to build and whydesign.md— how to build it (architecture, data models, interfaces)tasks.md— all tasks and their relationships- Understand the full picture before focusing on your task
Read project rules (if they exist):
coding-rules.md(search:docs/development/→docs/→ find)CLAUDE.md/AGENTS.mdat project root
Phase B — Feedback re-invocation (minimal context):
When called with --feedback, load only:
- The feedback file (review or test results)
- The target task description from
tasks.md - The relevant
design.mdsection - The changed files from the previous implementation
Do NOT re-read the full spec set unless the feedback indicates a misunderstanding of requirements.
Step 1: Locate Target Task
Parse tasks.md to find the task matching --task {task-id}:
- Extract: task name, requirements ID, design reference, target files, completion criteria
- If task is already checked
[x], warn and stop
Step 2: Reference Design
Read the design section referenced by the task (e.g., "design.md §4.2"):
- Extract: architecture decisions, interfaces, data models
- Identify target files to create or modify
Step 3: Implement
Normal mode (no --feedback):
- Follow the design to implement the task
- Apply coding rules and project conventions
- Create or modify only the files specified in the task
Feedback mode (--feedback {file}):
The feedback file is auto-detected by its type: header line:
- type: review → Read
## Findingssection. Fix only the findings taggedfix_before: implementation, at the specified file:line (Critical first, then Improvement). Findings taggedtrial/required_check/follow_upare deferred — the caller carries them; do not fix them here. If no finding carries afix_beforetag (a legacy review file), fix Critical findings first, then Improvements. - type: test → Read
## Test Casesfor failures and## Completion Criteria Coveragefor uncovered criteria. Fix the failing tests by modifying implementation code. - type: evaluate → Same
## Findingsprocessing astype: review(identical### Critical/### Improvementstructure). Fix Critical findings first, then Improvements. Ignore the## Blockedsection: blocked cases are setup gaps, not failures, and are not fix targets.
For both types:
- Focus on items marked as FAIL or
- [ ](unchecked) - Do NOT modify code unrelated to the findings
Step 4: Verify Completion Criteria
Check each completion criterion from tasks.md:
- If criterion is met, note it
- If not met, continue implementing until satisfied
- Do NOT update the checkbox in
tasks.md(this is spec-implement's responsibility)
Step 5: Commit
Commit the implementation following project conventions:
- Read commit message format from
coding-rules.mdorCLAUDE.md - Default format:
feat(scope): {task-id} — {brief description} - Stage only implementation files (not
tasks.md)
Error Handling
| Situation | Response |
|---|---|
--spec path not found |
Error: spec directory not found |
--task ID not found in tasks.md |
Error: task ID not found |
| Task already checked [x] | Warning: task already complete, skip |
| Design section not found | Warning: implement based on task description and requirements only |
--feedback file not found |
Error: feedback file not found |
| Coding rules not found | Warning: proceed with project defaults |
Usage Examples
# Implement a specific task
/spec-code --issue 36 --task T-007 --spec .specs/did-deactivation/
# Address review feedback
/spec-code --task T-007 --spec .specs/did-deactivation/ --feedback .specs/did-deactivation/review-T-007.md
# Address test failure feedback
/spec-code --task T-007 --spec .specs/did-deactivation/ --feedback .specs/did-deactivation/test-T-007.md
# Standalone (no issue)
/spec-code --task T-003 --spec .specs/auth-feature/