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
- Session starts — Kalami's hook fires
- Analyze previous session — reads the transcript from last time
- Extract lessons — finds corrections, error-fix pairs, and AI notes
- Generate rules — up to 5 new rules per session
- Update rankings — verified rules go up, stale ones go down
- 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:
| EXP | What it means |
|---|---|
| 5 | Kalami is getting to know your project |
| 10 | Repeat mistakes are decreasing |
| 20 | Claude is well-adapted to your codebase |
| 50 | You have a unique AI coding partner |
| 100 | Deep 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.