Why a File-Based Rules System?
Claude Rules Workflow
Chapter 1 · Why a File-Based Rules System?
This whole site — every numbered course, every language lesson, every kanji page — is generated according to a large, growing set of conventions: how a banner comment is formatted, where a file gets saved, when a PDF gets built, what a course does once it's finished. None of that lives in Claude's own memory as the single source of truth. It lives in plain text files, on disk, inside this repository's own rules/ folder — and this chapter is about why that specific design choice matters, and how it actually works today.
The Problem: Memory Isn't Guaranteed to Persist
Claude's built-in memory is genuinely useful — it's what lets a later session recall that a particular course prefers one bundled PR over several small ones, or that a user is a technical support engineer rather than a full-time developer. But memory is a convenience layer, not a guarantee. It can be cleared. A brand-new session can start with none of it. Two different environments running the same project might not share it at all. If every one of this project's own conventions — the banner-comment format, the course-folder-naming scheme, the PDF-on-completion rule — lived only in memory, a single cleared memory store would mean losing the instructions this entire site depends on to stay consistent.
The Fix: Files as the Source of Truth
The actual conventions live as plain English instructions in markdown files — permanent_rules.md, language_rules.md, kanji_rules.md, and several others, all inside this repository's own rules/ folder. There's nothing special about the file format; the discipline is entirely in keeping every rule in one place, on disk, where it survives regardless of what happens to any one session's memory. A rules file doesn't forget anything. It's exactly as reliable as the repository itself.
The Old Way — A Manual Recovery Prompt
An earlier version of this exact system (documented in a short, single-chapter reference file dated 2026-06-21 — itself now a historical artifact) relied on a dedicated recovery rule, R1, whose entire job was reminding a fresh session to go read the rules file:
This worked, but it depended entirely on someone remembering to paste that exact prompt at the start of every single session — a manual step, easy to forget, and only as good as whoever's job it was to remember it.
The Modern Way — Automatic Inclusion via @rules/
Today, the project's own CLAUDE.md file — read automatically at the start of every session in this repository, with no prompt needed at all — contains a short block like this:
Each @rules/<filename> line is an include — the full contents of that file are pulled directly into context automatically, every single session, before a single word of the actual conversation happens. There's no equivalent of R1 needed anymore, because there's nothing left to manually remember to ask for. The rules simply arrive.
CLAUDE.md currently contains a live callout: "Path correction (supersedes R1 in recovery_rules.md): The canonical rules location is claude-projects\website-content\rules\. The old path claude-generated-code\rules\ is deprecated." That's not a hypothetical example — it's this exact project, at some point mid-2026, moving its rules folder and explicitly noting that the entire manual R1 recovery mechanism from Chapter 1's own opening code block was superseded the moment automatic inclusion took over. The old rule wasn't deleted quietly; it was marked, in writing, as obsolete — which is itself a small demonstration of the discipline this whole course is about.
| Aspect | Manual Recovery (R1, 2026-06) | Automatic Inclusion (@rules/, today) |
|---|---|---|
| Trigger | Someone has to remember to paste the recovery prompt | Happens automatically at the start of every session |
| Failure mode | Forgetting to paste it means the rules are simply absent | Rules are present unless the include line itself is missing |
| Where it lives | A separate rule, itself relying on memory of its own existence | A structural part of how the session starts, not a rule to remember |
| What's still needed | Nothing extra — this was the whole mechanism | A new rules file must be added to the @rules/ list to be included (Chapter 10) |
Why This Still Matters Even With a Working Memory System
This project also has a real, separate auto-memory system (covered fully in Chapter 8) — so it's worth being precise about why the file-based rules layer hasn't been replaced by it. Memory is genuinely good at the kind of thing that's specific to one conversation or slowly-learned over time: a preference confirmed once, a project fact that will be stale in a month. The rules files are for the opposite case — a convention meant to apply identically to every single course, every single session, forever, until someone deliberately edits the rule itself. Putting that second kind of instruction in memory would mean it could quietly vary session to session; putting it in a file the whole project reads the same way every time is what keeps hundreds of generated chapters actually consistent with each other.
Hands-On Exercises
Explain, in your own words, why a rule meant to apply identically to every course generated on this site is better suited to a rules file than to Claude's memory system.
📄 View solutionThe old R1 recovery rule and the modern @rules/ include mechanism both solve the same underlying problem. Describe that problem, and explain specifically what changed between the two solutions in terms of what a human has to remember to do.
📄 View solutionA new rules file, say a hypothetical "video_lesson_rules.md", is written and saved into the rules/ folder, but the chapter-writer forgets one specific step. Based on this chapter's own comparison table, what will actually happen the next time a new session starts, and why?
📄 View solutionChapter 1 Quick Reference
- Claude's memory is a convenience layer — genuinely useful, but not guaranteed to persist across sessions or environments
- This project's own conventions live as plain markdown files under
rules/— durable, on disk, version-controlled - The old system relied on a manual recovery rule, R1, that had to be remembered and pasted at the start of every session
- The current system uses @rules/<filename> include lines in
CLAUDE.md, loaded automatically every session with no prompt needed - This project's own
CLAUDE.mdcontains a real, dated note explicitly marking R1 as superseded — the system documenting its own evolution - A brand-new rules file only takes effect once it's actually added to the @rules/ include list — covered fully in Chapter 10
- Rules files handle project-wide, always-true conventions; memory (Chapter 8) handles conversational, more transient facts