compounding-loop 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +93 -3
- package/bin/loop.js +2 -0
- package/dist/cli/dashboard.js +52 -0
- package/dist/cli/dashboard.js.map +1 -0
- package/dist/cli/gh.js +29 -0
- package/dist/cli/gh.js.map +1 -0
- package/dist/cli/index.js +144 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.js +72 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/loops.js +72 -0
- package/dist/cli/loops.js.map +1 -0
- package/dist/cli/new.js +54 -0
- package/dist/cli/new.js.map +1 -0
- package/dist/cli/run.js +81 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/core/blocked.js +42 -0
- package/dist/core/blocked.js.map +1 -0
- package/dist/core/brief.js +91 -0
- package/dist/core/brief.js.map +1 -0
- package/dist/core/gh.js +2 -0
- package/dist/core/gh.js.map +1 -0
- package/dist/core/init.js +59 -0
- package/dist/core/init.js.map +1 -0
- package/dist/core/repo.js +81 -0
- package/dist/core/repo.js.map +1 -0
- package/dist/core/rounds.js +50 -0
- package/dist/core/rounds.js.map +1 -0
- package/dist/core/runPrompt.js +31 -0
- package/dist/core/runPrompt.js.map +1 -0
- package/dist/core/status.js +21 -0
- package/dist/core/status.js.map +1 -0
- package/dist/core/table.js +24 -0
- package/dist/core/table.js.map +1 -0
- package/dist/core/template.js +29 -0
- package/dist/core/template.js.map +1 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/dist/server/data.js +36 -0
- package/dist/server/data.js.map +1 -0
- package/dist/server/events.js +105 -0
- package/dist/server/events.js.map +1 -0
- package/dist/server/five-sites.json +3071 -0
- package/dist/server/health.js +133 -0
- package/dist/server/health.js.map +1 -0
- package/dist/server/index.js +134 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/loops.js +142 -0
- package/dist/server/loops.js.map +1 -0
- package/dist/server/settings.js +25 -0
- package/dist/server/settings.js.map +1 -0
- package/dist/server/static-export.js +28 -0
- package/dist/server/static-export.js.map +1 -0
- package/dist/server/static.js +80 -0
- package/dist/server/static.js.map +1 -0
- package/dist/web/assets/index-BDdtnG33.js +49 -0
- package/dist/web/assets/index-D3-N8DN4.css +2 -0
- package/dist/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/dist/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/dist/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/dist/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/dist/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/dist/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/dist/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/web/favicon.svg +1 -0
- package/dist/web/index.html +14 -0
- package/dist/web/logo.svg +1 -0
- package/method/COMPOUNDING_LOOP.md +569 -0
- package/method/example/K-0001.md +16 -0
- package/method/knowledge-index.md +5 -0
- package/method/operating-card.md +40 -0
- package/method/retro.md +10 -0
- package/method/reviewer-prompt.md +13 -0
- package/method/stuck-protocol.md +12 -0
- package/method/task-template.md +41 -0
- package/package.json +71 -4
- package/plugin/.claude-plugin/plugin.json +7 -0
- package/plugin/commands/handoff.md +10 -0
- package/plugin/commands/loop-init.md +13 -0
- package/plugin/commands/retro.md +11 -0
- package/plugin/commands/stuck.md +10 -0
- package/runners/github-actions/loop.yml +51 -0
- package/runners/local/README.md +8 -0
- package/runners/local/crontab.txt +6 -0
- package/runners/local/task-scheduler.xml +32 -0
- package/runners/routine/README.md +19 -0
- package/runners/routine/prompt.md +13 -0
- package/templates/chrome-extension/CLAUDE.md +18 -0
- package/templates/chrome-extension/IDEA.md +22 -0
- package/templates/chrome-extension/extension/background.js +5 -0
- package/templates/chrome-extension/extension/manifest.json +9 -0
- package/templates/chrome-extension/extension/popup.css +3 -0
- package/templates/chrome-extension/extension/popup.html +15 -0
- package/templates/chrome-extension/extension/popup.js +16 -0
- package/templates/chrome-extension/gitignore +6 -0
- package/templates/chrome-extension/package.json +12 -0
- package/templates/chrome-extension/playwright.config.js +22 -0
- package/templates/chrome-extension/scripts/check.mjs +51 -0
- package/templates/chrome-extension/scripts/test.mjs +59 -0
- package/templates/chrome-extension/tests/popup.spec.js +37 -0
- package/templates/static-site/.ai/index.md +5 -0
- package/templates/static-site/.ai/log.md +3 -0
- package/templates/static-site/.ai/loop-prompt.md +10 -0
- package/templates/static-site/.ai/task.md +27 -0
- package/templates/static-site/.gitattributes +1 -0
- package/templates/static-site/CLAUDE.md +113 -0
- package/templates/static-site/IDEA.md +36 -0
- package/templates/static-site/gitignore +6 -0
- package/templates/static-site/netlify.toml +14 -0
- package/templates/static-site/package.json +14 -0
- package/templates/static-site/playwright.config.js +27 -0
- package/templates/static-site/scripts/check.mjs +188 -0
- package/templates/static-site/scripts/serve.mjs +44 -0
- package/templates/static-site/scripts/test.mjs +59 -0
- package/templates/static-site/site/index.html +23 -0
- package/templates/static-site/site/robots.txt +4 -0
- package/templates/static-site/site/sitemap.xml +4 -0
- package/templates/static-site/tests/pages.spec.js +21 -0
- package/templates/static-site/vercel.json +19 -0
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
# The Compounding Loop
|
|
2
|
+
|
|
3
|
+
*A universal method for working with AI agents. Built for coding first, but the same shape works for writing, research and analysis.*
|
|
4
|
+
*v1 · 2026-10-05*
|
|
5
|
+
|
|
6
|
+
> **How to read this file.** Part A (the Operating Card) is short and is meant to be loaded into every session: paste it into your always-loaded rules file (`CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, `.cursor/rules/`, …). Everything after it is reference. The AI reads a section only when that moment comes. The file follows its own rule: a small core that is always on, and everything else loaded on demand.
|
|
7
|
+
|
|
8
|
+
**Contents**
|
|
9
|
+
|
|
10
|
+
- Part A: Operating Card (always loaded)
|
|
11
|
+
- Part B: The method
|
|
12
|
+
1. The objective
|
|
13
|
+
2. Two ideas everything follows from
|
|
14
|
+
3. The laws
|
|
15
|
+
4. File layout
|
|
16
|
+
5. The task contract
|
|
17
|
+
6. Verification
|
|
18
|
+
7. Memory
|
|
19
|
+
8. Triggers
|
|
20
|
+
9. The loop: handoff, resume, stuck
|
|
21
|
+
10. The civilization: subagents and model tiers
|
|
22
|
+
11. Self-prompting
|
|
23
|
+
12. Finishing: retro, promotion ladder, cleanup
|
|
24
|
+
13. Measurement
|
|
25
|
+
14. The human's role
|
|
26
|
+
15. Commands
|
|
27
|
+
- Part C: Templates
|
|
28
|
+
- Part D: Setup and adoption order
|
|
29
|
+
- Part E: Limits, open questions, where the ideas come from
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Part A: Operating Card
|
|
34
|
+
|
|
35
|
+
> Copy this section into your always-loaded rules file. Keep it under ~60 lines.
|
|
36
|
+
> The § numbers point to Part B of `COMPOUNDING_LOOP.md`.
|
|
37
|
+
|
|
38
|
+
**Objective:** the most verified-correct results per minute of the human's attention. Tokens are the cheapest resource. A wrong result that looks right is the most expensive one.
|
|
39
|
+
|
|
40
|
+
**Start of every session**
|
|
41
|
+
1. Read `.ai/index.md`. Open a knowledge entry only when it's relevant to what you're doing.
|
|
42
|
+
2. If `.ai/task.md` exists, run the resume protocol (§9.2) before anything else.
|
|
43
|
+
|
|
44
|
+
**Before work**
|
|
45
|
+
3. Size the task. Tiny: just do it. Medium: contract + checks. Large or unclear: plan, get approval, then loop.
|
|
46
|
+
4. For medium and large tasks, write the contract (§5): goal, done-when (checkable by a command), constraints, out of scope. Ask all clarifying questions at once, before starting.
|
|
47
|
+
|
|
48
|
+
**During work**
|
|
49
|
+
5. One unit of work at a time. Run the checks after each unit. You never declare done; the checks do.
|
|
50
|
+
6. Write a note the moment you learn something, marked CONFIRMED or GUESS. Don't save it for the end.
|
|
51
|
+
7. After any error, search `.ai/index.md` for the error text before trying a fix.
|
|
52
|
+
8. Before editing a file, check the index for entries about that path.
|
|
53
|
+
9. Send reading-heavy work (search, docs, logs, review) to subagents that report back in 10 lines or fewer. Keep code-writing in one thread.
|
|
54
|
+
10. Same failure twice: stop and run the stuck protocol (§9.3). Don't retry a variant.
|
|
55
|
+
11. If reality contradicts the plan or contract, stop and report. Don't silently work around it.
|
|
56
|
+
12. Point to code and docs (`path:line`). Never copy them into notes.
|
|
57
|
+
|
|
58
|
+
**Context**
|
|
59
|
+
13. At ~50–60% context, or when a unit is done and the next one is big: run the handoff (§9.1), then tell the human the next window is ready.
|
|
60
|
+
|
|
61
|
+
**Finishing**
|
|
62
|
+
14. When the checks pass, run the retro (§12): propose promotions, flag stale entries, log the task, and delete `.ai/task.md` after approval.
|
|
63
|
+
|
|
64
|
+
**Never**
|
|
65
|
+
- Mark your own work done without the checks passing.
|
|
66
|
+
- Treat a GUESS from an earlier window as fact.
|
|
67
|
+
- Delete or rewrite CONFIRMED knowledge without new evidence.
|
|
68
|
+
- Change this card without the human's approval.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Part B: The method
|
|
73
|
+
|
|
74
|
+
### 1. The objective
|
|
75
|
+
|
|
76
|
+
Ranked by real cost, most expensive first:
|
|
77
|
+
|
|
78
|
+
1. **Wrong results that look right.** You find out late, and everything built on top has to be redone.
|
|
79
|
+
2. **Human attention.** Explaining, re-explaining, watching, reviewing.
|
|
80
|
+
3. **Waiting time.**
|
|
81
|
+
4. **Tokens and money.** The cheapest by far, and context that stays the same between calls is cached at a reduced rate.
|
|
82
|
+
|
|
83
|
+
So the goal is **the most verified-correct results per minute of human attention.**
|
|
84
|
+
|
|
85
|
+
Trim context when it hurts quality (noise, stale notes, contradictions), not to save tokens. Compressing a note into keywords saves a few hundred tokens out of a session that uses 50–150k, and throws away the *why*, which is the part that prevents repeated mistakes. That's a net loss.
|
|
86
|
+
|
|
87
|
+
### 2. Two ideas everything follows from
|
|
88
|
+
|
|
89
|
+
**Compounding.** Most methods make one task efficient. This one is built so that every task makes the next one cheaper. Every mistake gets fixed twice: once in the code, and once in the system (a note, a trigger, or best of all an automated check), so it can't happen again.
|
|
90
|
+
|
|
91
|
+
**Sparse activation.** Wake only what the moment needs. Large AI models already work this way inside: in a mixture-of-experts model, only a few expert sub-networks run for each token. This method applies the same principle at every level:
|
|
92
|
+
|
|
93
|
+
| Level | Dense (wasteful) | Sparse (this method) |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| Memory | Load every rule every session | A short index, plus triggers that fire at the moment of relevance (§7, §8) |
|
|
96
|
+
| Context | One long window that slowly degrades | Fresh windows with handoffs; subagents for reading (§9, §10) |
|
|
97
|
+
| Compute | The strongest model for everything | The cheapest tier that passes the checks (§10) |
|
|
98
|
+
| Rules | Prose rules re-read forever | Automated checks that cost nothing until broken (§12) |
|
|
99
|
+
| Human attention | Watching the agent work | Four touchpoints (§14) |
|
|
100
|
+
|
|
101
|
+
### 3. The laws
|
|
102
|
+
|
|
103
|
+
1. **Nothing is done until a check says so.**
|
|
104
|
+
2. **Every window gets the context its task needs: no more, no less.**
|
|
105
|
+
3. **Confirmed and guessed are always labeled.** A guess from a confused window that a fresh window reads as fact is the most common way loops go wrong.
|
|
106
|
+
4. **Point to the truth; never copy it.** Copies go stale. The code doesn't.
|
|
107
|
+
5. **Keep knowledge as low on the ladder as it can go:** automated check > trigger > note > always-loaded rule.
|
|
108
|
+
6. **Write notes when you learn, not when you're tired.** The end of a long session is the worst moment to summarize.
|
|
109
|
+
7. **Same failure twice means change strategy, not retry.**
|
|
110
|
+
8. **Many readers, one writer.** Read in parallel. Write in one thread, unless the files don't overlap.
|
|
111
|
+
9. **Spend intelligence on the spec, save it on execution.** The better the instructions, the smaller the model that can carry them out.
|
|
112
|
+
10. **Measure, or you're guessing.**
|
|
113
|
+
|
|
114
|
+
### 4. File layout
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
CLAUDE.md / AGENTS.md / GEMINI.md ← Operating Card + project core (≤ ~150 lines total)
|
|
118
|
+
.ai/
|
|
119
|
+
index.md ← one line per knowledge entry (always loaded)
|
|
120
|
+
knowledge/ ← one entry per file (loaded on demand or by a trigger)
|
|
121
|
+
triggers.yaml ← machine-readable triggers, for tools with hooks
|
|
122
|
+
task.md ← the current task's handoff (exists only during a task)
|
|
123
|
+
plans/ ← plans for large, multi-window tasks
|
|
124
|
+
routing.md ← task type → model tier, with track record
|
|
125
|
+
log.md ← one line per finished task
|
|
126
|
+
~/.ai/libs/ ← cross-project knowledge, one file per library@major-version
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The **project core** sits next to the card in the rules file. It holds only:
|
|
130
|
+
- what the project is (2–3 lines)
|
|
131
|
+
- exact commands to install, run, test and build
|
|
132
|
+
- the handful of hard rules that apply to every task
|
|
133
|
+
- where things live
|
|
134
|
+
|
|
135
|
+
Everything else goes in `.ai/knowledge/`.
|
|
136
|
+
|
|
137
|
+
### 5. The task contract
|
|
138
|
+
|
|
139
|
+
Before any medium or large task, write:
|
|
140
|
+
|
|
141
|
+
- **Goal.** One sentence about the outcome, not the activity.
|
|
142
|
+
- **Done when.** Checks a script can run: tests pass, build succeeds, a command exits 0, a screenshot matches. If you can't write one, the task isn't understood yet: ask, or explore first.
|
|
143
|
+
- **Constraints.** What must not change, and what must be reused.
|
|
144
|
+
- **Out of scope.** What not to touch, even if it's tempting.
|
|
145
|
+
- **Questions.** All of them, in one batch, before starting. A question costs seconds. A wrong assumption costs a whole window.
|
|
146
|
+
|
|
147
|
+
For large tasks, write a plan in `.ai/plans/` where every step has its own done-when, and get approval before building. Changing a plan is cheap. Changing code isn't.
|
|
148
|
+
|
|
149
|
+
### 6. Verification
|
|
150
|
+
|
|
151
|
+
This is the biggest multiplier in the whole method. An agent that can check its own work can loop alone. One that can't turns the human into the checker.
|
|
152
|
+
|
|
153
|
+
- **Build checks before features.** Types, lint, tests, build, end-to-end or screenshot checks, a script that exits 0. Types are the cheapest check and also the cheapest documentation.
|
|
154
|
+
- **Keep checks fast.** A 10-second suite gets run 20 times. A 10-minute one gets skipped. Keep a fast subset for each unit and run the full suite at the end.
|
|
155
|
+
- **Write the test that proves done-when before writing the code.**
|
|
156
|
+
- **The writer never reviews itself.** Final review comes from a fresh window that didn't write the code, with an adversarial brief: *"Find the three most likely ways this is wrong, and check each one."*
|
|
157
|
+
- **Error messages are prompts.** When you write a custom check, make its failure message say how to fix the problem. The agent reads it at exactly the right moment.
|
|
158
|
+
- **Beyond code.** For writing, research or analysis, the checker is a rubric written in advance, plus a critic in a fresh window, plus checking claims against sources.
|
|
159
|
+
|
|
160
|
+
### 7. Memory
|
|
161
|
+
|
|
162
|
+
Five layers, each loaded differently:
|
|
163
|
+
|
|
164
|
+
| Layer | Holds | Loaded |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| Core | Operating Card + project core | Always. Small and unchanging, so it stays cached |
|
|
167
|
+
| Index | One line per knowledge entry | Always |
|
|
168
|
+
| Knowledge | Gotchas, facts, decisions, lessons, open questions | Only when relevant or triggered |
|
|
169
|
+
| Task state | `.ai/task.md` | Every window of the current task; deleted afterwards |
|
|
170
|
+
| Source of truth | Code, git history, test output, docs | Read when needed; never copied |
|
|
171
|
+
|
|
172
|
+
**Every knowledge entry has** a type, a status (CONFIRMED or GUESS), triggers, evidence, and two counters (times it fired, times it helped). The template is in Part C.
|
|
173
|
+
|
|
174
|
+
**Index lines are for routing, not content.** They carry just enough words to decide "do I need to open this?" and nothing more:
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
K-0017 gotcha ✔ MV3 service worker loses in-memory state after ~30s idle · files: src/background/**
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Cross-project knowledge is keyed by library and major version, not by project type.** At task start, read the dependency manifest (`package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`, …) and load the index lines from `~/.ai/libs/<library>@<major>.md` for each dependency. This has three advantages:
|
|
181
|
+
- No guessing about what "kind" of project this is.
|
|
182
|
+
- It combines on its own: a Next + Supabase + Tailwind project simply gets all three sets of notes.
|
|
183
|
+
- Notes expire when the major version changes, which is exactly when they tend to become wrong.
|
|
184
|
+
|
|
185
|
+
### 8. Triggers
|
|
186
|
+
|
|
187
|
+
Loading every rule at session start has a hidden flaw. By the time a rule matters, it's buried far back under everything since. A note that appears right next to the action is much harder to miss.
|
|
188
|
+
|
|
189
|
+
Triggers watch events the tool already sees, run outside the model, and cost nothing until they fire. Four kinds, most precise first:
|
|
190
|
+
|
|
191
|
+
| Trigger | Fires when | Example |
|
|
192
|
+
|---|---|---|
|
|
193
|
+
| **Error** | Command output matches a known error | `fetch is not a function` → "Node 16 has no built-in fetch; this project needs Node 18 (K-0042)" |
|
|
194
|
+
| **File** | The agent reads or edits a matching path | Editing `src/background/**` → the MV3 lifecycle note |
|
|
195
|
+
| **Command** | Before a matching command runs | `npm run build` → "run `npx prisma generate` first" (or just run it automatically) |
|
|
196
|
+
| **Topic** | The task text matches keywords | "persist auth" → a one-line hint pointing to K-0017 |
|
|
197
|
+
|
|
198
|
+
- **With hooks** (for example Claude Code): a small script matches each event against `.ai/triggers.yaml` and injects the entry. Error and file triggers run after tool calls; command triggers run before.
|
|
199
|
+
- **Without hooks:** manual trigger mode. Card rules 7 and 8 make the agent search the index after errors and before edits. It's less automatic but has the same effect, and works in any tool.
|
|
200
|
+
- **Precision beats coverage.** A trigger that fires often and doesn't help is noise. Track `fired` and `helped`, and fix or delete triggers that help less than about half the time.
|
|
201
|
+
|
|
202
|
+
### 9. The loop
|
|
203
|
+
|
|
204
|
+
One task takes one or more windows. In each window:
|
|
205
|
+
|
|
206
|
+
1. Start fresh. Load the core, the index and `task.md`.
|
|
207
|
+
2. Do one unit of work.
|
|
208
|
+
3. Run the checks.
|
|
209
|
+
4. Green: commit. Red: log the attempt with the reason, and revert.
|
|
210
|
+
5. Repeat until the window is ~50–60% full or the unit is done.
|
|
211
|
+
6. Hand off.
|
|
212
|
+
|
|
213
|
+
#### 9.1 Handoff protocol
|
|
214
|
+
|
|
215
|
+
The goal: a fresh window with zero memory of this one can continue at full quality.
|
|
216
|
+
|
|
217
|
+
1. Run the checks and record the actual results, not remembered ones.
|
|
218
|
+
2. Commit green work. Revert or stash red work, and say so. The next window must start from a known state.
|
|
219
|
+
3. Rewrite **Current state**: branch, commit, check status, the single next step, and what to read first.
|
|
220
|
+
4. Add to **Tried**: approach → result → *why* it failed. One line each. Never delete from Tried during a task.
|
|
221
|
+
5. Sort new knowledge into **Confirmed** (with how you know) and **Guesses** (with how to test them). Mark anything that applies beyond this task with `promote?` for the retro.
|
|
222
|
+
6. **Stranger test.** Reread the file as someone who knows nothing about this session. Could they continue without asking anything? Fix whatever fails.
|
|
223
|
+
7. Keep it to about one page. If it's longer, move the details into knowledge entries and link to them.
|
|
224
|
+
8. Tell the human three things: the file is ready, what you chose to leave out, and the next step.
|
|
225
|
+
|
|
226
|
+
#### 9.2 Resume protocol
|
|
227
|
+
|
|
228
|
+
1. Read the core, the index and `.ai/task.md`.
|
|
229
|
+
2. **Verify before trusting.** Compare Current state with reality (git status, git log, run the checks). Reality wins: if they disagree, fix the file and say so.
|
|
230
|
+
3. Treat Guesses as ideas to test, never as facts.
|
|
231
|
+
4. State the next step in one line, then do it.
|
|
232
|
+
|
|
233
|
+
#### 9.3 Stuck protocol
|
|
234
|
+
|
|
235
|
+
Triggered by the same failure twice, or by two windows with no progress toward done-when.
|
|
236
|
+
|
|
237
|
+
1. Stop. Write down every assumption you're making.
|
|
238
|
+
2. Test the weakest assumption with the cheapest possible experiment.
|
|
239
|
+
3. Try a structurally different approach, not a variant of what failed.
|
|
240
|
+
4. Fan out: run 2–3 independent attempts in separate git worktrees and keep the one that passes the checks.
|
|
241
|
+
5. Move up one model tier or effort level (§10).
|
|
242
|
+
6. Ask the human, with what was tried, the specific question, and your best guess.
|
|
243
|
+
|
|
244
|
+
**Hard cap:** if a task reaches about 5 windows without the checks passing, stop and review it with the human. Loops left alone go in circles.
|
|
245
|
+
|
|
246
|
+
### 10. The civilization: subagents and model tiers
|
|
247
|
+
|
|
248
|
+
Picture a society of specialists, each woken only when needed. The specialists are made with **context, not training**: a specialist is a general model plus a role brief, its triggered knowledge, and the tools and files it's allowed to use. Context is cheap to create. Trained models aren't.
|
|
249
|
+
|
|
250
|
+
**The tiers:**
|
|
251
|
+
|
|
252
|
+
| Tier | Who | Use for |
|
|
253
|
+
|---|---|---|
|
|
254
|
+
| 0 | Tools, not models: compiler, type checker, linter, tests, grep, formatter, scripts | Anything a tool can do exactly. Free, and never wrong within its domain. Always try this first |
|
|
255
|
+
| 1 | Small, fast model, low effort | Finding code, summarizing files and logs, extracting, classifying, mechanical edits from an exact spec, running checks and reporting |
|
|
256
|
+
| 2 | Mid-size model, medium effort | Implementing a fully specified unit; writing tests from a spec |
|
|
257
|
+
| 3 | Strongest model, high effort | Planning, splitting work, writing contracts, debugging unknown failures, architecture, final review, retro decisions |
|
|
258
|
+
|
|
259
|
+
**A task is safe for a lower tier only if both hold:**
|
|
260
|
+
- it's fully specified, with no judgment calls left
|
|
261
|
+
- a check can tell whether it worked
|
|
262
|
+
|
|
263
|
+
Without a check, never move a task down a tier. Cheap results that are wrong but look right are the most expensive outcome there is.
|
|
264
|
+
|
|
265
|
+
**Move up a tier instead of retrying.** A failed check moves the task one tier up. Trying the cheap tier first and moving up on failure is usually far cheaper than always using the top tier, but only if failures get caught.
|
|
266
|
+
|
|
267
|
+
**Routing learns from the log** (`.ai/routing.md`):
|
|
268
|
+
- New task types start at tier 3.
|
|
269
|
+
- Move a type down one tier after about 90% first-try passes over its last 10 tasks.
|
|
270
|
+
- Move it back up after 2 failures in its last 5.
|
|
271
|
+
|
|
272
|
+
**Roles:**
|
|
273
|
+
- **Orchestrator** (tier 3): owns the plan, writes the workers' contracts, reads their short reports, and makes the decisions. It doesn't read whole files itself.
|
|
274
|
+
- **Workers** (tier from the routing table): each gets only its contract and triggered notes, in a fresh window. It writes results to files and reports back where they are, plus 3 lines at most.
|
|
275
|
+
- **Checker** (tier 0): runs after every worker.
|
|
276
|
+
- **Reviewer** (tier 3, fresh window): reads the final diff before merge, and wrote none of it.
|
|
277
|
+
|
|
278
|
+
**Rules for splitting:**
|
|
279
|
+
- Split where a big input turns into a small output: search, docs, research, review, test runs. Don't split by job title. A frontend agent, backend agent and QA agent copy an org chart, and every handoff between them loses information.
|
|
280
|
+
- Many readers, one writer. Workers write in parallel only when their file lists don't overlap, each in its own worktree.
|
|
281
|
+
- Workers report surprises instead of improvising. All decisions stay with the orchestrator, so parallel workers never make conflicting hidden choices.
|
|
282
|
+
- Don't split small tasks (coordinating costs more than the work), tightly connected features (use one writer plus read-only helpers), or problems nobody understands yet (one agent explores first).
|
|
283
|
+
- Shared state lives in files (plan, `task.md`, knowledge), never only in messages between agents.
|
|
284
|
+
|
|
285
|
+
### 11. Self-prompting
|
|
286
|
+
|
|
287
|
+
The AI writes prompts for its next window, its subagents and its reviewers. It's the best author of those prompts, because it knows what it learned. It's also the worst judge of what it forgot to say. These rules close that gap:
|
|
288
|
+
|
|
289
|
+
1. **Write for a stranger.** The reader has none of your context. Test it: could they act correctly with only this text and the repo?
|
|
290
|
+
2. **Turn "quality" into checks.** "Best quality possible" is a wish. Translate it: what would make this fail review? Make those things the done-when.
|
|
291
|
+
3. **Give the why with every instruction.** Reasons carry over to cases the instruction didn't mention. Bare rules don't.
|
|
292
|
+
4. **Say what not to do:** the Tried list and the known traps.
|
|
293
|
+
5. **Mark what's uncertain** as a guess, along with how to test it.
|
|
294
|
+
6. **Point, don't paste.** Give paths, commands and `path:line`, not file contents.
|
|
295
|
+
7. **Give an exit.** Say what to do if the instructions don't match reality: stop and report.
|
|
296
|
+
8. **Set the output shape:** where to write, how long, and what to return.
|
|
297
|
+
9. **Every line must change what the reader does.** Cut the rest.
|
|
298
|
+
|
|
299
|
+
**What the AI can write for itself.** The sky really is the limit here, as long as the checks and approvals stay in place:
|
|
300
|
+
- the next window's prompt (the handoff)
|
|
301
|
+
- contracts for its subagents
|
|
302
|
+
- the checks (tests and scripts), before the code
|
|
303
|
+
- an adversarial brief for its reviewer, and a pre-mortem: *"Assume this shipped and broke. What's the most likely reason?"*
|
|
304
|
+
- triggers and knowledge entries for what it discovered
|
|
305
|
+
- proposed changes to its own rules, the card and the routing table
|
|
306
|
+
|
|
307
|
+
**Limits on self-modification.** The AI edits `task.md`, guesses and its own notes freely. Changes to the card, the project core, CONFIRMED knowledge and the routing thresholds are proposals that the human approves.
|
|
308
|
+
|
|
309
|
+
### 12. Finishing: retro, promotion ladder, cleanup
|
|
310
|
+
|
|
311
|
+
**Retro.** About 2 minutes, when the checks pass. The AI drafts it and the human approves.
|
|
312
|
+
1. List what was learned. For each item: does it apply beyond this task, or only to it? Is it confirmed or a guess? At what moment would it have helped (which file, command or error)?
|
|
313
|
+
2. Move general, confirmed items down the promotion ladder as far as they'll go.
|
|
314
|
+
3. Put library-level lessons in `~/.ai/libs/<library>@<major>.md`.
|
|
315
|
+
4. Delete `.ai/task.md`. Knowledge that only mattered for this task goes with it, on purpose.
|
|
316
|
+
5. Add a line to `.ai/log.md` (§13) and update `routing.md`.
|
|
317
|
+
|
|
318
|
+
**The promotion ladder:**
|
|
319
|
+
|
|
320
|
+
```
|
|
321
|
+
guess → confirmed note → note with a trigger → automated check
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
The last step is the goal: **the best memory is one the model never has to read.** "Never use `require()` here" becomes a lint rule. "Run prisma generate before build" becomes part of the build script. Then the prose note is deleted. A check costs nothing until it's broken, and it can't be ignored.
|
|
325
|
+
|
|
326
|
+
**Cleanup.** Every ~10 tasks, or when the human says "clean up memory":
|
|
327
|
+
- Archive entries that haven't fired in ~20 tasks.
|
|
328
|
+
- Fix or delete entries that fired and misled.
|
|
329
|
+
- Expire library notes when the library's major version changes.
|
|
330
|
+
- Merge duplicates. Resolve contradictions: newer evidence wins.
|
|
331
|
+
- Check that every `path:line` pointer still exists.
|
|
332
|
+
- Keep the card and project core under ~150 lines.
|
|
333
|
+
|
|
334
|
+
### 13. Measurement
|
|
335
|
+
|
|
336
|
+
Add one line per finished task to `.ai/log.md`:
|
|
337
|
+
|
|
338
|
+
```
|
|
339
|
+
2026-10-05 | add retry to fetchUser | M | human 6m | 2 windows | first-try ✔ | tier-ups 0 | $0.40 | repeat errors 0 | triggers 3 fired / 2 helped
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
What to watch:
|
|
343
|
+
- **Human minutes per task.** The main number.
|
|
344
|
+
- **Repeat-error rate:** errors that were already in your knowledge. This is the system's report card and should trend toward zero.
|
|
345
|
+
- **First-try pass rate per tier.** This feeds the routing table.
|
|
346
|
+
- **Trigger precision:** times helped ÷ times fired.
|
|
347
|
+
- **Windows until the checks pass**, and cost.
|
|
348
|
+
|
|
349
|
+
Prefer numbers from tools (check results, git, billing) over the AI's own account of how things went. Change one thing at a time and watch the numbers. Every threshold in this file (50–60%, 20 tasks, 90%, 5 windows) is a starting guess for your log to correct.
|
|
350
|
+
|
|
351
|
+
### 14. The human's role
|
|
352
|
+
|
|
353
|
+
Your attention goes to four places only:
|
|
354
|
+
|
|
355
|
+
1. **The contract:** intent and done-when.
|
|
356
|
+
2. **The plan:** for large tasks.
|
|
357
|
+
3. **The result:** the final diff and the check results.
|
|
358
|
+
4. **The retro:** approving what gets promoted.
|
|
359
|
+
|
|
360
|
+
Everything in between runs without you, ideally in the background or as several independent tasks running side by side. If you catch yourself watching the agent work, something earlier is missing, usually a check.
|
|
361
|
+
|
|
362
|
+
### 15. Commands
|
|
363
|
+
|
|
364
|
+
Say it any way you like. The AI maps it to the right protocol.
|
|
365
|
+
|
|
366
|
+
| You say | The AI does |
|
|
367
|
+
|---|---|
|
|
368
|
+
| "New task: …" / "let's build …" | Contract (§5): restates the task, asks all questions at once, proposes done-when, sizes the task |
|
|
369
|
+
| "Plan it" | Orchestrator mode: writes a plan in `.ai/plans/` with steps and contracts, then waits for approval |
|
|
370
|
+
| "Update the context so we continue in a new window" / "handoff" | Handoff protocol (§9.1) |
|
|
371
|
+
| "Continue" / "resume" (in a new window) | Resume protocol (§9.2) |
|
|
372
|
+
| "This isn't working" / "we're stuck" | Stuck protocol (§9.3) |
|
|
373
|
+
| "Done" / "wrap up" | Checks → retro → promotions → log → delete `task.md` (§12) |
|
|
374
|
+
| "Clean up memory" | Cleanup (§12) |
|
|
375
|
+
| "How are we doing?" | A summary of the trends in `.ai/log.md` |
|
|
376
|
+
|
|
377
|
+
**The full-strength version of your usual handoff line:**
|
|
378
|
+
|
|
379
|
+
> Handoff: update `.ai/task.md` so a fresh window with zero memory of this one can continue at full quality. Run the checks first and record the real results. Commit or revert so the code is in a known state. Rewrite Current state, add to Tried with the *why*, keep Confirmed and Guesses separate, and end with the single next step and what to read first. Then tell me what you left out.
|
|
380
|
+
|
|
381
|
+
**And for the new window:**
|
|
382
|
+
|
|
383
|
+
> Resume from `.ai/task.md`. Verify Current state against git and the checks before trusting it, tell me about any mismatch, then do the next step.
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Part C: Templates
|
|
388
|
+
|
|
389
|
+
### C.1 `.ai/task.md`
|
|
390
|
+
|
|
391
|
+
```markdown
|
|
392
|
+
# TASK: <name> (window 3)
|
|
393
|
+
|
|
394
|
+
## Contract
|
|
395
|
+
Goal: <one sentence, outcome>
|
|
396
|
+
Done when: `<command>` passes; <other checks>
|
|
397
|
+
Constraints: <what must not change / must be reused>
|
|
398
|
+
Out of scope: <what not to touch>
|
|
399
|
+
|
|
400
|
+
## Current state (rewrite every window)
|
|
401
|
+
- Branch / commit: feat/<x> @ <hash>, clean
|
|
402
|
+
- Checks: 41 pass, 2 fail (<names>)
|
|
403
|
+
- Next step: <exactly one step>
|
|
404
|
+
- Read first: <path:lines>, <K-ids>
|
|
405
|
+
|
|
406
|
+
## Confirmed (with how we know)
|
|
407
|
+
- <fact> (seen in <test / log / commit>)
|
|
408
|
+
|
|
409
|
+
## Guesses (test before building on them)
|
|
410
|
+
- <hypothesis> (test: <cheapest experiment>)
|
|
411
|
+
|
|
412
|
+
## Tried (append-only: approach → result → why)
|
|
413
|
+
1. <approach> → <result> → <why it failed>
|
|
414
|
+
|
|
415
|
+
## Don't
|
|
416
|
+
- <thing not to retry> (Tried #<n>)
|
|
417
|
+
|
|
418
|
+
## promote? (for the retro)
|
|
419
|
+
- <general lesson worth keeping>
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### C.2 Worker contract
|
|
423
|
+
|
|
424
|
+
```markdown
|
|
425
|
+
## Task: <one line>
|
|
426
|
+
Tier: 2 · Effort: medium
|
|
427
|
+
Files you may edit: <exact paths>
|
|
428
|
+
Read first: <paths, K-ids>
|
|
429
|
+
Done when: <command> passes, including <new test name>
|
|
430
|
+
Constraints: <reuse X; don't change Y's signature>
|
|
431
|
+
Known traps: <K-ids, Tried #n from task.md>
|
|
432
|
+
If anything doesn't match this contract: stop and report. Don't work around it.
|
|
433
|
+
Report (3 lines max): what changed, check results, any surprise.
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### C.3 Knowledge entry (`.ai/knowledge/K-0017.md`)
|
|
437
|
+
|
|
438
|
+
```markdown
|
|
439
|
+
---
|
|
440
|
+
id: K-0017
|
|
441
|
+
type: gotcha # fact | gotcha | decision | lesson | question
|
|
442
|
+
status: confirmed # confirmed | guess
|
|
443
|
+
scope: project # or lib:<library>@<major>
|
|
444
|
+
triggers:
|
|
445
|
+
files: ["src/background/**"]
|
|
446
|
+
errors: []
|
|
447
|
+
commands: []
|
|
448
|
+
topics: [service worker, background state, persistence]
|
|
449
|
+
evidence: <how we know: test, log, commit hash>
|
|
450
|
+
created: 2026-10-05
|
|
451
|
+
fired: 0
|
|
452
|
+
helped: 0
|
|
453
|
+
---
|
|
454
|
+
MV3 service workers are stopped after ~30s idle, so anything held only in memory is lost.
|
|
455
|
+
Keep state in chrome.storage.local. See src/background/state.ts:10.
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### C.4 `.ai/index.md`
|
|
459
|
+
|
|
460
|
+
```markdown
|
|
461
|
+
K-0017 gotcha ✔ MV3 service worker loses in-memory state after ~30s idle · files: src/background/**
|
|
462
|
+
K-0031 gotcha ✔ build fails silently without prisma generate · cmd: npm run build
|
|
463
|
+
K-0042 fact ✔ native fetch needs Node 18+ · err: fetch is not a function
|
|
464
|
+
K-0050 question ? why does auth drop after laptop sleep? · topics: auth, session
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### C.5 `.ai/triggers.yaml`
|
|
468
|
+
|
|
469
|
+
```yaml
|
|
470
|
+
- id: K-0042
|
|
471
|
+
on: error
|
|
472
|
+
match: "fetch is not a function"
|
|
473
|
+
inject: .ai/knowledge/K-0042.md
|
|
474
|
+
- id: K-0017
|
|
475
|
+
on: file
|
|
476
|
+
match: "src/background/**"
|
|
477
|
+
inject: .ai/knowledge/K-0017.md
|
|
478
|
+
- id: K-0031
|
|
479
|
+
on: command
|
|
480
|
+
match: "npm run build"
|
|
481
|
+
inject: "Run `npx prisma generate` first; the build fails silently without it. (K-0031)"
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### C.6 `.ai/routing.md`
|
|
485
|
+
|
|
486
|
+
```markdown
|
|
487
|
+
| Task type | Tier | Effort | Last 10 first-try | Notes |
|
|
488
|
+
|----------------------------|------|--------|-------------------|--------------------------|
|
|
489
|
+
| find code / locate usages | 1 | low | 10/10 | |
|
|
490
|
+
| summarize logs | 1 | low | 9/10 | |
|
|
491
|
+
| write tests from a spec | 2 | medium | 9/10 | |
|
|
492
|
+
| implement specified unit | 2 | medium | 8/10 | 2 more fails → tier 3 |
|
|
493
|
+
| debug unknown failure | 3 | high | — | never moves down |
|
|
494
|
+
| plan / contracts / review | 3 | high | — | never moves down |
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### C.7 Retro
|
|
498
|
+
|
|
499
|
+
```markdown
|
|
500
|
+
## Retro: <task>
|
|
501
|
+
Learned:
|
|
502
|
+
- [general | task-only] [confirmed | guess] <item> (would have helped at: <file / command / error>)
|
|
503
|
+
Promote:
|
|
504
|
+
- <item> → <note | trigger | check (what kind)>
|
|
505
|
+
Fix / delete:
|
|
506
|
+
- <K-id> (<why>)
|
|
507
|
+
Routing changes:
|
|
508
|
+
- <task type> → tier <n> (<reason>)
|
|
509
|
+
Log line:
|
|
510
|
+
<date> | <task> | <size> | human <m> | <windows> | ...
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
## Part D: Setup and adoption order
|
|
516
|
+
|
|
517
|
+
### Where each piece lives, per tool
|
|
518
|
+
|
|
519
|
+
| Piece | Claude Code | Other tools |
|
|
520
|
+
|---|---|---|
|
|
521
|
+
| Always-loaded rules (card + core) | `CLAUDE.md` | `AGENTS.md` (Codex and many others), `GEMINI.md` or `.agent/rules/` (Antigravity), `.cursor/rules/` (Cursor) |
|
|
522
|
+
| Triggers | Hooks: after tool calls for error and file triggers, before tool calls for command triggers | Cursor's glob-scoped rules work as file triggers. Everywhere else: manual trigger mode (card rules 7 and 8) |
|
|
523
|
+
| Model tiers | `.claude/agents/*.md`, with model, effort and tools set per agent | Wherever your tool lets you pick a model per agent or per chat. Otherwise, run separate chats by hand |
|
|
524
|
+
| Fresh windows | `/clear`, or `claude -p` in a script loop | New chat or session |
|
|
525
|
+
|
|
526
|
+
### Adoption order
|
|
527
|
+
|
|
528
|
+
Don't set up everything at once. Each step is useful by itself:
|
|
529
|
+
|
|
530
|
+
1. **Card + `task.md` + the handoff and resume lines.** This is what you already do, sharpened.
|
|
531
|
+
2. **Contracts with done-when, and checks.** The biggest single gain.
|
|
532
|
+
3. **`log.md`.** Start measuring early, so you can tell whether the next steps help.
|
|
533
|
+
4. **Index, knowledge entries and the retro.** Memory starts compounding.
|
|
534
|
+
5. **Triggers through hooks.** Repeat errors start disappearing.
|
|
535
|
+
6. **Tiers and routing.** Cost drops once the log shows which tasks are safe to move down.
|
|
536
|
+
7. **Cross-project library memory.** New projects start ahead.
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
## Part E: Limits, open questions, where the ideas come from
|
|
541
|
+
|
|
542
|
+
**Limits and open questions**
|
|
543
|
+
- **Every number here is a starting guess.** Your log decides the real thresholds.
|
|
544
|
+
- **Overhead.** Ceremony that's too heavy for the task wastes time. Always size the task first.
|
|
545
|
+
- **Trigger noise.** Without pruning, triggers turn into the clutter they were meant to prevent.
|
|
546
|
+
- **Models change.** Bigger reliable context windows shift when to hand off. Stronger small models shift routing. The principles stay the same while the numbers move, so recheck routing whenever you switch models.
|
|
547
|
+
- **Self-reporting is biased.** An agent's account of its own success is the weakest evidence. Tool output is the strongest.
|
|
548
|
+
- **Unproven as a whole.** Individual pieces have evidence behind them. The combination is a hypothesis, and your log is the test.
|
|
549
|
+
|
|
550
|
+
**Where the ideas come from**
|
|
551
|
+
- **Retry with written reflections:** Reflexion (Shinn et al., 2023).
|
|
552
|
+
- **Fresh-context loops with state in files:** the "Ralph" loop (Geoffrey Huntley), and Anthropic's work on harnesses for long-running agents.
|
|
553
|
+
- **Orchestrator plus parallel workers, and their cost tradeoff:** Anthropic's multi-agent research system.
|
|
554
|
+
- **Short map pointing into a docs folder, plans kept in the repo, lint errors that teach the fix, background cleanup agents:** OpenAI's "harness engineering".
|
|
555
|
+
- **Hidden-decision conflicts between parallel agents:** Cognition (the Devin team).
|
|
556
|
+
- **Sparse activation:** mixture-of-experts models (Google's sparsely-gated MoE, Switch Transformer, GLaM).
|
|
557
|
+
- **Cheap-model-first cascades and routers:** FrugalGPT and RouteLLM.
|
|
558
|
+
- **A civilization of simple specialists:** Marvin Minsky, *The Society of Mind* (1986).
|
|
559
|
+
- **New in this combination, as far as I know:** error-message triggers, the promotion ladder ending in automated checks, cross-project memory keyed by library and version, confirmed/guess labels with cleanup based on how often entries fire, routing learned from your own log, and the repeat-error rate as the core metric.
|
|
560
|
+
|
|
561
|
+
---
|
|
562
|
+
|
|
563
|
+
## Unattended runs
|
|
564
|
+
|
|
565
|
+
When no human is watching (scheduled runs), these rules replace "ask the human":
|
|
566
|
+
|
|
567
|
+
- **Session lock:** if `.ai/session.lock` shows another run started less than 90 minutes ago, do nothing and stop.
|
|
568
|
+
- **Run budget:** the task file holds `Run: N / 30`. Add 1 at the start of every run; at 30, write `BLOCKED.md` ("run budget reached") and stop.
|
|
569
|
+
- **DONE / BLOCKED:** if `DONE.md` or `BLOCKED.md` exists, do nothing and stop. Write `DONE.md` only when every done-when passes; write `BLOCKED.md` (what you tried, the specific question, your best guess) when the stuck protocol is exhausted.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: K-0001
|
|
3
|
+
type: gotcha
|
|
4
|
+
status: confirmed
|
|
5
|
+
scope: project
|
|
6
|
+
triggers:
|
|
7
|
+
errors: ["fetch is not a function"]
|
|
8
|
+
files: []
|
|
9
|
+
commands: []
|
|
10
|
+
topics: [node version, fetch]
|
|
11
|
+
evidence: reproduced on Node 16, fixed on Node 20 (example entry)
|
|
12
|
+
created: 2026-01-01
|
|
13
|
+
fired: 0
|
|
14
|
+
helped: 0
|
|
15
|
+
---
|
|
16
|
+
Global `fetch` needs Node 18 or newer. Check `node --version` before debugging the call itself.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
## Operating Card (the Compounding Loop)
|
|
2
|
+
|
|
3
|
+
> The full method is in `.ai/method.md`. The § numbers point to Part B there.
|
|
4
|
+
|
|
5
|
+
**Objective:** the most verified-correct results per minute of the owner's attention. Tokens are the cheapest resource. A wrong result that looks right is the most expensive one.
|
|
6
|
+
|
|
7
|
+
**Start of every session**
|
|
8
|
+
1. Read `.ai/index.md`. Open a knowledge entry only when it's relevant to what you're doing.
|
|
9
|
+
2. If `.ai/task.md` exists, run the resume protocol (§9.2) before anything else.
|
|
10
|
+
|
|
11
|
+
**Before work**
|
|
12
|
+
3. Size the task. Tiny: just do it. Medium: contract + checks. Large or unclear: plan, then loop.
|
|
13
|
+
4. For medium and large tasks, write the contract (§5): goal, done-when (checkable by a command), constraints, out of scope.
|
|
14
|
+
|
|
15
|
+
**During work**
|
|
16
|
+
5. One unit of work at a time. Run the checks after each unit. You never declare done; the checks do.
|
|
17
|
+
6. Write a note the moment you learn something, marked CONFIRMED or GUESS. Don't save it for the end.
|
|
18
|
+
7. After any error, search `.ai/index.md` for the error text before trying a fix.
|
|
19
|
+
8. Before editing a file, check the index for entries about that path.
|
|
20
|
+
9. Send reading-heavy work (search, docs, logs, review) to subagents that report back in 10 lines or fewer. Keep code-writing in one thread.
|
|
21
|
+
10. Same failure twice: stop and run the stuck protocol (§9.3). Don't retry a variant.
|
|
22
|
+
11. If reality contradicts the plan or contract, stop and record it. Don't silently work around it.
|
|
23
|
+
12. Point to code and docs (`path:line`). Never copy them into notes.
|
|
24
|
+
|
|
25
|
+
**Context**
|
|
26
|
+
13. At ~50–60% context, or when a unit is done and the next one is big: run the handoff (§9.1) and end the run.
|
|
27
|
+
|
|
28
|
+
**Finishing**
|
|
29
|
+
14. When the checks pass, run the retro (§12), log the task and delete `.ai/task.md`.
|
|
30
|
+
|
|
31
|
+
**Unattended runs** (no human watching; the owner reads the results later)
|
|
32
|
+
- Session lock: if `.ai/session.lock` shows another run started less than 90 minutes ago, do nothing and stop.
|
|
33
|
+
- Run budget: `.ai/task.md` holds `Run: N / 30`. Add 1 at the start of every run; at 30, write `BLOCKED.md` ("run budget reached") and stop.
|
|
34
|
+
- If `DONE.md` or `BLOCKED.md` exists, do nothing and stop. Write `DONE.md` only when every done-when passes; write `BLOCKED.md` (tried, the question, best guess) when stuck.
|
|
35
|
+
|
|
36
|
+
**Never**
|
|
37
|
+
- Mark your own work done without the checks passing.
|
|
38
|
+
- Treat a GUESS from an earlier window as fact.
|
|
39
|
+
- Delete or rewrite CONFIRMED knowledge without new evidence.
|
|
40
|
+
- Change this card.
|
package/method/retro.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Retro
|
|
2
|
+
|
|
3
|
+
Run it when the checks pass, before deleting `.ai/task.md`. About two minutes.
|
|
4
|
+
|
|
5
|
+
1. List what was learned. For each item: does it apply beyond this task? Is it confirmed or a guess? At what moment would it have helped (file, command or error)?
|
|
6
|
+
2. Move general, confirmed items down the promotion ladder as far as they go: `guess → confirmed note → note with a trigger → automated check`. The best memory is one the model never has to read: turn a rule into a lint, test or script and delete the prose.
|
|
7
|
+
3. Write each kept lesson as a knowledge entry (`.ai/knowledge/K-NNNN.md`, see `method/example/K-0001.md`) with triggers, and add one line to `.ai/index.md`.
|
|
8
|
+
4. Flag entries this task showed to be wrong or stale. Never delete a CONFIRMED entry without new evidence.
|
|
9
|
+
5. Add one line to `.ai/log.md`: date, task, checks result, runs used, what was learned.
|
|
10
|
+
6. Delete `.ai/task.md`.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Reviewer prompt
|
|
2
|
+
|
|
3
|
+
Give this to a subagent that did not write the code. It sees the diff and the brief, not your reasoning.
|
|
4
|
+
|
|
5
|
+
> You are reviewing a change before it is pushed. Read `IDEA.md` (the brief), the task contract in `.ai/task.md`, and the diff (`git diff origin/main..HEAD`).
|
|
6
|
+
>
|
|
7
|
+
> Find the three most likely ways this is wrong for a real user, and check each by reading code or running a small command. Do not edit files.
|
|
8
|
+
>
|
|
9
|
+
> Look for: behaviour the contract promises but no test proves; a check that passes without exercising the feature; paths, quoting or line endings that break on Windows; secrets, tracking or calls home; private files that would be published; a published URL or API that changed.
|
|
10
|
+
>
|
|
11
|
+
> Report in 10 lines or fewer. Mark each finding BLOCKER (fix before push) or NOTE. Say what you ran and what you only read.
|
|
12
|
+
|
|
13
|
+
The author fixes every BLOCKER, runs the checks again, then pushes. A reviewer's NOTE goes in the task file under Guesses.
|