spec-implement
npx skills add https://github.com/anyoneanderson/agent-skills --skill spec-implement
Agent 安装分布
Skill 文档
spec-implement â Spec-Driven Implementation to PR
Execute implementation from specifications to pull request, following project-specific workflows and enforcing coding rules.
Language Rules
- Auto-detect input language â output in the same language
- Japanese input â Japanese output, use
references/implement-guide.ja.md - English input â English output, use
references/implement-guide.md - Explicit override takes priority (e.g., “in English”, “æ¥æ¬èªã§”)
Critical First Steps
BEFORE any implementation, execute these checks in order:
-
Verify environment:
- Run
pwdto confirm working directory - Run
git statusto confirm inside a git repository - Run
gh auth statusto confirm GitHub CLI access
- Run
-
Parse user input for options:
--resumeâ resume from last uncompleted task--issue {N}â specify GitHub Issue number--spec {path}â specify.specs/directory path--dry-runâ show execution plan without making changes--parallelâ force parallel execution if environment is ready--no-parallelâ force sequential execution
-
Locate spec directory:
- If
--specprovided â use that path - If issue body contains
.specs/path â use that - Otherwise â scan
.specs/and ask user to select:AskUserQuestion: question: "Which spec to implement?" / "ã©ã®ä»æ§æ¸ãå®è£ ãã¾ããï¼" options: [list discovered .specs/ directories]
- If
-
Locate and read project files (in this order):
Workflow playbook â search in order, use first found:
docs/development/issue-to-pr-workflow.mddocs/issue-to-pr-workflow.md- Fallback:
find . -name "issue-to-pr-workflow.md" -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/vendor/*" -not -path "*/dist/*" -not -path "*/build/*" | head -1 - If not found â trigger fallback (see Phase 1)
Coding rules â search in order, use first found:
docs/development/coding-rules.mddocs/coding-rules.md- Fallback:
find . -name "coding-rules.md" -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/vendor/*" -not -path "*/dist/*" -not -path "*/build/*" | head -1 - If not found â trigger fallback (see Phase 2)
Project instruction files â read all that exist:
CLAUDE.md(project root)src/CLAUDE.md(source-level rules)test/CLAUDE.md(test-level rules)AGENTS.md(agent definitions)
Spec files:
.specs/{feature}/requirement.mdâ what to build.specs/{feature}/design.mdâ how to build it.specs/{feature}/tasks.mdâ task breakdown with checkboxes
-
Detect parallel-capable agent environment (runtime-aware):
- Determine active runtime from the current execution environment (do NOT infer runtime solely from repository directories)
- Use repository files only for runtime setup validation:
- Codex validation:
.codex/config.toml - Claude Code validation:
.claude/agents/workflow-*.md
- Codex validation:
- If runtime cannot be determined, ask user to choose runtime
- Check whether workflow contains a parallel section (
Parallel Execution Strategy/Agent Roles) - Parse optional workflow section for explicit agent file paths:
Agent definition files:/ã¨ã¼ã¸ã§ã³ãå®ç¾©ãã¡ã¤ã«:- Extract paths for implementer / reviewer / tester from list items
- Use extracted paths as first priority for validation and dispatch context
- If section is absent, fallback to runtime defaults
- Validate runtime-specific sub-agent setup:
- Codex:
.codex/config.tomlhas[features] multi_agent = trueandagents.workflow-* - Claude Code: agent files from workflow section exist; if absent, use defaults (
.claude/agents/workflow-implementer.md,.claude/agents/workflow-reviewer.md,.claude/agents/workflow-tester.md)
- Codex:
- If any required condition is missing, continue in sequential mode
Execution Flow
Phase 1: Workflow Loading
Read the workflow file (located in Step 4) and interpret each section as instructions to follow:
| Workflow Section | Action |
|---|---|
| Development Environment | Extract setup commands, environment variables |
| Issue Analysis and Setup | Follow branch naming convention, issue reading steps |
| Branch Strategy / PR Target | Extract base branch (e.g., develop, main) and PR target branch |
| Phased Implementation | Follow implementation order and guidelines |
| Agent Roles / Sub-agents | Extract agent role definitions (if present) |
| Agent Definition Files (Optional) | Extract explicit sub-agent definition file paths |
| Testing | Extract test commands and coverage thresholds |
| PR Creation and Quality Gates | Extract pre-PR checks and PR template |
| CI/CD Monitoring | Extract CI verification commands |
| Commit Message Rules | Extract commit message format and language requirements |
Follow sections top-to-bottom. Replace {variable} placeholders with actual values (issue number, branch name, etc.). Treat “MUST” and “required” keywords as mandatory; treat “optional” and “if applicable” as conditional.
Base branch detection â determine {base_branch} from the workflow:
- Look for “branch strategy”, “base branch”, “PR target”, “develop”, “main” in the workflow
- If the workflow specifies a branch (e.g.,
develop), use it as{base_branch} - Default fallback:
main
Fallback (no workflow file): If no workflow file is found:
AskUserQuestion:
question: "Workflow file not found. Generate it?" / "ã¯ã¼ã¯ããã¼ãã¡ã¤ã«ãè¦ã¤ããã¾ãããçæãã¾ããï¼"
options:
- "Run spec-workflow-init" / "spec-workflow-initãå®è¡"
- "Continue without workflow" / "ã¯ã¼ã¯ããã¼ãªãã§ç¶è¡"
If continuing without workflow, use minimal flow: Issue analysis â branch â implement â test â PR. Use main as {base_branch}.
Phase 1.5: Parallel Mode Resolution (Runtime-Aware)
Enable parallel mode only when ALL are true:
- Workflow includes a parallel section with role assignment
- Runtime-specific sub-agent configuration is valid
- User did not pass
--no-parallel(or explicitly passed--parallel)
If runtime cannot be determined from execution context, confirm runtime before dispatch:
AskUserQuestion:
question: "Which runtime should execute sub-agents?" / "ã©ã®ã©ã³ã¿ã¤ã ã§ãµãã¨ã¼ã¸ã§ã³ãå®è¡ãã¾ããï¼"
options:
- "Codex runtime" / "Codexã§å®è¡"
- "Claude Code runtime" / "Claude Codeã§å®è¡"
If enabled:
- Run implementer and tester in parallel, then run reviewer after both complete.
- Use explicit runtime-specific dispatch instructions, not narrative role assignment only.
Codex path:
- Required config:
.codex/config.tomlwithmulti_agent = trueandagents.workflow-* - Agent definition file paths:
- First priority: paths declared in workflow
Agent definition filessection - Fallback: runtime defaults (from
.codex/agents/conventions)
- First priority: paths declared in workflow
- Dispatch format (example):
Task:
subagent_type: workflow-implementer
prompt: "Implement task T001 using design section 2.3. Edit implementation files only."
Task:
subagent_type: workflow-tester
prompt: "Create tests for task T001. Edit test files only."
Claude Code path:
- Required files:
- First priority: paths declared in workflow
Agent definition filessection - Fallback defaults:
.claude/agents/workflow-implementer.md,.claude/agents/workflow-reviewer.md,.claude/agents/workflow-tester.md
- First priority: paths declared in workflow
- Dispatch format: use Claude Code sub-agent call format with
subagent_typeset to workflow agent names (workflow-implementer,workflow-tester,workflow-reviewer). - Example (pseudocode):
SubAgent:
subagent_type: workflow-implementer
prompt: "Implement task T001 using design section 2.3. Edit implementation files only."
If disabled:
- Continue with the existing single-agent sequential loop.
Phase 2: Quality Rules Loading
Read the coding rules file (located in Step 4) and parse rule structure:
## {Category}
### [{Severity}] {Rule Name}
- {Rule detail}
Apply rules by severity:
| Severity | On Violation | Action |
|---|---|---|
[MUST] |
Error | Stop â fix â recheck before continuing |
[SHOULD] |
Warning | Log warning â continue |
[MAY] |
Info | Log info only |
Check timing:
- Before task: Review rules relevant to the task’s category
- During code generation: Self-check against
[MUST]rules - After task: Verify completion criteria + rule compliance
- Final gate: Check all
[MUST]rules across all changes
Fallback (no rules file): If no coding rules file is found:
AskUserQuestion:
question: "Coding rules not found. Generate them?" / "ã³ã¼ãã£ã³ã°ã«ã¼ã«ãè¦ã¤ããã¾ãããçæãã¾ããï¼"
options:
- "Run spec-rules-init" / "spec-rules-initãå®è¡"
- "Continue without rules" / "ã«ã¼ã«ãªãã§ç¶è¡"
If continuing without rules, use CLAUDE.md or AGENTS.md as fallback reference if available.
Phase 3: Project Instruction Loading
Read all project instruction files found in Step 4 (CLAUDE.md, src/CLAUDE.md, test/CLAUDE.md, AGENTS.md).
These files contain project-specific conditional rules, environment constraints, and coding conventions. Apply them with the same enforcement level as [MUST] rules from coding-rules.md:
- Extract conditional rules: IF-THEN patterns, conditional instructions, and environment-specific constraints (e.g., “when using Docker…”, “if the project has…”) are mandatory action triggers
- Extract environment constraints: Docker requirements, package manager restrictions, etc.
- Extract commit conventions: Commit message language, format, co-author requirements
- Extract test patterns: Required test helpers, test structure conventions
- Merge with coding-rules.md: These rules supplement (not replace) coding-rules.md
If neither coding-rules.md nor any CLAUDE.md files exist, proceed with framework defaults only.
Phase 4: Issue Analysis
If --issue {N} is provided or an issue number is found in context:
gh issue view {N} --json title,body,labels,assignees
Extract from the issue:
- Feature overview and requirements
- Spec directory path (if referenced)
- Phase/task checklists
- Assignees and labels
Phase 5: Branch Creation
ð¨ BLOCKING GATE â Feature branch is MANDATORY
Implementation MUST NOT proceed on
main,master, ordevelopbranches. This gate cannot be skipped. Violation = immediate stop.
Follow the workflow’s branch naming convention:
git checkout {base_branch} && git pull origin {base_branch}
git checkout -b feature/issue-{N}-{brief-description}
Where {base_branch} is the branch detected in Phase 1 (default: main).
Protected branch list â by default: main, master, develop.
If the workflow file defines a “protected branches” or “branch protection” section, use that list instead.
If --resume is active and the branch already exists, switch to it instead.
Post-creation verification:
current_branch=$(git branch --show-current)
if [ "$current_branch" = "main" ] || [ "$current_branch" = "master" ] || [ "$current_branch" = "develop" ]; then
echo "ð¨ ERROR: Cannot implement on protected branch: $current_branch"
echo "Create a feature branch first."
exit 1
fi
This check MUST pass before proceeding to Phase 6. If it fails, stop and ask the user for guidance.
Phase 6: Spec-Driven Task Loop
Pre-loop: Agent role detection
If the workflow file contains an “Agent Roles”, “Sub-agents”, or “ã¨ã¼ã¸ã§ã³ããã¼ã«” section:
-
Parse explicit agent file paths (if present):
- Read workflow section
Agent definition files:/ã¨ã¼ã¸ã§ã³ãå®ç¾©ãã¡ã¤ã«: - Build a map of role â definition file path (implementer/reviewer/tester)
- If no section exists, use runtime defaults
- Read workflow section
-
Parse the Role Assignment Table â find the Markdown table with columns like
Role | Agent | Responsibility:- Extract each row’s
Agentcolumn value â use as runtime sub-agent identifier (subagent_type) - Extract each row’s
Responsibilitycolumn value â use as context in the task prompt
- Extract each row’s
-
Parse the Parallel Execution Strategy Table (if present) â find the table with phase rows and role columns:
- Each row = a phase (execute sequentially, top to bottom)
- Cells with
-= role is idle in that phase - Non-
-cells = role’s action (roles active in the same row run in parallel)
-
Present options to the user:
AskUserQuestion: question: "Workflow defines agent roles. Use sub-agents for parallel execution?" / "ã¯ã¼ã¯ããã¼ã«ã¨ã¼ã¸ã§ã³ããã¼ã«ãå®ç¾©ããã¦ãã¾ãããµãã¨ã¼ã¸ã§ã³ãã§ä¸¦åå®è¡ãã¾ããï¼" options: - "Use sub-agents (parallel)" / "ãµãã¨ã¼ã¸ã§ã³ã使ç¨ï¼ä¸¦åï¼" - "Single agent (sequential)" / "ã·ã³ã°ã«ã¨ã¼ã¸ã§ã³ãï¼é 次ï¼" -
If sub-agents selected, branch by runtime:
- Codex runtime: spawn agents via Codex Task dispatch using parsed
Agentnames assubagent_type - Claude Code runtime: spawn agents via Claude Code sub-agent dispatch using parsed
Agentnames assubagent_type - Execute phases per strategy table (same-row roles run in parallel)
- Codex runtime: spawn agents via Codex Task dispatch using parsed
-
If single agent selected: proceed with sequential execution below
See reference guide for table format examples and runtime-specific sub-agent invocation patterns.
Read specs in order: requirement.md â design.md â tasks.md
For each unchecked task in tasks.md:
1. Read task details (requirements ID, design reference, target files, completion criteria)
2. Reference the corresponding design.md section
3. Implement: create or modify target files
4. ð Implementation Review:
a. Self-review generated code against design.md specifications
b. Verify coding-rules.md [MUST] rules for generated code
c. Verify CLAUDE.md conditional rules for generated code
d. If review finds issues â fix before proceeding
5. If task includes test implementation:
a. Write tests following project test patterns (from CLAUDE.md / coding-rules.md)
b. Run tests to verify they pass
c. ð Test Review:
- Verify test coverage matches completion criteria
- Verify test patterns match project conventions
- If review finds issues â fix before proceeding
6. Update tasks.md: mark completion criteria (- [ ] â - [x])
7. When all criteria pass: mark top-level task checkbox (- [x])
8. Commit progress:
git add .specs/{feature}/tasks.md [+ implementation files]
git commit -m "{commit message following project conventions}"
Commit messages: Follow format/language from coding-rules.md or CLAUDE.md. Default: feat: {task-id} complete â {brief description}. See reference guide for details.
No specs fallback: If .specs/ is missing, use Issue body as guide and generate a simple checklist. See reference guide for details.
Phase 7: Final Quality Gate
After all tasks are complete:
- Run test commands from the workflow (or language-appropriate default)
- Run lint/typecheck commands from the workflow (if specified)
- Verify all
[MUST]rules from coding-rules.md pass - Verify all CLAUDE.md conditional rules pass
- If any check fails â fix â recheck
- All checks pass â proceed to PR creation
Phase 8: PR Creation
Follow the workflow’s PR template. Use {base_branch} detected in Phase 1:
gh pr create \
--title "{type}: {description} (closes #{N})" \
--body "{PR body following workflow template}" \
--base {base_branch}
Where {base_branch} comes from Phase 1 workflow detection (default: main).
Verify --base {base_branch} matches the workflow’s branch strategy before creating the PR.
Safety guards:
- Do NOT create PR if tests are failing
- Do NOT force push
- Do NOT push directly to main/master
- Do NOT target wrong base branch (verify against workflow)
- Ask for user confirmation before large-scale code deletions
After PR creation, monitor CI status if the workflow specifies CI verification commands.
Options
| Option | Description |
|---|---|
--resume |
Resume from last uncompleted task in tasks.md |
--issue {N} |
Specify GitHub Issue number for context |
--spec {path} |
Specify .specs/ directory path (default: auto-detect) |
--dry-run |
Show execution plan without making any changes (output format: see reference guide) |
--parallel |
Force parallel mode (requires valid runtime sub-agent setup for Codex or Claude Code) |
--no-parallel |
Disable parallel mode and run sequentially |
Error Handling
| Situation | Response |
|---|---|
| Not a git repository | Error: “Must be in a git repository” / “gitãªãã¸ããªå ã§å®è¡ãã¦ãã ãã” |
gh CLI not available |
Error: guide user to install/authenticate gh CLI |
.specs/ not found |
Warning: switch to Issue-only minimal mode |
| Parallel requested but runtime sub-agent config missing/invalid | Warning: explain missing setup, fallback to sequential mode |
| Workflow-declared agent definition file path does not exist | Warning: explain missing file path, fallback to sequential mode |
| Workflow references sub-agent names that are not configured in selected runtime | Warning: explain missing agent definitions, fallback to sequential mode |
| Parallel file edit collision | Warning: stop parallel for current task, continue sequentially |
requirement.md missing |
Warning: use Issue body as requirements source |
tasks.md missing |
Warning: generate simple checklist from Issue |
[MUST] rule violation |
Error: stop, fix, recheck before continuing |
| Tests failing before PR | Block PR creation, report failures |
| Branch already exists | Ask: switch to it or create new |
| On protected branch (main/master/develop) | ð¨ BLOCKING: stop immediately, require feature branch |
| Workflow/rules file not at expected path | Search alternate paths before declaring missing |
Usage Examples
# Full implementation from spec
"Implement from spec for auth-feature"
ãauth-featureã®ä»æ§æ¸ããå®è£
ãã¦ã
# With issue number
"Implement spec --issue 42"
ãIssue #42ã®ä»æ§ãå®è£
ãã¦ã
# Resume after interruption
"Resume implementation --resume --spec .specs/auth-feature/"
ãå®è£
ãåé --resumeã
# Dry run to preview plan
"Show implementation plan --dry-run --spec .specs/auth-feature/"
ãå®è£
è¨ç»ã表示 --dry-runã
# Force parallel mode (runtime-aware)
"Implement from spec --spec .specs/auth-feature/ --parallel"
ã仿§æ¸ãã並åå®è¡ã§å®è£
--parallelã
# Minimal mode (no specs)
"Implement issue 42"
ãIssue 42ãå®è£
ãã¦ã
Post-Completion Actions
After PR is created:
AskUserQuestion:
question: "PR created. What's next?" / "PRã使ãã¾ãããæ¬¡ã¯ï¼"
options:
- "Monitor CI status" / "CIã¹ãã¼ã¿ã¹ãç£è¦"
- "Review the PR diff" / "PRå·®åã確èª"
- "Done" / "å®äº"