|
| 1 | +--- |
| 2 | +description: Execute ONE work unit from tasks.md (smallest of one phase, one user story, or one task group) |
| 3 | +--- |
| 4 | + |
| 5 | +## Scope Constraint |
| 6 | + |
| 7 | +**CRITICAL**: This agent completes AT MOST ONE work unit per invocation. |
| 8 | + |
| 9 | +A "work unit" is the SMALLEST of: |
| 10 | +- One phase (e.g., "Phase 1: Project Setup") |
| 11 | +- One user story (e.g., "US-001: Initialize Command") |
| 12 | +- One logical grouping of tasks |
| 13 | + |
| 14 | +**Rules**: |
| 15 | +- Find the FIRST incomplete work unit in tasks.md |
| 16 | +- Complete ONLY tasks within that single work unit |
| 17 | +- DO NOT start a second work unit even if time remains |
| 18 | +- If you cannot complete the entire work unit, complete as many tasks as possible |
| 19 | +- Partial progress is acceptable - remaining tasks continue in subsequent iterations |
| 20 | + |
| 21 | +**Why**: This prevents context degradation and keeps changes reviewable. |
| 22 | + |
| 23 | +## User Input |
| 24 | + |
| 25 | +```text |
| 26 | +$ARGUMENTS |
| 27 | +``` |
| 28 | + |
| 29 | +You **MUST** consider the user input before proceeding (if not empty). |
| 30 | + |
| 31 | +## Outline |
| 32 | + |
| 33 | +1. Run `.specify/scripts/powershell/check-prerequisites.ps1 -Json -RequireTasks -IncludeTasks` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot"). |
| 34 | + |
| 35 | +2. **Check checklists status** (if FEATURE_DIR/checklists/ exists): |
| 36 | + - Scan all checklist files in the checklists/ directory |
| 37 | + - For each checklist, count: |
| 38 | + - Total items: All lines matching `- [ ]` or `- [X]` or `- [x]` |
| 39 | + - Completed items: Lines matching `- [X]` or `- [x]` |
| 40 | + - Incomplete items: Lines matching `- [ ]` |
| 41 | + - Create a status table: |
| 42 | + |
| 43 | + ```text |
| 44 | + | Checklist | Total | Completed | Incomplete | Status | |
| 45 | + |-----------|-------|-----------|------------|--------| |
| 46 | + | ux.md | 12 | 12 | 0 | PASS | |
| 47 | + | test.md | 8 | 5 | 3 | FAIL | |
| 48 | + | security.md | 6 | 6 | 0 | PASS | |
| 49 | + ``` |
| 50 | +
|
| 51 | + - Calculate overall status: |
| 52 | + - **PASS**: All checklists have 0 incomplete items |
| 53 | + - **FAIL**: One or more checklists have incomplete items |
| 54 | +
|
| 55 | + - **If any checklist is incomplete**: |
| 56 | + - Display the table with incomplete item counts |
| 57 | + - **STOP** and ask: "Some checklists are incomplete. Do you want to proceed with implementation anyway? (yes/no)" |
| 58 | + - Wait for user response before continuing |
| 59 | + - If user says "no" or "wait" or "stop", halt execution |
| 60 | + - If user says "yes" or "proceed" or "continue", proceed to step 3 |
| 61 | +
|
| 62 | + - **If all checklists are complete**: |
| 63 | + - Display the table showing all checklists passed |
| 64 | + - Automatically proceed to step 3 |
| 65 | +
|
| 66 | +3. Load and analyze the implementation context: |
| 67 | + - **REQUIRED**: Read tasks.md for the complete task list and execution plan |
| 68 | + - **REQUIRED**: Read plan.md for tech stack, architecture, and file structure |
| 69 | + - **IF EXISTS**: Read progress.md for previously discovered patterns and iteration history |
| 70 | + - **IF EXISTS**: Read data-model.md for entities and relationships |
| 71 | + - **IF EXISTS**: Read contracts/ for API specifications and test requirements |
| 72 | + - **IF EXISTS**: Read research.md for technical decisions and constraints |
| 73 | + - **IF EXISTS**: Read quickstart.md for integration scenarios |
| 74 | +
|
| 75 | +4. **Project Setup Verification**: |
| 76 | + - **REQUIRED**: Create/verify ignore files based on actual project setup: |
| 77 | +
|
| 78 | + **Detection & Creation Logic**: |
| 79 | + - Check if the following command succeeds to determine if the repository is a git repo (create/verify .gitignore if so): |
| 80 | +
|
| 81 | + ```sh |
| 82 | + git rev-parse --git-dir 2>/dev/null |
| 83 | + ``` |
| 84 | +
|
| 85 | + - Check if Dockerfile* exists or Docker in plan.md -> create/verify .dockerignore |
| 86 | + - Check if .eslintrc* exists -> create/verify .eslintignore |
| 87 | + - Check if eslint.config.* exists -> ensure the config's `ignores` entries cover required patterns |
| 88 | + - Check if .prettierrc* exists -> create/verify .prettierignore |
| 89 | + - Check if .npmrc or package.json exists -> create/verify .npmignore (if publishing) |
| 90 | + - Check if terraform files (*.tf) exist -> create/verify .terraformignore |
| 91 | + - Check if .helmignore needed (helm charts present) -> create/verify .helmignore |
| 92 | +
|
| 93 | + **If ignore file already exists**: Verify it contains essential patterns, append missing critical patterns only |
| 94 | + **If ignore file missing**: Create with full pattern set for detected technology |
| 95 | +
|
| 96 | + **Common Patterns by Technology** (from plan.md tech stack): |
| 97 | + - **Node.js/JavaScript/TypeScript**: `node_modules/`, `dist/`, `build/`, `*.log`, `.env*` |
| 98 | + - **Python**: `__pycache__/`, `*.pyc`, `.venv/`, `venv/`, `dist/`, `*.egg-info/` |
| 99 | + - **Java**: `target/`, `*.class`, `*.jar`, `.gradle/`, `build/` |
| 100 | + - **C#/.NET**: `bin/`, `obj/`, `*.user`, `*.suo`, `packages/` |
| 101 | + - **Go**: `*.exe`, `*.test`, `vendor/`, `*.out` |
| 102 | + - **Ruby**: `.bundle/`, `log/`, `tmp/`, `*.gem`, `vendor/bundle/` |
| 103 | + - **PHP**: `vendor/`, `*.log`, `*.cache`, `*.env` |
| 104 | + - **Rust**: `target/`, `debug/`, `release/`, `*.rs.bk`, `*.rlib`, `*.prof*`, `.idea/`, `*.log`, `.env*` |
| 105 | + - **Kotlin**: `build/`, `out/`, `.gradle/`, `.idea/`, `*.class`, `*.jar`, `*.iml`, `*.log`, `.env*` |
| 106 | + - **C++**: `build/`, `bin/`, `obj/`, `out/`, `*.o`, `*.so`, `*.a`, `*.exe`, `*.dll`, `.idea/`, `*.log`, `.env*` |
| 107 | + - **C**: `build/`, `bin/`, `obj/`, `out/`, `*.o`, `*.a`, `*.so`, `*.exe`, `Makefile`, `config.log`, `.idea/`, `*.log`, `.env*` |
| 108 | + - **Swift**: `.build/`, `DerivedData/`, `*.swiftpm/`, `Packages/` |
| 109 | + - **R**: `.Rproj.user/`, `.Rhistory`, `.RData`, `.Ruserdata`, `*.Rproj`, `packrat/`, `renv/` |
| 110 | + - **Universal**: `.DS_Store`, `Thumbs.db`, `*.tmp`, `*.swp`, `.vscode/`, `.idea/` |
| 111 | +
|
| 112 | + **Tool-Specific Patterns**: |
| 113 | + - **Docker**: `node_modules/`, `.git/`, `Dockerfile*`, `.dockerignore`, `*.log*`, `.env*`, `coverage/` |
| 114 | + - **ESLint**: `node_modules/`, `dist/`, `build/`, `coverage/`, `*.min.js` |
| 115 | + - **Prettier**: `node_modules/`, `dist/`, `build/`, `coverage/`, `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml` |
| 116 | + - **Terraform**: `.terraform/`, `*.tfstate*`, `*.tfvars`, `.terraform.lock.hcl` |
| 117 | + - **Kubernetes/k8s**: `*.secret.yaml`, `secrets/`, `.kube/`, `kubeconfig*`, `*.key`, `*.crt` |
| 118 | +
|
| 119 | +5. **Identify the current work unit** (SCOPE CONSTRAINT): |
| 120 | + - Parse tasks.md to find the FIRST section with incomplete tasks (`- [ ]`) |
| 121 | + - Determine the work unit type: |
| 122 | + - If tasks are organized by phases -> work unit = one phase |
| 123 | + - If tasks are organized by user stories -> work unit = one user story |
| 124 | + - Otherwise -> work unit = first logical grouping of incomplete tasks |
| 125 | + - **Record the work unit boundaries** - you will ONLY work within these bounds |
| 126 | + - Example: If "Phase 2: Core Implementation" is the first with incomplete tasks, STOP at Phase 2's end |
| 127 | +
|
| 128 | +6. Execute implementation for the CURRENT WORK UNIT ONLY: |
| 129 | + - **Respect dependencies**: Run sequential tasks in order, parallel tasks [P] can run together |
| 130 | + - **Follow TDD approach**: Execute test tasks before their corresponding implementation tasks |
| 131 | + - **File-based coordination**: Tasks affecting the same files must run sequentially |
| 132 | + - **STOP at work unit boundary**: Do not continue to the next phase/story/group |
| 133 | +
|
| 134 | +7. Implementation execution rules: |
| 135 | + - **Setup first**: Initialize project structure, dependencies, configuration |
| 136 | + - **Tests before code**: If you need to write tests for contracts, entities, and integration scenarios |
| 137 | + - **Core development**: Implement models, services, CLI commands, endpoints |
| 138 | + - **Integration work**: Database connections, middleware, logging, external services |
| 139 | + - **Polish and validation**: Unit tests, performance optimization, documentation |
| 140 | +
|
| 141 | +8. **Progress tracking** - Create/update `progress.md` in FEATURE_DIR: |
| 142 | + - **If `progress.md` does not exist**, create it with header: `# Implementation Progress` |
| 143 | + - **Append an iteration entry** using this format: |
| 144 | + ```markdown |
| 145 | + ## Iteration [N] - [YYYY-MM-DD HH:MM] |
| 146 | + **Work Unit**: [Phase/Story/Task group title] |
| 147 | + **Tasks Completed**: |
| 148 | + - [x] Task ID: description |
| 149 | + - [x] Task ID: description |
| 150 | + **Tasks Remaining in Work Unit**: [count] or "None - work unit complete" |
| 151 | + **Commit**: [git hash] or "No commit - partial progress" |
| 152 | + **Files Changed**: |
| 153 | + - path/to/file.ext (created/modified/deleted) |
| 154 | + **Learnings**: |
| 155 | + - [patterns discovered, gotchas, useful context for future iterations] |
| 156 | + ``` |
| 157 | + - **IMPORTANT**: Mark each completed task as `[x]` in tasks.md immediately |
| 158 | +
|
| 159 | +9. Error handling: |
| 160 | + - Report progress after each completed task |
| 161 | + - Halt execution if any non-parallel task fails |
| 162 | + - For parallel tasks [P], continue with successful tasks, report failed ones |
| 163 | + - Provide clear error messages with context for debugging |
| 164 | +
|
| 165 | +10. **Work unit completion**: |
| 166 | + - When ALL tasks in the current work unit are complete: |
| 167 | + - Verify implemented features match the original specification |
| 168 | + - Validate that tests pass and coverage meets requirements |
| 169 | + - Confirm the implementation follows the technical plan |
| 170 | + - Create a commit: |
| 171 | + ``` |
| 172 | + git add -A |
| 173 | + git commit -m "feat(<feature-name>): <work unit title>" |
| 174 | + ``` |
| 175 | + - If only partial progress was made, do NOT commit (next iteration will continue) |
| 176 | +
|
| 177 | +11. **Completion signal**: |
| 178 | + - **If ALL tasks in tasks.md are complete** (no `- [ ]` remaining), output exactly: |
| 179 | + ``` |
| 180 | + <promise>COMPLETE</promise> |
| 181 | + ``` |
| 182 | + - If tasks remain in other work units, end normally (next iteration continues) |
| 183 | +
|
| 184 | +Note: This agent is designed for automated iteration loops. It completes one work unit per invocation to prevent context degradation and maintain reviewable change sets. If tasks are incomplete or missing, suggest running `/speckit.tasks` first to regenerate the task list. |
0 commit comments