Custom Rules
"How do I make the AI follow my conventions without repeating them every session?"
A rule is a behavioral instruction for your AI assistant. A trigger is the situation where it fires. Together, they let you encode your working conventions so the AI follows them automatically โ without you repeating them every session.
What a rule looks likeโ
Rules live in rules.md (personal) or knowledge/rules.md (project). Each rule is a plain-language instruction:
### Always run tests before pushing
Run the full test suite before any `git push`. If tests fail, fix them first โ do not push with failures.
What a trigger looks likeโ
Triggers live in triggers.md. Each trigger names the rule and declares when it applies:
## Before pushing to origin
- Apply: `rules.md ยง Always run tests before pushing`
The trigger fires when the phase matches โ before a push, at session start, before creating a PR, etc.
Rules vs. identityโ
Your identity file (me.md) describes who you are โ your expertise, preferences, and working style. Rules describe how the AI should behave in specific situations.
- Use
me.mdfor: "I prefer explicit over clever" or "I've been using Go for ten years." - Use
rules.mdfor: "Always write a failing test before implementing" or "Never force-push to main."
Writing a good ruleโ
Good rules are:
- Specific โ "run
npm test" beats "run tests" - Actionable โ the AI can follow them without judgment calls
- Bounded โ rules with triggers are more reliable than unconditional ones
Capturing rulesโ
Run /kmgraph:rules-capture to add a new rule. The skill prompts you for the rule text and whether it applies in specific situations โ then routes it to the right file automatically.
Relatedโ
- Your AI Profile โ identity vs. behavior: what goes where
- Customize Hooks โ automate rule enforcement at the shell level