Skip to content

Commit 4035cce

Browse files
committed
docs(ai): add design history workflow
Document git history checks before changing unclear behavior. Signed-off-by: Cyril Fougeray <cyril.fougeray@toolsforhumanity.com>
1 parent b22fc2d commit 4035cce

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

utils/ai/AGENT.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This repository contains the MCU firmware for the Worldcoin Orb, built with Zeph
1010

1111
- Keep changes small and compiling.
1212
- Prefer existing patterns; do not introduce new dependencies without asking.
13+
- When design intent is unclear, inspect commit history before changing behavior.
1314
- If unsure, propose 2 options with tradeoffs (don't guess).
1415

1516
## Path Discovery
@@ -199,6 +200,44 @@ See [Twister documentation](https://docs.zephyrproject.org/latest/develop/test/t
199200
- If the repo defines formatting/lint scripts, run them.
200201
- Don't reformat unrelated code.
201202

203+
## Design Decision Archaeology
204+
205+
When a requested change touches behavior whose rationale is unclear, treat git history as part of the documentation. Commit messages, old diffs, and PR references often explain why the current design exists.
206+
207+
Use this workflow before changing behavior in non-trivial paths:
208+
209+
1. Identify the relevant files, symbols, Kconfig options, devicetree nodes, and log messages with `rg`.
210+
2. Inspect file history in the owning repo:
211+
```bash
212+
git log --follow --oneline -- <path>
213+
git log --follow -p -- <path>
214+
```
215+
3. Inspect line or symbol history when the relevant code is localized:
216+
```bash
217+
git blame -L <start>,<end> -- <path>
218+
git log -S'<symbol-or-string>' -- <path>
219+
git log -G'<regex>' -- <path>
220+
```
221+
4. Search commit messages for the design concept and nearby terms:
222+
```bash
223+
git log --all --oneline --grep='<keyword>'
224+
git log --all --format='%h %ad %s' --date=short --grep='<keyword>'
225+
```
226+
5. Open the most relevant commits:
227+
```bash
228+
git show --stat --find-renames <commit>
229+
git show --format=fuller <commit> -- <path>
230+
```
231+
6. If a commit references a PR, issue, ticket, or design document, inspect it when available. Prefer primary sources over guessing.
232+
233+
Rules:
234+
235+
- Run history commands from the repo that owns the file (`<PUBLIC_REPO>`, `<PRIVATE_REPO>`, Zephyr, or a module repo).
236+
- If the checkout is shallow or missing older history, say so and ask before fetching deeper history.
237+
- Do not cargo-cult old behavior. Use history to understand constraints, then compare against the current code and current request.
238+
- In the final answer, cite any history that affected the implementation: commit hash, date, subject, and what design constraint it revealed.
239+
- Clearly separate "confirmed by history" from "inferred from current code". If no useful history is found, say that explicitly.
240+
202241
## Output Expectations
203242

204243
- **Before coding**: A short plan (3–6 steps).

0 commit comments

Comments
 (0)