Session Rules
Every project accumulates "the agent did X wrong, we told it Y" moments. Those corrections are project law. This turns them from session chatter into a RULE.md every future session reads first.
Commands
python3 scripts/session_rules.py --cwd /path/to/project
python3 scripts/session_rules.py --cwd . --since 90 --out RULE.md
python3 scripts/session_rules.py --cwd . --json
What it extracts
User turns carrying correction signals:
- "no, never do X" / "don't do that again"
- "we use Y not Z" / "we prefer X"
- "always run X first" / "you should always"
- "stop doing X" / "that's wrong"
Each rule keeps the sentence containing the correction plus the full user turn as evidence. Review the output before committing — extraction is a draft, corrections are law.
Workflow
- Run it after a session where you corrected the agent more than once.
- Read the generated RULE.md; delete false positives, sharpen wording.
- Commit RULE.md to the repo root.
- Point future agent sessions at it (AGENTS.md, system prompt, or just
@RULE.mdin the first message).
Pairs with
session-handoff (the full session briefing when switching clients),
open-loops (unresolved commitments from the same sessions).