@eventmodelers/cli 1.0.163 → 2.0.2

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 (128) hide show
  1. package/README.md +48 -36
  2. package/RELEASE_NOTES.md +20 -2
  3. package/cli.js +774 -247
  4. package/lib/adapters/spec-kitty-adapter.js +3 -7
  5. package/lib/build-kits.js +23 -0
  6. package/lib/global-agent-id.js +45 -0
  7. package/lib/modeling-local-ai.js +4 -2
  8. package/lib/scaffold-model.js +71 -0
  9. package/lib/scaffold.js +224 -0
  10. package/lib/supervise.js +60 -0
  11. package/lib/ui-baseline.js +123 -0
  12. package/package.json +1 -1
  13. package/shared/build-kit/README.md +4 -19
  14. package/shared/build-kit/lib/agent-lock.js +75 -0
  15. package/shared/build-kit/lib/agent-name.js +27 -0
  16. package/shared/build-kit/lib/event-prune.js +58 -0
  17. package/shared/build-kit/lib/events-view.js +134 -0
  18. package/shared/build-kit/lib/local-ai-agent.js +14 -26
  19. package/shared/build-kit/lib/mcp-register.js +17 -1
  20. package/shared/build-kit/lib/prompt-journal.js +191 -0
  21. package/shared/build-kit/lib/prompt-replay.js +35 -0
  22. package/shared/build-kit/lib/ralph.js +218 -169
  23. package/shared/build-kit/lib/slice-curation.js +40 -0
  24. package/shared/build-kit/lib/slice-events.js +93 -0
  25. package/shared/build-kit/lib/slice-git.js +86 -0
  26. package/shared/build-kit/lib/slice-learnings.js +197 -0
  27. package/shared/build-kit/lib/slice-projection.js +101 -0
  28. package/shared/build-kit/lib/slice-run.js +181 -0
  29. package/shared/build-kit/lib/slice-state.js +184 -0
  30. package/shared/build-kit/lib/slice-tasks.js +35 -0
  31. package/shared/build-kit/ralph-claude.js +4 -2
  32. package/shared/build-kit/ralph-exec.js +4 -2
  33. package/shared/build-kit/ralph-local-ai.js +5 -3
  34. package/shared/scaffold/LICENSE-em-scaffold +21 -0
  35. package/shared/scaffold/supabase/generate.mjs +290 -0
  36. package/shared/scaffold/supabase/template/scripts/create-user.mjs.tmpl +29 -0
  37. package/shared/scaffold/supabase/template/scripts/dev.mjs.tmpl +145 -0
  38. package/shared/scaffold/supabase/template/scripts/write-env.mjs.tmpl +44 -0
  39. package/shared/scaffold/supabase/template/server.ts.tmpl +168 -0
  40. package/shared/scaffold/supabase/template/src/common/extraEndpoints.ts.tmpl +5 -0
  41. package/shared/scaffold/supabase/template/src/common/notImplemented.test.ts.tmpl +58 -0
  42. package/shared/scaffold/supabase/template/src/common/notImplemented.ts.tmpl +29 -0
  43. package/shared/scaffold/supabase/template/supabase/migrations/_V0__supabase_stubs.sql.tmpl +34 -0
  44. package/shared/scaffold/supabase/template/web/src/App.tsx.tmpl +38 -0
  45. package/shared/scaffold/supabase/template/web/src/app/Layout.tsx.tmpl +48 -0
  46. package/shared/scaffold/supabase/template/web/src/app/NotFound.tsx.tmpl +12 -0
  47. package/shared/scaffold/supabase/template/web/src/app/SignIn.tsx.tmpl +42 -0
  48. package/shared/scaffold/supabase/template/web/src/app/TimelinePage.tsx.tmpl +73 -0
  49. package/shared/scaffold/supabase/template/web/src/app/pages.ts.tmpl +26 -0
  50. package/shared/scaffold/supabase/template/web/src/app/skeleton.css.tmpl +25 -0
  51. package/shared/scaffold/supabase/template/web/src/lib/NotBuilt.tsx.tmpl +12 -0
  52. package/shared/scaffold/supabase/template/web/src/lib/api.ts.tmpl +226 -0
  53. package/shared/scaffold/supabase/template/web/src/main.tsx.tmpl +13 -0
  54. package/shared/skills/learn-eventmodelers-api/SKILL.md +17 -4
  55. package/shared/skills/request-feedback/SKILL.md +1 -2
  56. package/shared/skills/ui-contract/SKILL.md +7 -5
  57. package/shared/skills/update-slice-status/SKILL.md +1 -1
  58. package/stacks/axon/templates/build-kit/CLAUDE.md +7 -6
  59. package/stacks/axon/templates/build-kit/lib/AGENT.md +6 -7
  60. package/stacks/axon/templates/build-kit/lib/backend-prompt.md +20 -42
  61. package/stacks/axon/templates/build-kit/lib/prompt.md +32 -41
  62. package/stacks/blank/templates/build-kit/CLAUDE.md +7 -6
  63. package/stacks/blank/templates/build-kit/lib/AGENT.md +6 -7
  64. package/stacks/blank/templates/build-kit/lib/backend-prompt.md +20 -37
  65. package/stacks/blank/templates/build-kit/lib/prompt.md +33 -42
  66. package/stacks/classic/templates/.claude/skills/build-automation/SKILL.md +1 -1
  67. package/stacks/classic/templates/.claude/skills/build-state-change/SKILL.md +1 -1
  68. package/stacks/classic/templates/.claude/skills/build-state-view/SKILL.md +2 -2
  69. package/stacks/classic/templates/.claude/skills/record-evidence/SKILL.md +2 -2
  70. package/stacks/classic/templates/build-kit/CLAUDE.md +9 -8
  71. package/stacks/classic/templates/build-kit/lib/AGENT.md +6 -7
  72. package/stacks/classic/templates/build-kit/lib/backend-prompt.md +20 -38
  73. package/stacks/classic/templates/build-kit/lib/prompt.md +33 -42
  74. package/stacks/kurrent/templates/build-kit/CLAUDE.md +7 -7
  75. package/stacks/kurrent/templates/build-kit/lib/AGENT.md +6 -7
  76. package/stacks/kurrent/templates/build-kit/lib/backend-prompt.md +20 -42
  77. package/stacks/kurrent/templates/build-kit/lib/prompt.md +32 -41
  78. package/stacks/modeling-kit/templates/.claude/skills/analyze-existing-model/SKILL.md +1 -1
  79. package/stacks/modeling-kit/templates/.claude/skills/detect-model-drift/SKILL.md +1 -1
  80. package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-core-rules/SKILL.md +2 -0
  81. package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-elaborating-scenarios/SKILL.md +7 -3
  82. package/stacks/modeling-kit/templates/.claude/skills/wdyt/SKILL.md +1 -1
  83. package/stacks/modeling-kit/templates/kit/CLAUDE-STANDALONE.md +3 -4
  84. package/stacks/modeling-kit/templates/kit/CLAUDE.md +18 -28
  85. package/stacks/modeling-kit/templates/kit/README.md +1 -1
  86. package/stacks/modeling-kit/templates/kit/lib/config.js +1 -1
  87. package/stacks/node/templates/build-kit/CLAUDE.md +7 -6
  88. package/stacks/node/templates/build-kit/lib/AGENT.md +6 -7
  89. package/stacks/node/templates/build-kit/lib/backend-prompt.md +20 -42
  90. package/stacks/node/templates/build-kit/lib/prompt.md +18 -41
  91. package/stacks/opencqrs/templates/build-kit/CLAUDE.md +7 -7
  92. package/stacks/opencqrs/templates/build-kit/lib/AGENT.md +6 -7
  93. package/stacks/opencqrs/templates/build-kit/lib/backend-prompt.md +20 -42
  94. package/stacks/opencqrs/templates/build-kit/lib/prompt.md +32 -41
  95. package/stacks/react/templates/.claude/skills/build-state-change/SKILL.md +1 -1
  96. package/stacks/react/templates/.claude/skills/build-state-view/SKILL.md +1 -1
  97. package/stacks/react/templates/build-kit/CLAUDE.md +7 -6
  98. package/stacks/react/templates/build-kit/lib/AGENT.md +6 -7
  99. package/stacks/react/templates/build-kit/lib/backend-prompt.md +25 -42
  100. package/stacks/react/templates/build-kit/lib/kit.json +1 -1
  101. package/stacks/react/templates/build-kit/lib/prompt.md +47 -43
  102. package/stacks/supabase/templates/.claude/skills/build-state-view/SKILL.md +15 -0
  103. package/stacks/supabase/templates/build-kit/CLAUDE.md +7 -6
  104. package/stacks/supabase/templates/build-kit/lib/AGENT.md +6 -7
  105. package/stacks/supabase/templates/build-kit/lib/backend-prompt.md +20 -42
  106. package/stacks/supabase/templates/build-kit/lib/prompt.md +18 -41
  107. package/stacks/supabase-react/templates/.claude/skills/build-state-change/SKILL.md +80 -8
  108. package/stacks/supabase-react/templates/.claude/skills/build-state-view/SKILL.md +66 -13
  109. package/stacks/supabase-react/templates/build-kit/CLAUDE.md +8 -7
  110. package/stacks/supabase-react/templates/build-kit/lib/AGENT.md +6 -7
  111. package/stacks/supabase-react/templates/build-kit/lib/backend-prompt.md +25 -42
  112. package/stacks/supabase-react/templates/build-kit/lib/kit.json +1 -1
  113. package/stacks/supabase-react/templates/build-kit/lib/prompt.md +48 -44
  114. package/stacks/umadb/templates/build-kit/CLAUDE.md +7 -6
  115. package/stacks/umadb/templates/build-kit/lib/AGENT.md +6 -7
  116. package/stacks/umadb/templates/build-kit/lib/backend-prompt.md +20 -42
  117. package/stacks/umadb/templates/build-kit/lib/prompt.md +32 -41
  118. package/shared/bridge/spec-kitty/bridge-spec-kitty-specify/SKILL.md +0 -125
  119. package/shared/bridge/spec-kitty/bridge-spec-kitty-tasks/SKILL.md +0 -95
  120. package/shared/build-kit/lib/agent.sh +0 -20
  121. package/shared/build-kit/ralph.sh +0 -111
  122. package/shared/build-kit/realtime-agent.js +0 -20
  123. package/stacks/bridge/templates/bridge/lib/AGENT.md +0 -47
  124. package/stacks/bridge/templates/bridge/lib/prompt.md +0 -111
  125. package/stacks/bridge/templates/bridge/ralph-claude.js +0 -50
  126. package/stacks/bridge/templates/bridge/ralph-hook.js +0 -103
  127. package/stacks/bridge/templates/bridge/ralph-local-ai.js +0 -43
  128. package/stacks/bridge/templates/bridge/ralph-static.js +0 -90
