Record Lesson
arch_record_lessonRecord a codebase rule the agent must follow next time, capturing the user's correction and the situation it applies to. Use it so future sessions avoid repeating the same non-obvious mistake.
Instructions
Record a lesson — a rule the agent should follow next time. Use when the user corrects a non-obvious mistake of yours, OR when you accept an unusual approach that would surprise a future reader. Skip typos, parser errors, and facts trivially visible in code.
Belongs here (arch) vs. agent-side memory (auto-memory / CLAUDE.md / AGENTS.md):
arch (this tool) — rules about the code: contracts, boundaries, patterns, API shape, type invariants, framework gotchas, schema/migration constraints, security rules tied to the codebase. Examples: "GraphQL admin mutations require a non-null ID and a corresponding picker query", "Always preserve createdAt on re-upsert", "Run integration tests against a real database, not mocks".
agent-side memory (not here) — rules about the user's workflow or how to collaborate with them: preferred commit style, branch naming, when to ask vs act, formatting preferences. Those live in auto-memory or a CLAUDE.md / AGENTS.md file — not in arch.
Heuristic: if a new engineer joining the codebase would need it → write it here. If only this specific user needs it → it's agent-side memory.
Three fields, each markdown:
rule: one imperative sentence (the rule).why: 1-3 sentences with the incident — quote the user verbatim when possible.when: one sentence describing the situation in which the rule applies. The server runs a similarity gate; possible outcomes:created: a new lesson was written.updated: a near-duplicate already existed — its updatedAt was bumped (confirmation signal). Refine the existing card if your wording was better.similar: a related lesson exists — nothing is written. Decide whether to refine the existing or write a clearly distinct one.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| why | Yes | 1-3 sentences. The incident or reason. Quote the user verbatim if they corrected you. | |
| rule | Yes | One imperative sentence — the rule itself. E.g. "Always preserve createdAt on re-upsert." | |
| when | Yes | One sentence describing the situation in which this rule applies. Future-you must be able to recognise it. | |
| group | Yes | Target group | |
| scope | No | global | |
| project | No | Optional. Project this lesson is scoped to (same value the indexer uses in `payload.project`). Omit for lessons that apply across all projects in the group. | |
| evidence | No | Optional commit hash, PR link, or short quote backing the lesson. | |
| severity | No | info |