How it works

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.

Open source and early (v0.1).
Releases start with v0.1.0; you can also build it from the GitHub repository. Built today: 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.
  1. 01CorrectFix the agent once
  2. 02LearnProve it with history
  3. 03CompileWrite five rules files
  4. 04CatchBlock the repeat
  5. 05AgeExpire what stops working
  6. 06ShareGit, with provenance
01 / Correct

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.

What counts as a correction
  • 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 a41f9e2 works 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.

02 / Learn

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.

Verification replayVerified
  1. a41f9e2^before the fix

    package-lock.json is present. The check fails, as it must.

  2. a41f9e2the fix

    package-lock.json is gone. The check passes.

  3. HEADtoday

    Still 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.

Evidence Scarcheck accepts
  • 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.ts before, passes after.

  • A correction session

    Explains why the rule exists. It links the lesson to the conversation, but never verifies it alone.

.scarcheck/lessons/L-142.md
---
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>
03 / Compile

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.

Rules budget, acme/web1,212 / 1,500
  1. Verified lessons only. Drafts, conflicts, failing checks and stale lessons whose premise changed stay out.
  2. Ranked by repeats caught in the last 90 days, then repo before org before personal.
  3. Over budget? The lowest-ranked lessons leave the text. Their checks and guards keep running.
Same lesson, native format: CCLAUDE.md OAGENTS.md ▲.cursor/rules/scarcheck.mdc ⌁.clinerules/scarcheck.md ◎.github/copilot-instructions.md
04 / Catch

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.

Before the tool call

Agent hooks

PreToolUse hooks for Claude Code and Codex. A guard answers before the command runs and never touches the network.

Before the commit

Pre-commit

scar check --staged checks staged content against every lesson before the commit lands. Works with husky, lefthook and pre-commit.

Before the merge

CI

Every pull request, with an annotation on the exact line. Catches what was committed with --no-verify.

05 / Age

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.

Expiry
VerifiedL-142acme/web

Use pnpm. Never npm or yarn in this repo.

Last catch: today, laptop-290 days left
Repeats caught
7 in 4 days
Review after
2027-01-23
If it goes quiet
Comes up in scar review on that date. Not renewed in 14 days: expires and leaves every rules file.
Stale detection
StaleL-088acme/api

Only use Node 18 APIs.

.nvmrc is now 220 hits in 90 days
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 with scar review.
VerifiedL-142

Use pnpm. Never npm or yarn in this repo.

Alex Rivera, 4 days ago7 repeats caught
ConflictCheck failingL-140

Use yarn workspaces for new packages.

Taylor Kim, 12 min agoacme/web

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.
06 / Share

Shared through git, with provenance.

Lessons are files, so committing .scarcheck/ shares them with everyone who clones the repo. Each lesson records who learned it, from where, and the commit that proves it. Review a new lesson in the pull request like any other change.

Provenance, L-142acme/web
  1. Corrected

    Alex Rivera in Claude Code, session 7f3c, turn 12, on alex-mbp.

  2. Verified

    Check fails on a41f9e2^, passes on a41f9e2.

  3. Merged

    Sam Chen reviewed it in the pull request and merged it into acme/web.

  4. Caught 7 repeats

    Last one by Codex on laptop-2, before npm install dayjs ran.

Scarcheck and memory tools

Memory for context. Scarcheck for proof.

Memory tools and Scarcheck do different jobs. Use both.

ScarcheckClaude Code auto memoryclaude-memVectorize HindsightMem0
Catches a repeat with a check at commit and in CIYesNoNoNoNo
Needs no AI model to save or recallYesNoNoNoNo
Lessons are plain files reviewed in pull requestsYesNoNoNoNo
Remembers broad project context and past workNoYesYesYesYes
Works with several agentsYesNoYesYesYes

Based on each project's public docs in November 2026. Corrections welcome in an issue.

Boundaries

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.