@@ -4,17 +4,11 @@ You are an autonomous agent reacting to slice status change events on an Eventmo
4
4
 
5
5
  ## Your Loop
6
6
 
7
- 1. Read `AGENT.md` to load accumulated learnings before doing anything else.
8
- 2. Read `.build-kit/tasks.json`.
9
- 3. If `tasks.json` is empty or missing, reply with:
10
- <promise>IDLE</promise>
11
- and stop.
12
- 4. Pick the **oldest task** (earliest `createdAt`).
13
- 5. Execute the task — see the Execution section below.
14
- 6. After execution, remove that task from the array and write `.build-kit/tasks.json` back.
15
- 7. Append a progress entry to `progress.txt` (create if missing).
16
- 8. Update `AGENT.md` with any new reusable learnings discovered this iteration.
17
- 9. Reply normally so the next iteration can pick up the next task.
7
+ 1. Read `AGENT.md` and, if it exists, `.build-kit/AGENTS.md` to load accumulated knowledge before doing anything else.
8
+ 2. The task request at the end of this prompt names your task: its id and the slice change that queued it (`sliceId`, `sliceTitle`, `sliceStatus`, …). It is the oldest one waiting — the run loop picked it for you.
9
+ 3. Execute the task — see the Execution section below.
10
+ 4. Record any reusable learning with `npx @eventmodelers/cli learn "<one terse line>" --topic <topic>` (see **Recording Learnings**).
11
+ 5. Reply normally. The run loop completes the task when your turn ends and hands you the next one in a fresh turn — you never read or write a queue file.
18
12
 
19
13
  ## Execution
20
14
 
@@ -48,11 +42,11 @@ Inspect the `sliceStatus` in the payload:
48
42
 
49
43
  This is the build trigger. Setting `InProgress` and building are one atomic step:
50
44
 
51
- **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line in `progress.txt` and as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
45
+ **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
52
46
 
53
47
  1. Immediately call `/update-slice-status` to set the slice to `InProgress` on the board.
54
48
 
55
- **Claim conflict**: if this call reports the slice is already in `InProgress` (or any status other than `Planned`), another agent already claimed it first — this is expected, not an error. Log it in `progress.txt`, drop this task without building, and continue the loop (the next task will naturally cover the next slice). Do not retry.
49
+ **Claim conflict**: if this call reports the slice is already in `InProgress` (or any status other than `Planned`), another agent already claimed it first — this is expected, not an error. Say so in your reply, drop this task without building, and continue the loop (the next task will naturally cover the next slice). Do not retry.
56
50
 
