Skip to main content

Learning Loop

The learning loop is how Kalami gets smarter over time. It runs automatically at the start of every Claude Code session — no manual action needed.

What happens each session

  1. Session starts — Kalami's hook fires
  2. Analyze previous session — reads the transcript from last time
  3. Extract lessons — finds corrections, error-fix pairs, and AI notes
  4. Generate rules — up to 5 new rules per session
  5. Update rankings — verified rules go up, stale ones go down
  6. Deliver context — Claude receives all active rules before writing any code

This cycle repeats every session. The more you use Claude, the better Kalami gets at preventing mistakes.

Session requirement

Kalami needs at least 10 user messages in a session before it analyzes it. Short sessions (quick questions, single commands) are skipped — there isn't enough signal to learn from.

EXP and milestones

Every rule extracted earns EXP (experience points). Milestones tell you how well Kalami knows your project:

EXPWhat it means
5Kalami is getting to know your project
10Repeat mistakes are decreasing
20Claude is well-adapted to your codebase
50You have a unique AI coding partner
100Deep project expertise

Check your current EXP with npx kalami status.

Session continuity

Kalami tracks progress across sessions in .kalami/progress.md:

  • What was accomplished in the last session
  • What was left unfinished
  • Current branch and plan status

At the start of each session, Claude reads this context and picks up where you left off. No more "what were we working on?"

Report card

At the end of each session, Kalami generates a report card:

  • Rules that were verified (proved useful this session)
  • Corrections that were captured
  • Files that were modified
  • Session duration and activity summary

This feeds into the next loop cycle.

Rate of learning

  • Max 5 rules per session — prevents flooding with low-quality rules
  • Fade after 5 sessions — unverified rules are removed
  • Immediate exclusion — contradicted rules are gone instantly
  • Budget-managed — only the best rules fit in the context window

The system is self-correcting. Bad rules don't survive.