@sixfactors-ai/codeloop 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +214 -0
  3. package/dist/__tests__/integration/skill-board.test.d.ts +1 -0
  4. package/dist/__tests__/integration/skill-board.test.js +76 -0
  5. package/dist/__tests__/integration/skill-board.test.js.map +1 -0
  6. package/dist/__tests__/integration/tdd-planning.test.d.ts +1 -0
  7. package/dist/__tests__/integration/tdd-planning.test.js +41 -0
  8. package/dist/__tests__/integration/tdd-planning.test.js.map +1 -0
  9. package/dist/commands/init.d.ts +2 -0
  10. package/dist/commands/init.js +115 -0
  11. package/dist/commands/init.js.map +1 -0
  12. package/dist/commands/serve.d.ts +7 -0
  13. package/dist/commands/serve.js +113 -0
  14. package/dist/commands/serve.js.map +1 -0
  15. package/dist/commands/status.d.ts +2 -0
  16. package/dist/commands/status.js +177 -0
  17. package/dist/commands/status.js.map +1 -0
  18. package/dist/commands/update.d.ts +2 -0
  19. package/dist/commands/update.js +95 -0
  20. package/dist/commands/update.js.map +1 -0
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +17 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/lib/__tests__/board.test.d.ts +1 -0
  25. package/dist/lib/__tests__/board.test.js +220 -0
  26. package/dist/lib/__tests__/board.test.js.map +1 -0
  27. package/dist/lib/__tests__/scaffold.test.d.ts +1 -0
  28. package/dist/lib/__tests__/scaffold.test.js +39 -0
  29. package/dist/lib/__tests__/scaffold.test.js.map +1 -0
  30. package/dist/lib/__tests__/serve.test.d.ts +1 -0
  31. package/dist/lib/__tests__/serve.test.js +57 -0
  32. package/dist/lib/__tests__/serve.test.js.map +1 -0
  33. package/dist/lib/__tests__/server.test.d.ts +1 -0
  34. package/dist/lib/__tests__/server.test.js +100 -0
  35. package/dist/lib/__tests__/server.test.js.map +1 -0
  36. package/dist/lib/__tests__/smoke.test.d.ts +1 -0
  37. package/dist/lib/__tests__/smoke.test.js +7 -0
  38. package/dist/lib/__tests__/smoke.test.js.map +1 -0
  39. package/dist/lib/board.d.ts +38 -0
  40. package/dist/lib/board.js +86 -0
  41. package/dist/lib/board.js.map +1 -0
  42. package/dist/lib/detect.d.ts +13 -0
  43. package/dist/lib/detect.js +60 -0
  44. package/dist/lib/detect.js.map +1 -0
  45. package/dist/lib/scaffold.d.ts +8 -0
  46. package/dist/lib/scaffold.js +105 -0
  47. package/dist/lib/scaffold.js.map +1 -0
  48. package/dist/lib/server.d.ts +5 -0
  49. package/dist/lib/server.js +125 -0
  50. package/dist/lib/server.js.map +1 -0
  51. package/dist/lib/version.d.ts +10 -0
  52. package/dist/lib/version.js +27 -0
  53. package/dist/lib/version.js.map +1 -0
  54. package/dist/ui/404.html +1 -0
  55. package/dist/ui/_next/static/XkK-IaWE1h2_WYJHhUKNa/_buildManifest.js +1 -0
  56. package/dist/ui/_next/static/XkK-IaWE1h2_WYJHhUKNa/_ssgManifest.js +1 -0
  57. package/dist/ui/_next/static/chunks/255-54d3085ce94738a4.js +1 -0
  58. package/dist/ui/_next/static/chunks/423-bb541b7ae2733575.js +1 -0
  59. package/dist/ui/_next/static/chunks/4bd1b696-c023c6e3521b1417.js +1 -0
  60. package/dist/ui/_next/static/chunks/app/_not-found/page-d6bc774f7acb716e.js +1 -0
  61. package/dist/ui/_next/static/chunks/app/layout-e5fc8e78e1c8da95.js +1 -0
  62. package/dist/ui/_next/static/chunks/app/page-a1867b0e8c871ff8.js +1 -0
  63. package/dist/ui/_next/static/chunks/framework-de98b93a850cfc71.js +1 -0
  64. package/dist/ui/_next/static/chunks/main-49fd204fc9037ea3.js +1 -0
  65. package/dist/ui/_next/static/chunks/main-app-c46afa2f48f3aaef.js +1 -0
  66. package/dist/ui/_next/static/chunks/pages/_app-7d307437aca18ad4.js +1 -0
  67. package/dist/ui/_next/static/chunks/pages/_error-cb2a52f75f2162e2.js +1 -0
  68. package/dist/ui/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  69. package/dist/ui/_next/static/chunks/webpack-4a462cecab786e93.js +1 -0
  70. package/dist/ui/_next/static/css/721d4a8588775f36.css +1 -0
  71. package/dist/ui/index.html +1 -0
  72. package/dist/ui/index.txt +19 -0
  73. package/package.json +53 -0
  74. package/starters/generic.yaml +45 -0
  75. package/starters/go.yaml +47 -0
  76. package/starters/node-typescript.yaml +56 -0
  77. package/starters/python.yaml +50 -0
  78. package/templates/codeloop/board.json +5 -0
  79. package/templates/codeloop/gotchas.md +13 -0
  80. package/templates/codeloop/patterns.md +15 -0
  81. package/templates/codeloop/principles.md +49 -0
  82. package/templates/codeloop/rules.md +23 -0
  83. package/templates/commands/commit.md +245 -0
  84. package/templates/commands/manage.md +77 -0
  85. package/templates/commands/plan.md +83 -0
  86. package/templates/commands/reflect.md +93 -0
  87. package/templates/tasks/todo.md +3 -0