57
51
  2. Run `/load-slice sliceId=<payload.sliceId>` to fetch the full slice, then read the slice definition from `.build-kit/.slices/<contextSlug>/<sliceFolder>/slice.json`. The runner keeps a `slice.json` fresh from a summary endpoint, so a file holding only `id`, `title`, `status` and `sliceType` is that stub, not an empty slice — never conclude a slice has no elements from it. Only if the full fetch itself returns no commands/events/read models/fields is the slice actually empty.
58
52
 
@@ -64,6 +58,20 @@ This is the build trigger. Setting `InProgress` and building are one atomic step
64
58
 
65
59
  4. Invoke the matching skill and follow its instructions **completely**. Do NOT implement the slice manually.
66
60
 
61
+ **Baseline gate** — before touching any code, run `npx @eventmodelers/cli build-baseline check --scope backend`.
62
+ It compares the board's node hashes of every element of the slice (commands, events, read models,
63
+ processors, specifications, ...) with what was recorded after the last successful build:
64
+ - `UNCHANGED` — nothing on the board changed. Do not rebuild or re-diff; run the slice's tests and
65
+ finish. Only now is "no code changes needed" a valid outcome.
66
+ - `NO_BASELINE` / `UNKNOWN` — no recorded build, or the board could not be read: do one full
67
+ field-by-field diff of slice.json against the code (never treat `UNKNOWN` as `UNCHANGED`).
68
+ - `CHANGED` — it lists the elements that changed, were added or were removed. Diff slice.json
69
+ against the code for exactly those and fix every drift; leave what matches alone.
70
+
71
+ When the checks pass, run `npx @eventmodelers/cli build-baseline record --scope backend` **before
72
+ committing**, so `ui-baseline.json` is committed with the slice. Never record without having done the
73
+ work the verdict asked for. Screens and UI prompts are not this kit's business and never trigger a build.
74
+
67
75
  5. **Verify against slice.json**: Cross-check the implementation — every command field, event field, and specification in slice.json must appear in the code. No invented fields — if it is not in slice.json, it must not be in the code.
68
76
 
69
77
  6. Run quality checks:
@@ -78,48 +86,31 @@ This is the build trigger. Setting `InProgress` and building are one atomic step
78
86
  Another agent is already building this slice. Log it and skip — do not build.
79
87
 
80
88
  #### `Done`
81
- Summarize what was completed and update `progress.txt`.
89
+ Summarize what was completed in your reply.
82
90
 
83
91
  #### `Blocked`
84
- Log the blocker in `progress.txt`.
92
+ State the blocker in your reply.
85
93
 
86
94
  #### `Review`
87
- Fetch slice details and prepare a review summary in `progress.txt`.
95
+ Fetch slice details and prepare a review summary in your reply.
88
96
 
89
97
  #### Any other status (`Created`, etc.)
90
- Load the slice and log the state transition in `progress.txt`. No build action.
98
+ Load the slice and note the state transition in your reply. No build action.
91
99
 
92
100
  Use the skills available in `.claude/skills/` to interact with the board.
93
101
 
94
- ## Updating tasks.json
95
-
96
- After completing a task, remove it from the array and write the updated array back to `.build-kit/tasks.json`. If the array is now empty, write `[]`.
102
+ ## Recording Learnings
97
103
 
98
- ## Progress Report Format
104
+ `.build-kit/AGENTS.md` is generated from the learnings recorded so far — read it at the start of every session, never edit it by hand. Record a learning the moment you have it:
99
105
 
100
- APPEND to `progress.txt` (never replace):
101
106
  ```
102
- ## [ISO timestamp] — Task [task.id]
103
-
104
- Slice: [sliceTitle] ([sliceId])
105
- Status change: [sliceStatus]
106
-
107
- Action taken:
108
- - [what was done in response to the slice change]
109
-
110
- Learnings:
111
- - [any patterns, gotchas, or reusable knowledge discovered]
112
- ---
107
+ npx @eventmodelers/cli learn "<one terse line>" --topic "<topic>"
113
108
  ```
114
109
 
115
- ## Stop Condition
116
-
117
- If `.build-kit/tasks.json` is empty (`[]`) or does not exist, reply with:
118
- <promise>IDLE</promise>
119
-
120
- ## Updating AGENT.md
121
-
122
- After completing a task, add any **reusable** learnings to `AGENT.md` — patterns, gotchas, API quirks, or skill behaviour that future iterations should know. Only add things that are general and applicable beyond this single task. Do not duplicate what is already there.
110
+ - Only what is genuinely reusable: codebase patterns, gotchas, commands that work or don't, conventions — and, after a failed approach, what was tried and why it failed. Not slice-specific details, and nothing the code or git log already says.
111
+ - One learning per call, one line each. A learning that is already in `.build-kit/AGENTS.md` is skipped for you.
112
+ - `--scope system` for what is true of the modeled domain (a business rule, a naming convention of the model); `repo` (the default) for the codebase and its tooling. `--tag <tag>` labels it (repeatable).
113
+ - One in `.build-kit/AGENTS.md` that turned out wrong or obsolete: `npx @eventmodelers/cli learnings --ids` lists each with its id, `npx @eventmodelers/cli learn --retract <id>` removes it.
123
114
 
124
115
  ## Important
125
116
 
@@ -23,16 +23,16 @@ TODO — any other guardrails worth stating up front (e.g. ignore routes files u
23
23
  asked, ignore tests unless asked, slice names are case-insensitive) — copy the ones
24
24
  that still apply from an existing stack's build-kit/CLAUDE.md.
25
25
 
26
- At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings.
26
+ At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings. It is generated from the learnings recorded so far — record a new one with `npx @eventmodelers/cli learn "<one terse line>" --topic <topic>`, never by editing the file.
27
27
 
28
- When starting to work on a slice, invoke the `update-slice-status` skill with `InProgress` status before doing anything else.
28
+ When working from a queued task, invoke the `update-slice-status` skill with `InProgress` status before doing anything else. When the task request names the slice to build (a run-loop build), the run loop has already set it to `InProgress` and pushes the final status itself — do not call `update-slice-status`; record the outcome with `npx @eventmodelers/cli slice-status <status>`.
29
29
 
30
30
  ## Building a Slice
31
31
 
32
32
  **CRITICAL: You MUST always use the provided skills to build slices. NEVER implement a slice manually.**
33
33
  **ALL fields, event names, command names, and business rules MUST come exclusively from slice.json. Do NOT invent, assume, or guess any field or logic not present in the slice definition.**
34
34
 
35
- **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line in `progress.txt` and as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
35
+ **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
36
36
 
37
37
  When asked to build a slice, always follow this flow:
38
38
 
@@ -43,9 +43,10 @@ When asked to build a slice, always follow this flow:
43
43
  - **State-view** — `projections` or `queries` array is non-empty → invoke `/build-state-view`
44
44
  - **State-change** — default (has `commands` / `events`) → invoke `/build-state-change`
