Mistake Reflection
Implements the mistake-handling step of AGENTS.md §"Mandatory
workflow".
When to load this skill
Trigger on ANY of these, without waiting for the user to ask:
- The user corrects a factual claim, code change, or assumption.
- A tool result contradicts something you just stated or did
(lint failure, test failure, type-check failure, file not found,
command exit non-zero on something you said would succeed).
- You re-read a file or doc and realize a prior statement was wrong
or unverified.
- You realize mid-task that you skipped a required step
(e.g. didn't read
docs/ai/coding_conventions.md,
docs/ai/mandatory_checks.md, or docs/ai/evidence_rules.md at
task start).
- You stated an inference as a fact without a
file:line citation
and later had to walk it back.
If unsure whether something counts: it counts. False positives are
cheap; false negatives are how the same mistake recurs.
Procedure
Do these in order. Do NOT defer to the end of the task.
- Acknowledge the mistake to the user explicitly in the current
response. One or two sentences. No hedging, no minimization.
- Read recent entries in
docs/ai/ai_learnings.md (at minimum
the last 5 entries, or the whole file if shorter). If the current
mistake is a recurrence of an existing rule, say so explicitly and
reference the prior entry's date — do not silently duplicate.
- Append a new entry to
docs/ai/ai_learnings.md using the
template below. Append; do not rewrite existing entries.
- Continue the original task only after steps 1–3 are done.
Entry template
Copy this verbatim, fill in each field, append to the end of the file
(after the existing --- separator):
## YYYY-MM-DD — <one-line summary>
- **Mistake**: What went wrong. Be concrete. Quote the wrong claim or
describe the wrong action. Include `file:line` references where
applicable.
- **Trigger**: How the mistake surfaced (user correction, tool output,
self-review). Include the specific signal if it was a tool result.
- **Root cause**: Why it happened. Distinguish between (a) missing
knowledge, (b) skipped verification step, (c) false assumption from
pattern-matching, (d) workflow gap. Avoid generic "I didn't think
carefully" — name the specific failure mode.
- **Recurrence of**: If this matches an existing rule, link to the
prior entry's date. Otherwise write "new".
- **Rule**: A concrete, checkable rule that would have prevented this.
Phrase as an imperative ("Before X, do Y"). If the rule already
exists and was violated, the rule should be about *enforcement*
(e.g. a check to add to a skill, a step to add to AGENTS.md), not a
restatement of the existing rule.
Anti-patterns to avoid
- Don't restate the same lesson with new wording. If
you'd write essentially the same rule again, the real fix is to
make the rule self-enforcing (update a skill or
AGENTS.md), not
to add a third entry.
- Don't let rules go stale. When you read prior entries, flag stale
tooling references and either update them or note the staleness in your
new entry.
- Don't write rules that depend on you remembering to follow them.
If a rule is "remember to do X at the start of every task", it will
be skipped. Prefer rules that bind to a tool, a skill trigger, or a
CI check.
- Don't bury the acknowledgement. Tell the user up front in the
response that you got it wrong, before describing the fix.
Cleanup ritual
Before appending, check the file's length:
- ≥ 10 entries: pause and propose to the user that one or more
entries be either (a) deleted (if obsolete or one-off), or (b)
promoted into the workflow somewhere it will actually be read. If
the candidate rule is about claims/citations/evidence specifically,
docs/ai/evidence_rules.md is a natural target — otherwise leave
the choice of destination to the user. Do this before adding the
new entry, so the file doesn't grow monotonically and stop being read.
This ritual is the only mechanism preventing ai_learnings.md from
becoming a write-only graveyard.
Repo-specific notes
docs/ai/ai_learnings.md is gitignored.
Entries are local to the developer's checkout and will not be seen
by other agents or in CI. The file is for the human developer to
improve AGENTS.md / skills based on patterns.
- The protocol source and trigger pointer both live in
AGENTS.md
§"Mandatory workflow". GEMINI.md is a deprecated stub.
- Date format is
YYYY-MM-DD to match existing entries.
1---2name: mistake-reflection3description: Use when you discover you made a mistake — caught by the user, by a tool result, by your own re-reading, or by a failed check. Appends a structured entry to docs/ai/ai_learnings.md and re-reads recent entries to avoid repeats.4---56# Mistake Reflection78Implements the mistake-handling step of `AGENTS.md` §"Mandatory9workflow".1011## When to load this skill1213Trigger on ANY of these, without waiting for the user to ask:1415- The user corrects a factual claim, code change, or assumption.16- A tool result contradicts something you just stated or did17 (lint failure, test failure, type-check failure, file not found,18 command exit non-zero on something you said would succeed).19- You re-read a file or doc and realize a prior statement was wrong20 or unverified.21- You realize mid-task that you skipped a required step22 (e.g. didn't read `docs/ai/coding_conventions.md`,23 `docs/ai/mandatory_checks.md`, or `docs/ai/evidence_rules.md` at24 task start).25- You stated an inference as a fact without a `file:line` citation26 and later had to walk it back.2728If unsure whether something counts: it counts. False positives are29cheap; false negatives are how the same mistake recurs.3031## Procedure3233Do these in order. Do NOT defer to the end of the task.34351. **Acknowledge the mistake to the user explicitly** in the current36 response. One or two sentences. No hedging, no minimization.372. **Read recent entries** in `docs/ai/ai_learnings.md` (at minimum38 the last 5 entries, or the whole file if shorter). If the current39 mistake is a recurrence of an existing rule, say so explicitly and40 reference the prior entry's date — do not silently duplicate.413. **Append a new entry** to `docs/ai/ai_learnings.md` using the42 template below. Append; do not rewrite existing entries.434. **Continue the original task** only after steps 1–3 are done.4445## Entry template4647Copy this verbatim, fill in each field, append to the end of the file48(after the existing `---` separator):4950```markdown51## YYYY-MM-DD — <one-line summary>5253- **Mistake**: What went wrong. Be concrete. Quote the wrong claim or54 describe the wrong action. Include `file:line` references where55 applicable.56- **Trigger**: How the mistake surfaced (user correction, tool output,57 self-review). Include the specific signal if it was a tool result.58- **Root cause**: Why it happened. Distinguish between (a) missing59 knowledge, (b) skipped verification step, (c) false assumption from60 pattern-matching, (d) workflow gap. Avoid generic "I didn't think61 carefully" — name the specific failure mode.62- **Recurrence of**: If this matches an existing rule, link to the63 prior entry's date. Otherwise write "new".64- **Rule**: A concrete, checkable rule that would have prevented this.65 Phrase as an imperative ("Before X, do Y"). If the rule already66 exists and was violated, the rule should be about *enforcement*67 (e.g. a check to add to a skill, a step to add to AGENTS.md), not a68 restatement of the existing rule.69```7071## Anti-patterns to avoid7273- **Don't restate the same lesson with new wording.** If74 you'd write essentially the same rule again, the real fix is to75 make the rule self-enforcing (update a skill or `AGENTS.md`), not76 to add a third entry.77- **Don't let rules go stale.** When you read prior entries, flag stale 78 tooling references and either update them or note the staleness in your 79 new entry.80- **Don't write rules that depend on you remembering to follow them.**81 If a rule is "remember to do X at the start of every task", it will82 be skipped. Prefer rules that bind to a tool, a skill trigger, or a83 CI check.84- **Don't bury the acknowledgement.** Tell the user up front in the85 response that you got it wrong, before describing the fix.8687## Cleanup ritual8889Before appending, check the file's length:9091- **≥ 10 entries**: pause and propose to the user that one or more92 entries be either (a) deleted (if obsolete or one-off), or (b)93 promoted into the workflow somewhere it will actually be read. If94 the candidate rule is about claims/citations/evidence specifically,95 `docs/ai/evidence_rules.md` is a natural target — otherwise leave96 the choice of destination to the user. Do this *before* adding the 97 new entry, so the file doesn't grow monotonically and stop being read.9899This ritual is the only mechanism preventing `ai_learnings.md` from100becoming a write-only graveyard.101102## Repo-specific notes103104- `docs/ai/ai_learnings.md` is **gitignored**.105 Entries are local to the developer's checkout and will not be seen106 by other agents or in CI. The file is for the human developer to107 improve `AGENTS.md` / skills based on patterns.108- The protocol source and trigger pointer both live in `AGENTS.md`109 §"Mandatory workflow". `GEMINI.md` is a deprecated stub.110- Date format is `YYYY-MM-DD` to match existing entries.