@@ -0,0 +1,56 @@
1
+ # Codeloop Configuration
2
+ # Node.js + TypeScript starter
3
+
4
+ project:
5
+ name: "my-project"
6
+
7
+ scopes:
8
+ backend:
9
+ paths: ["src/**", "lib/**"]
10
+ gotcha_sections: ["Backend", "Database", "API"]
11
+ pattern_sections: ["Backend", "API", "Error Handling"]
12
+ frontend:
13
+ paths: ["app/**", "components/**", "pages/**"]
14
+ gotcha_sections: ["Frontend", "React"]
15
+ pattern_sections: ["Frontend", "Components"]
16
+ tests:
17
+ paths: ["**/*.test.*", "**/*.spec.*", "__tests__/**"]
18
+ gotcha_sections: ["Testing"]
19
+ pattern_sections: ["Testing"]
20
+ config:
21
+ paths: [".github/**", "Dockerfile*", "docker-compose*", "*.config.*"]
22
+ gotcha_sections: ["CI", "Config"]
23
+ pattern_sections: ["CI"]
24
+
25
+ quality_checks:
26
+ backend:
27
+ - name: "Typecheck"
28
+ command: "npx tsc --noEmit 2>&1 | tail -20"
29
+ frontend:
30
+ - name: "Typecheck"
31
+ command: "npx tsc --noEmit 2>&1 | tail -20"
32
+
33
+ diff_scan:
34
+ - pattern: "console\\.log"
35
+ files: "*.ts,*.tsx,*.js,*.jsx"
36
+ exclude: "*.test.*,*.spec.*"
37
+ severity: CRITICAL
38
+ message: "console.log in production code"
39
+ - pattern: "\\.env"
40
+ files: "*"
41
+ severity: CRITICAL
42
+ message: ".env file should not be committed"
43
+ - pattern: "any\\b"
44
+ files: "*.ts,*.tsx"
45
+ exclude: "*.test.*,*.spec.*,*.d.ts"
46
+ severity: WARNING
47
+ message: "Explicit 'any' type — consider a specific type"
48
+
49
+ commit:
50
+ types: [feat, fix, refactor, docs, test, chore, perf]
51
+ format: "type(scope): message"
52
+
53
+ codeloop:
54
+ critical_frequency: 3
55
+ promote_frequency: 10
56
+ max_knowledge_lines: 200
@@ -0,0 +1,50 @@
1
+ # Codeloop Configuration
2
+ # Python starter
3
+
4
+ project:
5
+ name: "my-project"
6
+
7
+ scopes:
8
+ backend:
9
+ paths: ["src/**", "app/**", "lib/**"]
10
+ gotcha_sections: ["Backend", "Database", "API"]
11
+ pattern_sections: ["Backend", "API"]
12
+ tests:
13
+ paths: ["tests/**", "**/*_test.py", "**/test_*.py"]
14
+ gotcha_sections: ["Testing"]
15
+ pattern_sections: ["Testing"]
16
+ config:
17
+ paths: [".github/**", "Dockerfile*", "docker-compose*", "pyproject.toml", "setup.py"]
18
+ gotcha_sections: ["CI", "Config"]
19
+ pattern_sections: ["CI"]
20
+
21
+ quality_checks:
22
+ backend:
23
+ - name: "Type check"
24
+ command: "mypy src/ 2>&1 | tail -20"
25
+ - name: "Lint"
26
+ command: "ruff check src/ 2>&1 | tail -20"
27
+
28
+ diff_scan:
29
+ - pattern: "print\\("
30
+ files: "*.py"
31
+ exclude: "test_*,*_test.py,conftest.py"
32
+ severity: WARNING
33
+ message: "print() in production code — use logging"
34
+ - pattern: "import pdb"
35
+ files: "*.py"
36
+ severity: CRITICAL
37
+ message: "Debugger import left in code"
38
+ - pattern: "\\.env"
39
+ files: "*"
40
+ severity: CRITICAL
41
+ message: ".env file should not be committed"
42
+
43
+ commit:
44
+ types: [feat, fix, refactor, docs, test, chore, perf]
45
+ format: "type(scope): message"
46
+
47
+ codeloop:
48
+ critical_frequency: 3
49
+ promote_frequency: 10
50
+ max_knowledge_lines: 200
@@ -0,0 +1,5 @@
1
+ {
2
+ "version": 1,
3
+ "columns": ["backlog", "planned", "in_progress", "review", "done"],
4
+ "tasks": []
5
+ }
@@ -0,0 +1,13 @@
1
+ # Gotchas
2
+
3
+ Cross-cutting gotchas discovered during development. Sorted by frequency (highest first).
4
+ New entries added via `/commit` and `/reflect`. Frequency incremented when re-encountered.
5
+
6
+ Frequency determines severity in `/commit` review:
7
+ - `freq >= 3` → CRITICAL (blocks commit unless overridden)
8
+ - `freq 1-2` → WARNING (non-blocking)
9
+ - `freq >= 10` → Consider promoting to `rules.md`
10
+
11
+ ---
12
+
13
+ <!-- Add gotchas below, organized by section. Sections should match your config.yaml gotcha_sections. -->
@@ -0,0 +1,15 @@
1
+ # Patterns
2
+
3
+ Proven patterns used in this project. Confidence levels based on adoption.
4
+ New entries added via `/commit` and `/reflect`.
5
+
6
+ Confidence levels:
7
+ - **HIGH** — Used consistently, well-tested
8
+ - **MEDIUM** — Used in some places, works well
9
+ - **LOW** — Experimental, needs more validation
10
+
11
+ HIGH-confidence patterns are checked during `/commit` review — deviations trigger warnings.
12
+
13
+ ---
14
+
15
+ <!-- Add patterns below, organized by section. Sections should match your config.yaml pattern_sections. -->
@@ -0,0 +1,49 @@
1
+ # Operating Principles
2
+
3
+ These principles guide how Claude Code works in this project. They're loaded as context for all flywheel skills.
4
+
5
+ ---
6
+
7
+ ## 1. Plan Mode Default
8
+
9
+ 3+ steps = plan first. Write the plan to `tasks/todo.md`. Get approval before building. STOP and re-plan if things go sideways.
10
+
11
+ ## 2. Subagent Strategy
12
+
13
+ Offload research and exploration to subagents. One task per subagent. Keep the main context clean for implementation work.
14
+
15
+ ## 3. Self-Improvement Loop
16
+
17
+ After any correction or discovery:
18
+ - Capture gotchas and patterns via `/commit` or `/reflect`
19
+ - Frequency = severity: the more something recurs, the more critical it becomes
20
+ - `freq >= 3` = CRITICAL in next `/commit` review
21
+
22
+ ## 4. Verification Before Done
23
+
24
+ Never mark a task complete without proof. Run tests, check logs, verify the output. Ask yourself: "Would a staff engineer approve this?"
25
+
26
+ ## 5. Demand Elegance (Balanced)
27
+
28
+ For non-trivial changes, pause and ask "is there a more elegant way?" Skip this for simple fixes — don't over-engineer.
29
+
30
+ ## 6. Autonomous Bug Fixing
31
+
32
+ Given a bug? Just fix it. Zero hand-holding. Point at evidence, resolve it. Don't ask for permission to investigate.
33
+
34
+ ## 7. Simplicity First
35
+
36
+ Minimal code, minimal impact. Touch only what's necessary. The right amount of complexity is the minimum needed for the current task.
37
+
38
+ ## 8. No Laziness
39
+
40
+ Root causes only. Don't patch symptoms. Don't skip hard problems. Don't leave broken things behind.
41
+
42
+ ## 9. TDD Default
43
+
44
+ Write acceptance criteria first. Define tests before code. Follow RED → GREEN → REFACTOR:
45
+ 1. **RED** — Write failing tests that define what "done" looks like
46
+ 2. **GREEN** — Write the minimum code to make tests pass
47
+ 3. **REFACTOR** — Clean up while tests stay green
48
+
49
+ Not every change needs full TDD, but any non-trivial feature or bug fix benefits from defining expected behavior before implementation.
@@ -0,0 +1,23 @@
1
+ # Rules
2
+
3
+ Non-negotiable rules for this project. These are always loaded as CRITICAL by `/commit`.
4
+
5
+ Add project-specific rules here. Start with these universals:
6
+
7
+ ---
8
+
9
+ ## 1. Errors = Failure
10
+
11
+ Never rationalize error codes. 404/401/500 means something is broken — fix it or report it.
12
+
13
+ ## 2. Verify Before Claiming Done
14
+
15
+ A feature "works" when the **user can see/use the result**, not when code compiles. Run the tests, check the output, prove it works.
16
+
17
+ ## 3. Own It
18
+
19
+ Complete ALL tasks. No "next steps" lists, no "TODO later", no deferring. If something is broken, fix it. If something is missing, add it.
20
+
21
+ ## 4. No Destructive Operations Without Confirmation
22
+
23
+ `git push`, `git stash`, `git rebase`, force deletes — always confirm with the user first. These affect shared state and can destroy work.
@@ -0,0 +1,245 @@
1
+ ---
2
+ description: Review + reflect + commit in one flow
3
+ argument-hint: [type] [scope] [message] OR [--wip]
4
+ allowed-tools: Bash(git:*), Read, Edit, Write, Glob, Grep, AskUserQuestion
5
+ ---
6
+
7
+ <!-- codeloop-version: 0.2.0 -->
8
+
9
+ # /commit
10
+
11
+ Three-phase commit: **Review → Reflect → Commit**.
12
+
13
+ ## Quick Usage
14
+
15
+ ```bash
16
+ /commit # Full flow: review → reflect → commit (auto-generate message)
17
+ /commit feat auth "add login endpoints" # Full flow with explicit message
18
+ /commit --wip # Skip review + reflect, WIP commit with --no-verify
19
+ ```
20
+
21
+ ---
22
+
23
+ ## Phase 1: Review
24
+
25
+ ### 1.1 Get the diff
26
+
27
+ ```bash
28
+ git diff HEAD --name-only
29
+ git status --short
30
+ ```
31
+
32
+ If nothing to commit → say "Nothing to commit" and **stop**.
33
+
34
+ ### 1.2 Determine scopes from changed paths
35
+
36
+ Read `.codeloop/config.yaml` and map changed files to scopes using the `scopes` section:
37
+
38
+ ```yaml
39
+ scopes:
40
+ backend:
41
+ paths: ["src/**", "lib/**"]
42
+ gotcha_sections: ["Backend", "Database"]
43
+ pattern_sections: ["Backend", "API"]
44
+ ```
45
+
46
+ Match each changed file against scope paths. A file can match multiple scopes.
47
+
48
+ If no config.yaml exists, use a single "all" scope that loads everything.
49
+
50
+ ### 1.3 Load dynamic rubrics
51
+
52
+ Read these files and extract rules matching the active scopes:
53
+
54
+ 1. **`.codeloop/rules.md`** — all rules are always CRITICAL
55
+ 2. **`.codeloop/gotchas.md`** — items with `freq >= 3` in matching sections → CRITICAL; `freq 1-2` → WARNING
56
+ 3. **`.codeloop/patterns.md`** — HIGH-confidence patterns in matching sections → expectations (deviation = WARNING)
57
+
58
+ Only load sections relevant to the active scopes. Don't review the entire gotchas file for a docs-only change.
59
+
60
+ **Scope → rubric section mapping** comes from `config.yaml`:
61
+ - `gotcha_sections` defines which gotcha sections to load for that scope
62
+ - `pattern_sections` defines which pattern sections to load for that scope
63
+
64
+ ### 1.4 Quality checks
65
+
66
+ Read `quality_checks` from `.codeloop/config.yaml` and run checks for active scopes:
67
+
68
+ ```yaml
69
+ quality_checks:
70
+ backend:
71
+ - name: "Typecheck"
72
+ command: "npx tsc --noEmit 2>&1 | tail -20"
73
+ ```
74
+
75
+ If any check **fails** → report as a CRITICAL finding.
76
+
77
+ If no quality_checks defined → skip silently.
78
+
79
+ ### 1.5 Scan diff for violations
80
+
81
+ Read `diff_scan` rules from `.codeloop/config.yaml`:
82
+
83
+ ```yaml
84
+ diff_scan:
85
+ - pattern: "console\\.log"
86
+ files: "*.ts,*.js"
87
+ exclude: "*.test.*"
88
+ severity: CRITICAL
89
+ message: "console.log in production code"
90
+ ```
91
+
92
+ For each rule, scan the actual diff content for matches.
93
+
94
+ If no diff_scan rules → skip silently.
95
+
96
+ ### 1.6 Output findings
97
+
98
+ ```
99
+ ## Review
100
+
101
+ **Scopes**: backend, frontend
102
+ **Rubrics loaded**: 6 CRITICAL, 3 WARNING from gotchas; 4 patterns checked
103
+
104
+ | Sev | Finding | File |
105
+ |-----|---------|------|
106
+ | CRITICAL | console.log in service code | src/foo/bar.ts:42 |
107
+ | CRITICAL | Typecheck failed (2 errors) | — |
108
+ | WARNING | Hardcoded string | src/foo/bar.ts:18 |
109
+ | CLEAN | Build passed | — |
110
+
111
+ **Verdict**: BLOCKED (2 critical)
112
+ ```
113
+
114
+ Verdicts:
115
+ - **CLEAN** — no issues, proceed
116
+ - **WARNINGS** — non-blocking suggestions, proceed to commit
117
+ - **BLOCKED** — critical issues found, must fix before commit
118
+
119
+ ### 1.7 If BLOCKED
120
+
121
+ Use AskUserQuestion with options:
122
+ - **Fix issues** — stop here, user fixes and re-runs `/commit`
123
+ - **Commit anyway** — override, proceed to Phase 2
124
+ - **Abort** — stop entirely
125
+
126
+ ---
127
+
128
+ ## Phase 2: Reflect (lightweight)
129
+
130
+ Quickly scan this session for:
131
+ 1. **Gotchas** — unexpected behavior, hidden dependencies, bugs found
132
+ 2. **Patterns** — approaches that worked well, shortcuts discovered
133
+
134
+ If anything found → use AskUserQuestion with multiSelect to let user pick what to save.
135
+
136
+ Save selected items to `.codeloop/gotchas.md` or `.codeloop/patterns.md`.
137
+
138
+ New gotchas get `[freq:1]`. Place them in the appropriate section (create section if needed).
139
+
140
+ If nothing worth saving → skip silently, move to Phase 3.
141
+
142
+ ---
143
+
144
+ ## Phase 3: Commit
145
+
146
+ ### 3.1 Stage files
147
+
148
+ ```bash
149
+ git add -A
150
+ git status --short
151
+ ```
152
+
153
+ Show what will be committed.
154
+
155
+ ### 3.2 Build commit message
156
+
157
+ **If type/scope/message provided as arguments:**
158
+ ```
159
+ $TYPE($SCOPE): $MESSAGE
160
+ ```
161
+
162
+ **If auto-generating**, analyze the staged diff:
163
+ - **Type**: Read allowed types from `commit.types` in config.yaml (default: feat, fix, refactor, docs, test, chore, perf)
164
+ - **Scope**: primary directory/feature from changed files
165
+ - **Message**: brief description of the "why", not the "what"
166
+
167
+ For large commits (10+ files or multiple features), include a body with grouped bullet points.
168
+
169
+ ### 3.3 Create commit
170
+
171
+ ```bash
172
+ git commit -m "$(cat <<'EOF'
173
+ type(scope): message
174
+
175
+ optional body
176
+ EOF
177
+ )"
178
+ ```
179
+
180
+ ### 3.4 Board sync
181
+
182
+ If `.codeloop/board.json` exists:
183
+ - Read the board JSON
184
+ - Find the active task: first task with status `in_progress`, then `review`, then `planned` (in that priority order)
185
+ - If no task found, warn: "Board sync skipped — no active task found in board.json" (non-blocking, commit still succeeds)
186
+ - Append the new commit SHA to the task's `commits` array
187
+ - Write the updated board back to `.codeloop/board.json`
188
+
189
+ ### 3.5 Report result
190
+
191
+ ```
192
+ ## Committed
193
+
194
+ **Hash**: abc1234
195
+ **Message**: feat(auth): add login endpoints
196
+ **Files**: 5 changed, +120, -30
197
+ ```
198
+
199
+ ---
200
+
201
+ ## WIP Mode (`--wip`)
202
+
203
+ Skip Phase 1 and Phase 2 entirely:
204
+
205
+ ```bash
206
+ git add -A
207
+ git commit -m "chore: WIP" --no-verify
208
+ ```
209
+
210
+ Report the commit hash and stop.
211
+
212
+ ---
213
+
214
+ ## Rubric Evolution
215
+
216
+ The review gets smarter over time:
217
+
218
+ ```
219
+ Session work → discover gotcha → Phase 2 saves to gotchas.md (freq:1)
220
+ → re-encountered in future sessions → freq increases via /reflect
221
+ → next /commit Phase 1 picks it up at higher severity (freq >= 3 = CRITICAL)
222
+ ```
223
+
224
+ No separate rubrics file. `gotchas.md` IS the rubrics source. Frequency = severity.
225
+
226
+ ---
227
+
228
+ ## Commit Types
229
+
230
+ | Type | When |
231
+ |------|------|
232
+ | `feat` | New feature or capability |
233
+ | `fix` | Bug fix |
234
+ | `refactor` | Code restructuring, no behavior change |
235
+ | `docs` | Documentation only |
236
+ | `test` | Adding/updating tests |
237
+ | `chore` | Maintenance, deps, config |
238
+ | `perf` | Performance improvement |
239
+
240
+ ## Safety Rules
241
+
242
+ 1. **ALWAYS `git add -A` first** — never leave uncommitted work
243
+ 2. **Never amend pushed commits**
244
+ 3. **Never skip hooks** (except `--wip`)
245
+ 4. **Never push** — `/commit` only creates local commits
@@ -0,0 +1,77 @@
1
+ ---
2
+ description: Track task progress — read/update tasks/todo.md
3
+ allowed-tools: Read, Write, Edit, Glob, Grep
4
+ ---
5
+
6
+ <!-- codeloop-version: 0.2.0 -->
7
+
8
+ # /manage
9
+
10
+ Track progress on the current task. Read and update `tasks/todo.md`.
11
+
12
+ ## Usage
13
+
14
+ ```bash
15
+ /manage # Show current task status
16
+ /manage done <n> # Mark step N as complete
17
+ /manage add <step> # Add a new step
18
+ /manage close # Mark task as done (moves to Done column)
19
+ /manage summary # Generate progress summary
20
+ ```
21
+
22
+ ## How It Works
23
+
24
+ ### Show Status (default)
25
+
26
+ 1. Read `tasks/todo.md`
27
+ 2. Show:
28
+ - Task title and context
29
+ - Checklist with completion status
30
+ - Next uncompleted step highlighted
31
+
32
+ ### Mark Complete (`done <n>`)
33
+
34
+ 1. Read `tasks/todo.md`
35
+ 2. Change step N from `- [ ]` to `- [x]`
36
+ 3. **Board sync** — if `.codeloop/board.json` exists:
37
+ - Read the board JSON
38
+ - Find the matching task: search by exact title from `tasks/todo.md`'s `# Task:` heading. If no exact match, use the first task with status `planned`, `in_progress`, or `backlog` (in that priority order)
39
+ - If no task found, warn: "Board sync skipped — no matching task found in board.json"
40
+ - Update the corresponding step's `done` field to `true`
41
+ - Update task status based on progress:
42
+ - First step marked done → set status to `in_progress`
43
+ - All steps marked done → set status to `review`
44
+ - Write the updated board back to `.codeloop/board.json`
45
+ 4. If all steps complete, show completion summary
46
+
47
+ ### Close Task (`close`)
48
+
49
+ 1. Read `tasks/todo.md` — verify all steps are `- [x]` (complete)
50
+ 2. If steps remain incomplete, warn: "N steps still unchecked — close anyway?" (use AskUserQuestion)
51
+ 3. **Board sync** — if `.codeloop/board.json` exists:
52
+ - Find the matching task (same lookup as `done <n>`)
53
+ - Set task status to `done`
54
+ - Write the updated board back to `.codeloop/board.json`
55
+ 4. Archive: rename `tasks/todo.md` to `tasks/done/<title-slug>.md` (create dir if needed)
56
+ 5. Show: "Task closed. Board updated."
57
+
58
+ ### Add Step (`add <step>`)
59
+
60
+ 1. Read `tasks/todo.md`
61
+ 2. Append new step to the plan
62
+ 3. Show updated checklist
63
+
64
+ ### Summary (`summary`)
65
+
66
+ Generate a concise summary of:
67
+ - What's done
68
+ - What's remaining
69
+ - Any blockers or gotchas encountered
70
+ - Time/effort estimate for remaining work
71
+
72
+ ## Rules
73
+
74
+ - **tasks/todo.md is the source of truth.** All task state lives here.
75
+ - **Update as you go.** Don't wait until the end to mark things complete.
76
+ - **Be honest about blockers.** If stuck, say so in the summary.
77
+ - **Verify before marking done.** Each step should have evidence of completion.
@@ -0,0 +1,83 @@
1
+ ---
2
+ description: Plan a task — write spec to tasks/todo.md, enter plan mode
3
+ allowed-tools: Read, Write, Edit, Glob, Grep, AskUserQuestion, EnterPlanMode
4
+ ---
5
+
6
+ <!-- codeloop-version: 0.2.0 -->
7
+
8
+ # /plan
9
+
10
+ Plan before building. Write specs to `tasks/todo.md`, get approval, then execute.
11
+
12
+ ## Usage
13
+
14
+ ```bash
15
+ /plan # Start planning (enter plan mode)
16
+ /plan <description> # Plan a specific task
17
+ ```
18
+
19
+ ## Phase 1: Understand
20
+
21
+ 1. Read the task description (from argument or ask the user)
22
+ 2. Read `.codeloop/config.yaml` for project context (scopes, conventions)
23
+ 3. Read `.codeloop/gotchas.md` — scan for relevant gotchas that could affect the plan
24
+ 4. Read `.codeloop/patterns.md` — check for established patterns to follow
25
+
26
+ ## Phase 2: Plan
27
+
28
+ Enter plan mode and explore the codebase:
29
+
30
+ 1. Identify affected files and modules
31
+ 2. Check for existing patterns that should be followed
32
+ 3. Consider gotchas that apply to the planned changes
33
+ 4. Write the plan to `tasks/todo.md` using test-first structure:
34
+
35
+ ```markdown
36
+ # Task: <title>
37
+
38
+ ## Context
39
+ <Why this task exists, what problem it solves>
40
+
41
+ ## Acceptance Criteria
42
+ - <criterion 1 — what must be true when done>
43
+ - <criterion 2>
44
+
45
+ ## Tests (RED)
46
+ Define failing tests before writing implementation code:
47
+ - <test case 1>
48
+ - <test case 2>
49
+
50
+ ## Plan
51
+ - [ ] Step 1: Write tests for acceptance criteria (RED)
52
+ - [ ] Step 2: Write minimum code to pass tests (GREEN)
53
+ - [ ] Step 3: Refactor while tests stay green
54
+ - [ ] ...
55
+
56
+ ## Gotchas to Watch
57
+ - <relevant gotchas from .codeloop/gotchas.md>
58
+
59
+ ## Files to Change
60
+ - `path/to/file.ts` — <what changes>
61
+ ```
62
+
63
+ 5. **Board sync** — if `.codeloop/board.json` exists, create a task on the board:
64
+ - Read `.codeloop/board.json`
65
+ - Add a new task with `status: "planned"`, title matching the plan title, and steps matching the plan checklist
66
+ - Write the updated board back to `.codeloop/board.json`
67
+
68
+ 6. Exit plan mode for user approval
69
+
70
+ ## Phase 3: Execute
71
+
72
+ After approval, work through the plan:
73
+
74
+ 1. Mark each step as you complete it (update `tasks/todo.md`)
75
+ 2. If the plan needs adjustment, update it and explain why
76
+ 3. Verify each step works before moving to the next
77
+
78
+ ## Rules
79
+
80
+ - **3+ steps = always plan first.** Don't wing it.
81
+ - **Stop and re-plan if things go sideways.** The plan is a living document.
82
+ - **Staff engineer bar.** Before marking complete: "Would a staff engineer approve this?"
83
+ - **Gotchas are warnings.** Check `.codeloop/gotchas.md` before each risky step.