/memory-loop:habitfrom memory-loop
Distill a lesson — a mistake, a user correction, or a praised behavior — into HABITS.md as a positive practice or a hard line, after it clears the damage/recurrence/generality gate. Use after the user corrects you, after an incident, or when a correction signal fires.
Ships in memory-loop. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
HABITS.md (default ~/.claude/groundwork/HABITS.md, created by the setup
skill) is the frame where lessons become standing behavior. If the file is
missing, tell the user to run /memory-loop:setup (step 2) first.
It is imported into every session, so it is re-read on every request — its size is paid per turn, multiplied by the length of the conversation. That is the whole reason this skill is mostly a set of gates: a habit file that captures everything is a file nobody can afford to load, and an unloaded habit file teaches nothing.
A lesson enters HABITS.md only when it clears all three. Answer them in order and out loud; a candidate that fails any one of them has a better home (see the routing table).
Context can flip gate 1: the same verification shortcut that is 🟢 during read-only exploration becomes 🛑 the moment its output feeds an external post, a PR, long-term memory, or a destructive change. Judge by where the output goes, not by the action alone.
| Fails | Goes to | Why |
|---|---|---|
| Recurrence (🟢, one-off) | nowhere — say so and move on | The cheapest correct answer. Most lessons are consumed by the session that learned them. |
| Generality (tool/flag/script-specific) | the wiki (dev-loop:wiki-ingest), or that tool's own docs | Retrievable when that tool is in play, absent when it is not. |
| Generality (one repo's layout, commands, conventions) | that repo's CLAUDE.md | Loads exactly where it applies. |
| Nothing — a fact, not a behavior | a memory (memory-loop:remember) | Habits are rules for acting; facts are recalled on demand. |
| All three cleared | HABITS.md | The always-loaded set. |
Routing away is the normal outcome — most sessions have nothing that clears all three gates, and that is a complete and correct result.
habits-budget-guard.sh (PreToolUse) denies any Edit or Write that grows
HABITS.md past its budget: habitsBudgetBytes (default 8000) and
habitsMaxRules (default 24, 🟢 and 🛑 counted together). The count is the
constraint that usually binds — a list stops working as a list long before it
stops being affordable — and the byte budget catches rules that grow into essays. A write that shrinks
the file is always allowed, so the way out is never blocked.
At budget, adding means removing. In order of preference:
HABITS-ARCHIVE.md beside HABITS.md, keeping its [Cnn] pointer so the case
record still resolves. Archiving is not deletion; nothing is lost.Keep each rule to about two lines (~240 characters). A rule that needs a paragraph is usually two rules, or one rule plus a case.
Background prose is what makes a rule file grow without bound, so it lives in
HABITS-CASES.md (same directory, not auto-loaded) and each rule carries a
[Cnn] pointer.
## Cnn to HABITS-CASES.md, put [Cnn] on the rule.
Number sequentially, never renumber — a stale pointer is worse than a long file.(← background: …) inline in HABITS.md, but one
sentence of it. For a prohibition the origin is the judgment you need at the
moment you'd cross it; the incident report still belongs in the cases file.A HABITS.md written before the split has its backgrounds inline and no cases
file beside it. A plugin update does not migrate it — templates are only
copied by setup, which never overwrites an existing file. So the code changes
underneath while the data stays as it was; closing that gap is a deliberate step:
HABITS-CASES.md next to HABITS.md — re-running the setup skill
drops in the template and leaves HABITS.md untouched.(← background: …) text into a ## Cnn
section in the cases file and leave [Cnn] on the rule. Number them in the
order the rules appear.## Cnn number.Relocate prose verbatim. Never reword a rule while moving its background: a migration that edits behavior while claiming to reorganize is the hardest kind of change to notice afterwards.
Before adding, read the whole of HABITS.md and look for an entry with an overlapping trigger — the situation the rule fires in, not its wording. Two rules that fire in the same moment are one rule, however different they sound. If one exists, strengthen or merge it; do not append a near-duplicate.
The failure mode this prevents is specific and common: a dozen rules that each say "check the real artifact before claiming" in the vocabulary of a different incident. Merged, they are one rule anyone can hold in their head. Separate, they are a file nobody reads.
Merging is not appending. A merged rule still fits in two lines; the new incident's detail goes to the cases file, never onto the end of the rule. The opposite failure is just as real: one rule that absorbs every related incident as another clause until it is a page long. Neither the byte budget nor the rule cap notices that until the whole file is over — a dozen two-line rules and one essay can weigh the same.
When the lesson is "an existing rule was violated again", the rule's text has
already failed once — the session that broke it had it loaded. Rewording or
lengthening it is the least effective response available. Record the
recurrence as a case (## Cnn, pointing at the rule) and put the rule on the
escalation ladder below: if the breach is mechanically detectable, it is a hook
candidate; if it is a procedure, a skill candidate.
One audit of a long-lived habit file that skipped this step found the same shape everywhere: the rules that kept being extended after each recurrence grew into the largest entries and kept recurring, while the only breaches that actually stopped were the ones promoted to hooks.
Default home is HABITS.md. Promote when — and only when — a rule is clear, repeated, and valuable, all three:
Leave a one-line tombstone in HABITS.md: → promoted to <hook/skill name>.
A promotion that frees budget is the best kind of addition.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
6 skills in this plugin
/consolidatePeriodically merge the memory index, long-tier memory files, and the habit file — deduplicate, resolve contradictions to the current truth, absolutize dates, bring HABITS.md back under budget — and propose the result for your confirmation before any write. Use when MEMORY.md grows large (~120+ lines), when the habit file is over budget, or when memories accumulate duplicates, contradictions, or stale facts./identitySet, change, or decline the user/assistant names that memory-loop injects at session start. Use when the user wants to set up names, rename either party, ask the assistant to pick its own name, or stop the name-setup offer from appearing./rememberSave gate for persistent memories — confirm tier (long/short) and expiry with the user before writing, so hallucinated or transient facts never enter long-term memory. Use whenever saving a memory file, and when the expiry sweep reports archived memories./setupFirst-time memory-loop setup — offer identity names, create HABITS.md and OUTPUT.md from the templates, wire their imports into ~/.claude/CLAUDE.md, write an initial config, and verify the hooks respond./tutorRun a spaced-repetition self-quiz over lessons already distilled into HABITS.md — one novel-scenario transfer question per due item, anti-sycophancy grading, and a 1-4 recall rating logged through the tutor scheduler. Use when the user asks to be quizzed or reviewed (English or Korean), or replies to a memory-loop tutor due-reminder line ("N개 복습 항목이 대기 중").memory-loop@buildwithclaude is listed by davepoon/buildwithclaude — review the source before installing
npx claudepluginhub davepoon/buildwithclaude --plugin memory-loop