The life of a lesson.
From one correction to never again.
A lesson is born from a mistake you already fixed, earns its place with evidence, and keeps it only while it catches repeats. Here is every step, with the files and output you will actually see.
scar init, scar learn (from a commit or a session, with command guards), scar lessons ls, show, verify, archive and restore, scar check (grep, file-absent, command), scar compile, hooks for Claude Code, Codex and pre-commit, and scar doctor. It works offline and sends nothing anywhere. Anything marked Planned is not built.You fix it once, the way you already do.
Nothing changes in how you work. Scarcheck's hooks for Claude Code and Codex watch the session for a correction: a turn that rejects what the agent just did, followed by a commit that fixes it.
- A rejection
"no", "never", "don't" right after a tool call. Session
7f3c, turn 12. - A fix that lands
A commit after the correction. Scarcheck does not treat it as this session's, because HEAD moving does not show who committed. You name it with
scar learn --from-commit. - Or you say so
scar learn --from-commit a41f9e2works any time, with or without a session.
Scarcheck suggests scar learn when a session ends. Auto-capture, planned, will draft the lesson for you. Either way, nothing is saved until the evidence holds.
A lesson needs proof, not a good feeling.
scar learn drafts a rule and a check from the correction, then replays your git history. The check must fail on the commit before the fix and pass on the fix. If it cannot, the lesson stays a draft and never reaches a rules file.
a41f9e2^before the fixpackage-lock.json is present. The check fails, as it must.
a41f9e2the fixpackage-lock.json is gone. The check passes.
HEADtodayStill passes, with 0 existing violations, so it is safe to enforce from now on.
Why both sides. A check that passes before and after proves nothing. One that fails on both is broken. Only fail, then pass, makes a lesson.
- A fix commit
The check fails on its parent and passes on it. L-142,
a41f9e2. - A failing, then passing test
Any test command. L-131 fails
tz.spec.tsbefore, passes after. - A correction session
Explains why the rule exists. It links the lesson to the conversation, but never verifies it alone.
--- id: L-142 rule: Use pnpm. Never npm or yarn in this repo. scope: repo trigger: ["package.json", "tool:Bash"] status: verified evidence: - commit: a41f9e2 - correction: claude-code session 7f3c, turn 12 checks: - file-absent: [package-lock.json, yarn.lock] - block-command: "^(npm (i|install)|yarn add)\\b" instead: "pnpm add {args}" proof: before: { commit: 7c01d55, result: fail } # a41f9e2^ after: { commit: a41f9e2, result: pass } verified_at: 2026-10-21T09:14:03Z learned_by: alex@acme.dev review_after: 2027-01-23 --- The repo is a pnpm workspace. npm writes a lockfile pnpm ignores, so CI installs different versions. Fix: pnpm add <pkg> --filter <app>
One lesson, five rules files, one budget.
scar compile writes verified lessons into each agent's native rules file. It writes only inside a fenced block it owns, so your own text above and below stays yours. A token budget keeps that block short enough to be read.
- Verified lessons only. Drafts, conflicts, failing checks and stale lessons whose premise changed stay out.
- Ranked by repeats caught in the last 90 days, then repo before org before personal.
- Over budget? The lowest-ranked lessons leave the text. Their checks and guards keep running.
## Testing Run `pnpm test` from the repo root before you push. -<!-- scarcheck:start v1 sha=3f9a1c2 -->+<!-- scarcheck:start v1 sha=8b41e07 -->-<!-- 17 lessons, 1,184 tokens. Edit .scarcheck/lessons, not this block. -->+<!-- 18 lessons, 1,212 tokens. Edit .scarcheck/lessons, not this block. --> ## Scarcheck lessons+- Use pnpm. Never npm or yarn in this repo. Fix: `pnpm add <pkg> --filter <app>`. (L-142) - API dates are UTC ISO strings. Parse with parseISO, never new Date(str). (L-131) - Read feature flags through flags.get(). Never import the flag SDK client directly. (L-119) - Run tests with TZ=UTC. (L-104) 14 more lessons <!-- scarcheck:end -->
The check runs where the repeat would land.
A rule in a file is advice. A check is a fact. Every lesson's check runs at three points, from the fastest to the last line of defense, and a repeat is stopped with the lesson and the fix, not a lecture.
Agent hooks
PreToolUse hooks for Claude Code and Codex. A guard answers before the command runs and never touches the network.
Pre-commit
scar check --staged checks staged content against every lesson before the commit lands. Works with husky, lefthook and pre-commit.
CI
Every pull request, with an annotation on the exact line. Catches what was committed with --no-verify.
- Run actions/checkout@v42s
- Run buildwithme/setup-scarcheck@v13s
- Run scar compile --check1s
- Run scar check --ci --base origin/main4s
✗ L-131 API dates are UTC ISO strings. Parse with parseISO, never new Date(str). apps/web/src/lib/orders.ts:48:17 48 │ const placed = new Date(order.placedAt); fix parseISO(order.placedAt) · import { parseISO } from "date-fns" 1 repeat in 1 file · 18 lessons · 9 changed files · 2.4sError: Process completed with exit code 1.
Lessons expire unless they keep paying rent. Planned
Every catch pushes a lesson's review date 90 days out. A lesson that stops catching anything, points at something that changed, or contradicts another lesson comes to you for review instead of rotting in a rules file.
Use pnpm. Never npm or yarn in this repo.
- Repeats caught
- 7 in 4 days
- Review after
- 2027-01-23
- If it goes quiet
- Comes up in
scar reviewon that date. Not renewed in 14 days: expires and leaves every rules file.
Only use Node 18 APIs.
- Why it is stale
- The fact it rests on changed, and nothing has tripped the check in 90 days.
- Suggested
- Archive it, or rewrite it for Node 22 and verify again.
- Meanwhile
- Held back from rules files, because its premise changed. A lesson that has only gone quiet stays until its review date.
Conflict detection Planned
Will be detected and resolved withscar review.
Use pnpm. Never npm or yarn in this repo.
Use yarn workspaces for new packages.
Held back from all 5 rules files
Why Scarcheck flagged it
L-140's check needs a yarn.lock, and L-142's check fails if one exists. Both cannot pass on the same commit, so an agent reading both would pick one at random. Until someone decides, only L-142 is compiled. The options:
- Keep one: L-142 stays, L-140 is archived with your reason, and Taylor is notified.
- Scope both: narrow each by path so they no longer overlap. Both verify again.
- Merge: one lesson with both sets of evidence. It stays a draft until it verifies again.
Memory for context. Scarcheck for proof.
Memory tools and Scarcheck do different jobs. Use both.
| Scarcheck | Claude Code auto memory | claude-mem | Vectorize Hindsight | Mem0 | |
|---|---|---|---|---|---|
| Catches a repeat with a check at commit and in CI | Yes | No | No | No | No |
| Needs no AI model to save or recall | Yes | No | No | No | No |
| Lessons are plain files reviewed in pull requests | Yes | No | No | No | No |
| Remembers broad project context and past work | No | Yes | Yes | Yes | Yes |
| Works with several agents | Yes | No | Yes | Yes | Yes |
Based on each project's public docs in November 2026. Corrections welcome in an issue.
What Scarcheck does not do.
Saying no is most of the design. These are the things we left out on purpose, and will keep out.
No repository upload
Checks run on your machine and on your CI runner. The CLI is offline: it sends nothing anywhere.
No generic memory
It does not record everything the agent saw or said. It keeps a short list of rules, each tied to one mistake and one check.
No rules without evidence
Nothing is written into a rules file until a check fails before the fix and passes after. Unproven ideas wait as drafts.
No edits outside its block
Your CLAUDE.md and AGENTS.md stay yours. Scarcheck touches only the lines between its own markers.
Your next correction is your first lesson.
Free and open source. Install it, then run scar init.