45
45
  3. Invoke the matching skill and follow its instructions completely. Do not deviate.
46
- 4. **Verify against slice.json**: After the skill completes, check that every command field, event field, and specification in slice.json appears in the implementation. No invented fields — if it is not in slice.json, it must not be in the code. This applies even when the slice was previously `Done` and reappears as `Planned` — never dismiss a mismatch as "already implemented" or harmless drift; diff slice.json against the code field by field and update the code to match every change.
47
- 5. Run quality checks (TODO: this stack's build + test commands), then the slice tests only.
48
- 6. If checks pass, commit with `feat: [Slice Name]` and set slice status to `Done`. For STATE_VIEW/STATE_CHANGE slices when `handover` is enabled the status to set is `Handover`, not `Done` — see the `ui-contract` skill, Step 4.
46
+ 4. **Baseline gate**: run `npx @eventmodelers/cli build-baseline check --scope backend` first and act only on its verdict — `UNCHANGED` means nothing on the board changed since the last recorded build: do not rebuild, just run the slice's tests and finish; `NO_BASELINE`/`UNKNOWN` mean one full field-by-field diff of slice.json against the code; `CHANGED` lists exactly which elements changed, were added or removed — diff and fix only those. After the checks pass and before committing, run `build-baseline record --scope backend`. A screen or UI prompt change never triggers a backend build.
47
+ 5. **Verify against slice.json**: After the skill completes, check that every command field, event field, and specification in slice.json appears in the implementation. No invented fields — if it is not in slice.json, it must not be in the code. This applies even when the slice was previously `Done` and reappears as `Planned` — never dismiss a mismatch as "already implemented" or harmless drift; diff slice.json against the code field by field and update the code to match every change.
48
+ 6. Run quality checks (TODO: this stack's build + test commands), then the slice tests only.
49
+ 7. If checks pass, commit with `feat: [Slice Name]` and set slice status to `Done`. For STATE_VIEW/STATE_CHANGE slices when `handover` is enabled the status to set is `Waiting`, not `Done` — see the `ui-contract` skill, Step 4.
49
50
 
50
51
  After you are done, automatically run the tests for the slice that was edited.
51
52
 
@@ -1,12 +1,11 @@
1
- # Agent Learnings
1
+ # Agent Reference
2
2
 
3
- Patterns and gotchas discovered during task processing. Update this file whenever you encounter something reusable.
3
+ What task processing relies on: the shape of a task and the API facts the skills use. A reusable learning is recorded with `npx @eventmodelers/cli learn "<one terse line>"`, not added here.
4
4
 
5
- ## tasks.json
5
+ ## Tasks
6
6
 
7
- - Tasks are objects with `id`, `createdAt`, and `payload` (a `SliceChangedPayload`).
8
- - After completing a task, remove it from the array entirely — do not add a status field.
9
- - Write `[]` to `tasks.json` if the last task is completed.
7
+ - A task is a slice change the run loop queued: an `id` and a `payload` (a `SliceChangedPayload`). The task request names it.
8
+ - You never read or write a queue file: the run loop completes the task when your turn ends.
10
9
 
11
10
  ## SliceChangedPayload fields
12
11
 
@@ -44,4 +43,4 @@ These files are always up to date — read them directly before invoking any ski
44
43
  - The `boardId` and `organizationId` from each payload provide full context — pass them to skills.
45
44
  - Node events use `node:created`, `node:changed`, `node:deleted` — always POST to `/api/org/:orgId/boards/:boardId/nodes/events`.
46
45
  - Slice metadata (title, status) lives on the SLICE_BORDER node under `meta.sliceStatus` and `meta.title`.
47
- - `/update-slice-status` rejects moving a slice into a status it's already in — this is a concurrency guard, not a bug. It means another agent already claimed the slice. Treat it as `ALREADY_IN_STATUS`, skip that slice, and move on to the next `Planned` one instead of erroring out.
46
+ - `/update-slice-status` rejects moving a slice into a status it's already in — this is a concurrency guard, not a bug. It means another agent already claimed the slice. Treat it as `ALREADY_IN_STATUS`, skip that slice, and move on to the next `Planned` one instead of erroring out. This applies to queued tasks only: when the task request names the slice to build, the run loop owns its status — never call `/update-slice-status` there.
@@ -17,59 +17,42 @@ You work within **exactly ONE context at a time** — the one named in `.build-k
17
17
 
18
18
  0. Do not read the entire code base. Focus on the tasks in this description.
19
19
  1. Read `.build-kit/.slices/current_context.json` to find the active context name, then read `.build-kit/.slices/<contextName>/index.json`. Every item in status "planned" is a task.
20
- 2. Read the progress log at `progress.txt` **if it exists** (check Codebase Patterns section first) — it is absent until the first slice is built, which is not an error; create it when you write your first entry
20
+ 2. Read `.build-kit/AGENTS.md` **if it exists** — the project's accumulated learnings, generated from what earlier builds recorded. If the slice's `slice.json` has a `lastAttempt`, an earlier attempt at it failed: read its `reason`, `lastReply`, `branch` and `changed`, and do not repeat what failed.
21
21
  3. Make sure you are on the right branch "feature/<slicename>", if unsure, start from main.
22
- 5. Pick the **highest priority** slice where status is **exactly** "Planned" (case insensitive). This becomes your PRD. Set the status "InProgress" in the index.json **and** update the slice status on the eventmodelers board using the `update-slice-status` skill (or MCP if available).
23
- **IMPORTANT: Only work on slices with status "Planned" in the CURRENT context. Never pick up a slice that is "InProgress", "Done", "Blocked", "Created", or any other status — even if it looks incomplete. If no slice has status "Planned" in the current context, reply with:**
22
+ 5. Your slice is the one the task request names (the run loop picked the highest priority slice with status "Planned"); it becomes your PRD. The run loop has already claimed it — its status is "InProgress" in index.json and on the board. Build that slice and do not call `update-slice-status`: the run loop owns the slice's status on the board.
23
+ **IMPORTANT: Only work on the slice named in the task request. Never switch to another slice, whatever its status. If the task request names no slice and no slice has status "Planned" in the current context, reply with:**
24
24
  <promise>NO_TASKS</promise> and stop immediately. Do not work on other slices and do not switch to another context.
25
- **Claim conflict**: the board rejects the status update if the slice is already in the target status — this is expected: another agent claimed it first, racing you for the same slice. This is NOT an error. Do not stop, do not retry the same slice. Re-read `index.json` (or re-fetch via `load-slice`), pick the next-highest-priority slice still "Planned", and try claiming that one instead. Repeat until a claim succeeds or no "Planned" slice remains, in which case reply `<promise>NO_TASKS</promise>`.
26
25
  6. Pick the slice definition from `.build-kit/.slices/<contextName>/<folder>/slice.json` as defined in the prd. Never work on more than one slice per iteration.
27
- 7. A slice can define additional prompts as codegen/backendPrompt. Any additional prompts defined in backend are hints for the implementation of the slice and have to be taken into account. If you use the additional prompt, add a line in progress.txt
26
+ 7. A slice can define additional prompts as codegen/backendPrompt. Any additional prompts defined in backend are hints for the implementation of the slice and have to be taken into account.
28
27
  7. Determine the slice type and invoke the matching skill as defined in the **Building a Slice** section of `.build-kit/CLAUDE.md`. Do NOT implement manually.
29
- 8. Write a short progress one liner after each step to progress.txt
28
+ 8. Record each learning the moment you have it (see **Recording Learnings**), not at the end.
30
29
  9. Analyze and Implement that single slice, making use of the skills in the skills directory plus your previously collected knowledge. Make a TODO list for what needs to be done, and adjust the implementation according to the JSON definition. Carefully inspect events, fields and compare against the implemented slice. JSON is the desired state. ATTENTION: a "planned" task can also be just added specifications. So always look at the slice itself, but also the specifications. If specifications were added in json which are not on code, you need to add them in code.
31
30
  10. The slice in the json is always true, the code follows what is defined in the json
32
31
  11. Slice is only 'Done' if business logic is implemented as defined in the JSON, APIs are implemented, all scenarios in JSON are implemented in code and it fulfills the slice.json. There must be no specification in json that has no equivalent in code.
33
32
  12. Only when `handover` is on (the task's `Handover: on` line), invoke the `ui-contract` skill for STATE_VIEW / STATE_CHANGE slices; with handover off skip this step (publishes the UI Contract section to the slice's feedback-lane markdown node)
34
33
  13. Run quality checks — TODO: your stack's build command, TODO: your stack's test command (slice-scoped only; do not run all tests).
35
34
  14. If checks pass, commit ALL changes with message: `feat: [Slice Name]` and merge back to main as FF merge (update first)
36
- 15. Update the PRD to set `status: Done` for the completed story in index.json **and** update the slice status on the eventmodelers board using the `update-slice-status` skill (or MCP if available). For STATE_VIEW/STATE_CHANGE slices when `handover` is enabled the status to set is `Handover`, not `Done` — see the `ui-contract` skill, Step 4.
37
- 16. Append your progress to `progress.txt` after each step in the iteration.
38
- 17. Append your new learnings to `.build-kit/AGENTS.md` in a compressed form, reusable for future iterations. Only add learnings if they are not already there.
35
+ 15. Record the outcome with `npx @eventmodelers/cli slice-status Done` — not by editing index.json, and do not call `update-slice-status`: the run loop pushes the status to the board when your turn ends. For STATE_VIEW/STATE_CHANGE slices when `handover` is enabled the status to record is `Waiting`, not `Done` — see the `ui-contract` skill, Step 4. A slice you could not finish needs no status: leave it as it is and the run loop discards the attempt.
36
+ 16. Record any reusable learning you have not recorded yet (see **Recording Learnings**).
37
+ 17. If an entry in `.build-kit/AGENTS.md` turned out wrong or obsolete, retract it (see **Recording Learnings**).
39
38
  18. Finish the iteration.
40
39
 
41
40
  ## Escalating Ambiguity
42
41
 
43
- **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line in `progress.txt` and as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
42
+ **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
44
43
 
45
- ## Progress Report Format
44
+ ## Recording Learnings
46
45
 
47
- APPEND to progress.txt (never replace, always append):
46
+ `.build-kit/AGENTS.md` is generated from the learnings recorded so far — read it at the start of every session, never edit it by hand. Record a learning the moment you have it:
48
47
 
49
48
  ```
50
- ## [Date/Time] - [Slice]
51
-
52
- - What was implemented
53
- - Files changed
54
- - **Learnings for future iterations:**
55
- - Patterns discovered (e.g., "this codebase uses X for Y")
56
- - Gotchas encountered (e.g., "don't forget to update Z when changing W")
57
- - Useful context (e.g., "the evaluation panel is in component X")
58
- ---
49
+ npx @eventmodelers/cli learn "<one terse line>" --topic "<topic>"
59
50
  ```
60
51
 
61
- The learnings section is critical - it helps future iterations avoid repeating mistakes and understand the codebase better.
62
-
63
- ## Consolidate Patterns
64
-
65
- If you discover a **reusable pattern** that future iterations should know, add it to the `## Codebase Patterns` section at the TOP of progress.txt (create it if it doesn't exist).
66
-
67
- ```
68
- ## Codebase Patterns
69
- - TODO: an example of a your stack-specific reusable pattern once you have one
70
- ```
71
-
72
- Only add patterns that are **general and reusable**, not story-specific details.
52
+ - Only what is genuinely reusable: codebase patterns, gotchas, commands that work or don't, conventions — and, after a failed approach, what was tried and why it failed. Not slice-specific details, and nothing the code or git log already says.
53
+ - One learning per call, one line each. A learning that is already in `.build-kit/AGENTS.md` is skipped for you.
54
+ - `--scope system` for what is true of the modeled domain (a business rule, a naming convention of the model); `repo` (the default) for the codebase and its tooling. `--tag <tag>` labels it (repeatable).
55
+ - One in `.build-kit/AGENTS.md` that turned out wrong or obsolete: `npx @eventmodelers/cli learnings --ids` lists each with its id, `npx @eventmodelers/cli learn --retract <id>` removes it.
73
56
 
74
57
  ## Update AGENTS.md Files
75
58
 
@@ -80,7 +63,7 @@ Before committing, check if any edited files have learnings worth preserving in
80
63
  - Slice specific implementation details
81
64
  - Story-specific implementation details
82
65
  - Temporary debugging notes
83
- - Information already in progress.txt
66
+ - Information already recorded as a learning in `.build-kit/AGENTS.md`
84
67
  - Task-specific learnings
85
68
 
86
69
  Only update AGENTS.md if you have **genuinely reusable knowledge** that would help future work
@@ -124,9 +107,9 @@ If ALL slices in the current context are Done, reply with:
124
107
  - If no `.eventmodelers/config.json` exists anywhere (project root or an ancestor directory, or `~/.eventmodelers/config.json` — the one inside `.build-kit/` is only an optional override, so its absence means nothing), skip all platform communication (MCP calls, `update-slice-status`, board sync) and continue working locally.
125
108
  - Work on ONE slice per iteration
126
109
  - Commit frequently
127
- - update progress.txt frequently
128
- - Read the Codebase Patterns section in progress.txt before starting
110
+ - Record learnings as you go with `learn`
111
+ - Read `.build-kit/AGENTS.md` before starting
129
112
 
130
113
  ## When an iteration completes
131
114
 
132
- Use all the key learnings from the progress.txt and update the `.build-kit/AGENTS.md` file with those learnings.
115
+ Make sure every reusable learning is recorded with `learn`; `.build-kit/AGENTS.md` is generated from them — never edit it by hand.
@@ -4,17 +4,11 @@ You are an autonomous agent reacting to slice status change events on an Eventmo
4
4
 
5
5
  ## Your Loop
6
6
 
7
- 1. Read `AGENT.md` to load accumulated learnings before doing anything else.
8
- 2. Read `.build-kit/tasks.json`.
9
- 3. If `tasks.json` is empty or missing, reply with:
10
- <promise>IDLE</promise>
11
- and stop.
12
- 4. Pick the **oldest task** (earliest `createdAt`).
13
- 5. Execute the task — see the Execution section below.
14
- 6. After execution, remove that task from the array and write `.build-kit/tasks.json` back.
15
- 7. Append a progress entry to `progress.txt` (create if missing).
16
- 8. Update `AGENT.md` with any new reusable learnings discovered this iteration.
17
- 9. Reply normally so the next iteration can pick up the next task.
7
+ 1. Read `AGENT.md` and, if it exists, `.build-kit/AGENTS.md` to load accumulated knowledge before doing anything else.
8
+ 2. The task request at the end of this prompt names your task: its id and the slice change that queued it (`sliceId`, `sliceTitle`, `sliceStatus`, …). It is the oldest one waiting — the run loop picked it for you.
9
+ 3. Execute the task — see the Execution section below.
10
+ 4. Record any reusable learning with `npx @eventmodelers/cli learn "<one terse line>" --topic <topic>` (see **Recording Learnings**).
11
+ 5. Reply normally. The run loop completes the task when your turn ends and hands you the next one in a fresh turn — you never read or write a queue file.
18
12
 
19
13
  ## Execution
20
14
 
@@ -50,7 +44,7 @@ This is the build trigger. Setting `InProgress` and building are one atomic step
50
44
 
51
45
  1. Immediately call `/update-slice-status` to set the slice to `InProgress` on the board.
52
46
 
53
- **Claim conflict**: if this call reports the slice is already in `InProgress` (or any status other than `Planned`), another agent already claimed it first — this is expected, not an error. Log it in `progress.txt`, drop this task without building, and continue the loop (the next task will naturally cover the next slice). Do not retry.
47
+ **Claim conflict**: if this call reports the slice is already in `InProgress` (or any status other than `Planned`), another agent already claimed it first — this is expected, not an error. Say so in your reply, drop this task without building, and continue the loop (the next task will naturally cover the next slice). Do not retry.
54
48
 
55
49
  2. Run `/load-slice sliceId=<payload.sliceId>` to fetch the full slice, then read the slice definition from `.build-kit/.slices/<contextSlug>/<sliceFolder>/slice.json`. The runner keeps a `slice.json` fresh from a summary endpoint, so a file holding only `id`, `title`, `status` and `sliceType` is that stub, not an empty slice — never conclude a slice has no elements from it. Only if the full fetch itself returns no commands/events/read models/fields is the slice actually empty.
56
50
 
@@ -62,6 +56,20 @@ This is the build trigger. Setting `InProgress` and building are one atomic step
62
56
 
63
57
  4. Invoke the matching skill and follow its instructions **completely**. Do NOT implement the slice manually.
64
58
 
59
+ **Baseline gate** — before touching any code, run `npx @eventmodelers/cli build-baseline check --scope backend`.
60
+ It compares the board's node hashes of every element of the slice (commands, events, read models,
61
+ processors, specifications, ...) with what was recorded after the last successful build:
62
+ - `UNCHANGED` — nothing on the board changed. Do not rebuild or re-diff; run the slice's tests and
63
+ finish. Only now is "no code changes needed" a valid outcome.
64
+ - `NO_BASELINE` / `UNKNOWN` — no recorded build, or the board could not be read: do one full
65
+ field-by-field diff of slice.json against the code (never treat `UNKNOWN` as `UNCHANGED`).
66
+ - `CHANGED` — it lists the elements that changed, were added or were removed. Diff slice.json
67
+ against the code for exactly those and fix every drift; leave what matches alone.
68
+
69
+ When the checks pass, run `npx @eventmodelers/cli build-baseline record --scope backend` **before
70
+ committing**, so `ui-baseline.json` is committed with the slice. Never record without having done the
71
+ work the verdict asked for. Screens and UI prompts are not this kit's business and never trigger a build.
72
+
65
73
  5. **Verify against slice.json**: cross-check the implementation — every command field, event field, and specification in slice.json must appear in the code. No invented fields — if it is not in slice.json, it must not be in the code.
66
74
 
67
75
  6. Run quality checks (TODO: your stack's build + test commands — slice-scoped tests only, not the full suite).
@@ -74,52 +82,35 @@ This is the build trigger. Setting `InProgress` and building are one atomic step
74
82
  Another agent is already building this slice. Log it and skip — do not build.
75
83
 
76
84
  #### `Done`
77
- Summarize what was completed and update `progress.txt`.
85
+ Summarize what was completed in your reply.
78
86
 
79
87
  #### `Blocked`
80
- Log the blocker in `progress.txt`.
88
+ State the blocker in your reply.
81
89
 
82
90
  #### `Review`
83
- Fetch slice details and prepare a review summary in `progress.txt`.
91
+ Fetch slice details and prepare a review summary in your reply.
84
92
 
85
93
  #### Any other status (`Created`, etc.)
86
- Load the slice and log the state transition in `progress.txt`. No build action.
94
+ Load the slice and note the state transition in your reply. No build action.
87
95
 
88
96
  Use the skills available in `.claude/skills/` to interact with the board.
89
97
 
90
- ## Updating tasks.json
91
-
92
- After completing a task, remove it from the array and write the updated array back to `.build-kit/tasks.json`. If the array is now empty, write `[]`.
93
-
94
98
  ## Escalating Ambiguity
95
99
 
96
- **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line in `progress.txt` and as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
97
-
98
- ## Progress Report Format
100
+ **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, ...), pick the most sensible interpretation from `slice.json`, its specifications and the surrounding model, build it, and record each assumption in one line as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
99
101
 
100
- APPEND to `progress.txt` (never replace):
101
- ```
102
- ## [ISO timestamp] — Task [task.id]
102
+ ## Recording Learnings
103
103
 
104
- Slice: [sliceTitle] ([sliceId])
105
- Status change: [sliceStatus]
104
+ `.build-kit/AGENTS.md` is generated from the learnings recorded so far — read it at the start of every session, never edit it by hand. Record a learning the moment you have it:
106
105
 
107
- Action taken:
108
- - [what was done in response to the slice change]
109
-
110
- Learnings:
111
- - [any patterns, gotchas, or reusable knowledge discovered]
112
- ---
106
+ ```
107
+ npx @eventmodelers/cli learn "<one terse line>" --topic "<topic>"
113
108
  ```
114
109
 
115
- ## Stop Condition
116
-
117
- If `.build-kit/tasks.json` is empty (`[]`) or does not exist, reply with:
118
- <promise>IDLE</promise>
119
-
120
- ## Updating AGENT.md
121
-
122
- After completing a task, add any **reusable** learnings to `AGENT.md` — patterns, gotchas, API quirks, or skill behaviour that future iterations should know. Only add things that are general and applicable beyond this single task. Do not duplicate what is already there.
110
+ - Only what is genuinely reusable: codebase patterns, gotchas, commands that work or don't, conventions — and, after a failed approach, what was tried and why it failed. Not slice-specific details, and nothing the code or git log already says.
111
+ - One learning per call, one line each. A learning that is already in `.build-kit/AGENTS.md` is skipped for you.
112
+ - `--scope system` for what is true of the modeled domain (a business rule, a naming convention of the model); `repo` (the default) for the codebase and its tooling. `--tag <tag>` labels it (repeatable).
113
+ - One in `.build-kit/AGENTS.md` that turned out wrong or obsolete: `npx @eventmodelers/cli learnings --ids` lists each with its id, `npx @eventmodelers/cli learn --retract <id>` removes it.
123
114
 
124
115
  ## Important
125
116
 
@@ -52,7 +52,7 @@ Locate where the trigger event's state change happens in the code — the **Slic
52
52
  | in-process application/domain events (e.g. Spring `ApplicationEventPublisher`, MediatR notifications, Node `EventEmitter`) | a listener on the existing event for the trigger — or publish a new one from the trigger's service method the same way others are published |
53
53
  | transactional outbox / message broker | a consumer on the existing topic/queue, registered like the reference consumer |
54
54
  | scheduler / job framework | a scheduled job that queries the todo-list read model (or the trigger's persisted state) for pending items and fires the command per item |
55
- | none of the above | the least invasive option consistent with the codebase: a direct call from the trigger's service method after it commits, or a scheduled job if the reaction must be decoupled/retried. Record the choice in `progress.txt` and in `ARCHITECTURE.md` so later automations reuse it |
55
+ | none of the above | the least invasive option consistent with the codebase: a direct call from the trigger's service method after it commits, or a scheduled job if the reaction must be decoupled/retried. Record the choice in `ARCHITECTURE.md` so later automations reuse it |
56
56
 
57
57
  Rules:
58
58
  - Map trigger fields → command fields exactly as slice.json defines; no extra fields.
@@ -118,5 +118,5 @@ the endpoint's contract as the `## UI Contract` section of the slice's feedback-
118
118
  - [ ] The new code mirrors its precedent slice (or the reference implementation): layout, naming and conventions; no new framework, library or architectural style was introduced
119
119
  - [ ] Data produced by existing slices was reused, not duplicated
120
120
  - [ ] The slice lives in its own files; shared files were touched only at the seams in `ARCHITECTURE.md`, and its Slice map row lists them
121
- - [ ] Assumptions are recorded in `progress.txt` and as code comments
121
+ - [ ] Assumptions are recorded as code comments
122
122
  - [ ] The evidence note exists in the slice's column on the board (`/record-evidence`)
@@ -47,7 +47,7 @@ If a Done slice in this context has no row in the Slice map, run `/learn-archite
47
47
  For every read model field, find where the feeding event's data is persisted (the entity/table/column written by that event's state-change slice). Search by event name, entity and field names.
48
48
 
49
49
  - **Found** → the field is read from there.
50
- - **Not persisted anywhere** (the state-change slice isn't built yet, or never stored that field) → do not invent a parallel store. Add the missing column/entity the way the reference does (new migration) only if it clearly belongs to this read; otherwise record the gap as an assumption in `progress.txt` and as a code comment.
50
+ - **Not persisted anywhere** (the state-change slice isn't built yet, or never stored that field) → do not invent a parallel store. Add the missing column/entity the way the reference does (new migration) only if it clearly belongs to this read; otherwise record the gap as an assumption as a code comment.
51
51
 
52
52
  If the slice reappears as `Planned` and a query for it already exists, treat this skill as a **diff** against slice.json: add missing fields, remove fields slice.json no longer has, add missing specifications.
53
53
 
@@ -120,5 +120,5 @@ the endpoint's contract as the `## UI Contract` section of the slice's feedback-
120
120
  - [ ] If `storylines[]` is present, a storyline-derived test was added for every isolable read-model transition (adjacent READMODEL beats with only EVENT beats between them)
121
121
  - [ ] The new code mirrors its precedent slice (or the reference implementation): layout, naming and conventions; no new framework, library or architectural style was introduced
122
122
  - [ ] The slice lives in its own files; shared files were touched only at the seams in `ARCHITECTURE.md`, and its Slice map row lists them
123
- - [ ] Assumptions and data gaps are recorded in `progress.txt` and as code comments
123
+ - [ ] Assumptions and data gaps are recorded as code comments
124
124
  - [ ] The evidence note exists in the slice's column on the board (`/record-evidence`)
@@ -26,7 +26,7 @@ From the slice you just built (or, for a legacy slice, from its row in the **Sli
26
26
  | Field → code mapping | every command / event / read-model field and the parameter, property or column it maps to |
27
27
  | Specification → test mapping | every entry in `specifications[]` (and storyline-derived tests) and the test class + method that covers it |
28
28
  | Shared seams | the `Shared seams` column of the slice's Slice map row |
29
- | Assumptions | the lines this slice added to `progress.txt` |
29
+ | Assumptions | the assumptions this slice recorded as code comments |
30
30
  | Quality checks | the build and test commands from `ARCHITECTURE.md` you ran, and their result |
31
31
 
32
32
  Only list what is really in the code. If an element has no counterpart (e.g. a modeled event the CRUD codebase has no equivalent for), say so explicitly — `— (persisted as the row insert, no event class)` — instead of leaving it out.
@@ -174,4 +174,4 @@ Note: <noteId> in lane Implementation, column <COLUMN_ID> (created|updated)
174
174
  Commit: <sha>
175
175
  ```
176
176
 
177
- A failed write here never undoes the build: log it in `progress.txt` and continue with the status update — but do not skip this step silently.
177
+ A failed write here never undoes the build: say so in your reply and continue with the status update — but do not skip this step silently.
@@ -27,16 +27,16 @@ Ignore case for files and slices in prompts. "CartItems" slice is the same as "c
27
27
 
28
28
  Do not change existing tests unless explicitly instructed, or the change brings the test in line with slice.json (e.g. step 4's field/spec diff).
29
29
 
30
- At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings.
30
+ At the start of every session, read `.build-kit/AGENTS.md` if it exists to load accumulated project learnings. It is generated from the learnings recorded so far — record a new one with `npx @eventmodelers/cli learn "<one terse line>" --topic <topic>`, never by editing the file.
31
31
 
32
- When starting to work on a slice, invoke the `update-slice-status` skill with `InProgress` status before doing anything else.
32
+ When working from a queued task, invoke the `update-slice-status` skill with `InProgress` status before doing anything else. When the task request names the slice to build (a run-loop build), the run loop has already set it to `InProgress` and pushes the final status itself — do not call `update-slice-status`; record the outcome with `npx @eventmodelers/cli slice-status <status>`.
33
33
 
34
34
  ## Building a Slice
35
35
 
36
36
  **CRITICAL: You MUST always use the provided skills to build slices. NEVER implement a slice manually.**
37
37
  **ALL fields, event names, command names, and business rules MUST come exclusively from slice.json. Do NOT invent, assume, or guess any field or logic not present in the slice definition.**
38
38
 
39
- **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, where a file should live, ...), pick the most sensible interpretation from `slice.json`, its specifications, the surrounding model and the existing code, build it, and record each assumption in one line in `progress.txt` and as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
39
+ **Default: make a reasonable assumption and build the slice.** If a detail is unclear or missing (an example value, a field type, a status mapping, a referenced event that isn't modeled yet, where a file should live, ...), pick the most sensible interpretation from `slice.json`, its specifications, the surrounding model and the existing code, build it, and record each assumption in one line as a code comment. Ambiguity alone is never a reason to stop. **Only if the slice literally cannot be built** — nothing runnable can be produced even with sensible assumptions — invoke `/request-feedback` with the specific question; it posts the question as a comment on the slice and marks it `Blocked`. That must be the absolute exception; a `Blocked` slice should mean "impossible without a human", never "the agent preferred to ask".
40
40
 
41
41
  When asked to build a slice, always follow this flow:
42
42
 
@@ -48,11 +48,12 @@ When asked to build a slice, always follow this flow:
48
48
  - **State-view** — `projections` or `queries` array is non-empty → invoke `/build-state-view`
49
49
  - **State-change** — default (has `commands` / `events`) → invoke `/build-state-change`
50
50
  4. Invoke the matching skill and follow its instructions completely. Do not deviate.
51
- 5. **Verify against slice.json**: After the skill completes, check that every command field, event field, read model field and specification in slice.json has its counterpart in the implementation. No invented fields — if it is not in slice.json, it must not be in the code. This applies even when the slice was previously `Done` and reappears as `Planned` — never dismiss a mismatch as "already implemented" or harmless drift; diff slice.json against the code field by field and update the code to match every change.
52
- 6. Run the quality checks from `.build-kit/ARCHITECTURE.md` (build/compile, then only the tests this slice touched).
53
- 7. If checks pass, make sure the slice's row in the Slice map is added/updated and commit with `feat: [Slice Name]`.
54
- 8. Invoke `/record-evidence` — it writes the implementation evidence (element → code mapping, files, specification → test mapping, seams, assumptions, commit) as a markdown note into the slice's column, in the chapter's `Implementation` feedback lane.
55
- 9. Set slice status to `Done`.
51
+ 5. **Baseline gate**: run `npx @eventmodelers/cli build-baseline check --scope backend` first and act only on its verdict — `UNCHANGED` means nothing on the board changed since the last recorded build: do not rebuild, just run the slice's tests and finish; `NO_BASELINE`/`UNKNOWN` mean one full field-by-field diff of slice.json against the code; `CHANGED` lists exactly which elements changed, were added or removed — diff and fix only those. After the checks pass and before committing, run `build-baseline record --scope backend`. A screen or UI prompt change never triggers a backend build.
52
+ 6. **Verify against slice.json**: After the skill completes, check that every command field, event field, read model field and specification in slice.json has its counterpart in the implementation. No invented fields — if it is not in slice.json, it must not be in the code. This applies even when the slice was previously `Done` and reappears as `Planned` — never dismiss a mismatch as "already implemented" or harmless drift; diff slice.json against the code field by field and update the code to match every change.
53
+ 7. Run the quality checks from `.build-kit/ARCHITECTURE.md` (build/compile, then only the tests this slice touched).
54
+ 8. If checks pass, make sure the slice's row in the Slice map is added/updated and commit with `feat: [Slice Name]`.
55
+ 9. Invoke `/record-evidence` — it writes the implementation evidence (element → code mapping, files, specification → test mapping, seams, assumptions, commit) as a markdown note into the slice's column, in the chapter's `Implementation` feedback lane.
56
+ 10. Set slice status to `Done`.
56
57
 
57
58
  After you are done, automatically run the tests for the slice that was edited.
58
59
 
@@ -1,12 +1,11 @@
1
- # Agent Learnings
1
+ # Agent Reference
2
2
 
3
- Patterns and gotchas discovered during task processing. Update this file whenever you encounter something reusable.
3
+ What task processing relies on: the shape of a task and the API facts the skills use. A reusable learning is recorded with `npx @eventmodelers/cli learn "<one terse line>"`, not added here.
4
4
 
5
- ## tasks.json
5
+ ## Tasks
6
6
 
7
- - Tasks are objects with `id`, `createdAt`, and `payload` (a `SliceChangedPayload`).
8
- - After completing a task, remove it from the array entirely — do not add a status field.
9
- - Write `[]` to `tasks.json` if the last task is completed.
7
+ - A task is a slice change the run loop queued: an `id` and a `payload` (a `SliceChangedPayload`). The task request names it.
8
+ - You never read or write a queue file: the run loop completes the task when your turn ends.
10
9
 
11
10
  ## SliceChangedPayload fields
12
11
 
@@ -44,4 +43,4 @@ These files are always up to date — read them directly before invoking any ski
44
43
  - The `boardId` and `organizationId` from each payload provide full context — pass them to skills.
45
44
  - Node events use `node:created`, `node:changed`, `node:deleted` — always POST to `/api/org/:orgId/boards/:boardId/nodes/events`.
46
45
  - Slice metadata (title, status) lives on the SLICE_BORDER node under `meta.sliceStatus` and `meta.title`.
47
- - `/update-slice-status` rejects moving a slice into a status it's already in — this is a concurrency guard, not a bug. It means another agent already claimed the slice. Treat it as `ALREADY_IN_STATUS`, skip that slice, and move on to the next `Planned` one instead of erroring out.
46
+ - `/update-slice-status` rejects moving a slice into a status it's already in — this is a concurrency guard, not a bug. It means another agent already claimed the slice. Treat it as `ALREADY_IN_STATUS`, skip that slice, and move on to the next `Planned` one instead of erroring out. This applies to queued tasks only: when the task request names the slice to build, the run loop owns its status — never call `/update-slice-status` there.