Rules
Rules are the core of Kalami. They are instructions that Claude reads at the start of every session — learned from your corrections and the mistakes you've fixed.
What a rule looks like
NEVER use `any` type in TypeScript — always define proper interfaces
src/
(verified 3, added: 2026-03-10, s:5)
- Line 1: The instruction — starts with NEVER, ALWAYS, PREFER, AVOID, or MUST
- Line 2: Which part of the code it applies to (e.g.,
src/) - Line 3: Metadata — how many times it's been verified, when it was added, which session
How rules are created
Kalami captures three types of learning signals:
1. Your corrections (highest quality)
When you tell Claude "no, do it this way," Kalami records the correction and turns it into a rule.
You: "Don't mock the database in tests, use the real database"
Kalami creates:
NEVER mock the database in integration tests — use real database connections
2. Error-fix pairs
When a command fails, Claude fixes the code, and the command passes — Kalami records both the wrong and right versions.
npm testfails → Claude fixes a type error →npm testpassesKalami creates a rule with the WRONG/RIGHT code pair
3. AI self-recorded
Claude can voluntarily record a lesson when it discovers something important about your project.
How rules are ranked
Not all rules are equal. Kalami uses verified count to rank them:
- Every time a rule proves relevant in a session, its count goes up
- Rules with higher counts get priority in the context budget
- Rules with zero verification after 5 sessions fade out
- Rules that contradict a newer correction are immediately excluded
This means your rule set stays fresh — useful rules survive, outdated ones disappear.
Where rules live
| File | Purpose |
|---|---|
.kalami/index.md | The experience database — all rules ever learned |
.claude/rules/kalami-rules.md | Active rules delivered to Claude (regenerated each session) |
.claude/rules/kalami-workflow.md | Universal rules (commit format, branch naming, coding standards) |
How many rules can you have?
Kalami manages a context budget — a token limit for rules delivered to Claude. When the budget is full, lower-ranked rules are excluded. Check your budget with:
npx kalami context
Viewing your rules
npx kalami lessons # All verified rules, grouped by module
npx kalami status # Summary with rule counts and recent corrections