# Session Rules

> Generates a RULE.md from a project's AI-session history by extracting every moment the human corrected the agent — "no, never use jwt", "always run tests first", "we use sessions not tokens". The highest-leverage context file a project can have is the one built from its own history of mistakes. Reads Claude Code, Codex, and OpenCode stores (same conventions as session-handoff), fully offline.

- Skill: `trac3r00/session-rules` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add trac3r00/session-rules`
- Raw SKILL.md: https://api.skillmd.com/api/skills/trac3r00/session-rules/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- License: MIT
- Author: trac3r00 (https://skillmd.com/u/trac3r00)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/trac3r00/session-rules

---


# 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

```bash
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

1. Run it after a session where you corrected the agent more than once.
2. Read the generated RULE.md; delete false positives, sharpen wording.
3. Commit RULE.md to the repo root.
4. Point future agent sessions at it (AGENTS.md, system prompt, or just
   `@RULE.md` in the first message).

## Pairs with

`session-handoff` (the full session briefing when switching clients),
`open-loops` (unresolved commitments from the same sessions).

