Make CLAUDE.md a short router, and move each topic's rules to a file under rules/ that loads when a session touches a matching file

This commit is contained in:
2026-10-13 00:24:17 +02:00
parent 72fd688d81
commit 6f8a650ac0
22 changed files with 183 additions and 130 deletions
+6 -4
View File
@@ -3,14 +3,16 @@ import pathlib
from loop_claude.project.text_file import read_utf8
from loop_claude.stop import Stop
# The records: these project files and HUMAN_RULES; the judge reads them beside the README's premises.
# The records: these project files and the human's rules; the judge reads them beside the README's premises.
RECORD_FILES = ("AGENTS.md", "docs/decisions.md")
HUMAN_RULES = "~/.claude/CLAUDE.md"
HUMAN_RULES = ("~/.claude/CLAUDE.md", "~/.claude/rules/")
def read_records(root: str, claude_md: pathlib.Path) -> str | Stop:
"""The project's record files, then the human's rules for every project, each headed by its name; a file that does not exist is left out."""
sources = [(root, name, name) for name in RECORD_FILES] + [(str(claude_md.parent), claude_md.name, HUMAN_RULES)]
"""The project's record files, then the human's rules for every project, CLAUDE.md first, each headed by its name; a file that does not exist is left out."""
rules = claude_md.parent / "rules"
sources = [(root, name, name) for name in RECORD_FILES] + [(str(claude_md.parent), claude_md.name, HUMAN_RULES[0])]
sources += [(str(rules), rule.name, HUMAN_RULES[1] + rule.name) for rule in sorted(rules.glob("*.md"))]
records = []
for folder, name, heading in sources:
if not pathlib.Path(folder, name).exists():