17 — Language of code, and guards that keep rules alive
Commandments I and III applied to names: a rule that lives only in someone’s head is not a rule, and a rule without a test is a wish.
Two languages, split by reader
| Layer | Language |
|---|---|
| Code — identifiers (modules, classes, functions, variables, Fixture — Prepared data or state a test runs against (e.g. a small database with a few records). A test is only repeatable if it always starts from the same point. more in the glossary →, test names), code file names, DB tables and columns, CLI (command line) — Using a program by typing commands in a terminal instead of clicking. Commands can be saved, repeated and automated — which is why the assistant mostly works this way. more in the glossary → flags, config and API — An agreed way for two programs to talk to each other — one asks, the other answers in a set format. Through an API your app connects to outside services (payments, maps, AI). Treat an API key like a password. more in the glossary → keys, enum/state values, log keys, Commit — A saved, labelled point in the project’s history — a confirmation of a specific batch of changes. Small, described commits make a history you can return to any working state from. more in the glossary → messages | English, always |
| Prose — docs, plans, AI_README — A map file in every code directory: what’s here, what it’s for and what to watch out for — written for search. The assistant finds the right file with one search instead of reading the whole directory. more in the glossary →, comments, docstrings, user-facing text | the project’s language, declared once in CLAUDE.md |
# CLAUDE.md
Code: English (identifiers, tests, DB, CLI, keys). Prose: Polish (docs, comments, docstrings, UI).
Rules
- English code is the ecosystem’s language — tooling, autocomplete, errors and the next engineer all speak it; a native-language identifier is transliterated three different ways.
- Tests are code.
test_<subject>_<condition>_<expected>in English; the why (the incident, the date, the cost) goes into the docstring, in the prose language. - No mixed identifiers (
test_cost_NIE_ISTNIEJE_in_window) — unreadable and ungreppable. - Names a tool prints stay English inside prose — a command, flag, status, file or tag (
commit,--dry-run,migrate.py,deploy-*): that is what you grep for. The everyday word for the activity may be in the prose language (“wdrożenie” for deploying). - A rule without a Guard — A test that enforces a project rule (e.g. “every module is in the AI_README”) and stops the commit when it’s broken. A rule without a guard is only a wish — a long session will break it in good faith. more in the glossary → is a wish. One session shipped 95 of 98 commits without touching the Index (database) — A lookup in the database that makes searching instant instead of scanning everything in order. The first move for slow queries — like an index at the back of a book instead of reading 400 pages. more in the glossary → it was told to update. Rules that must survive a long session are enforced by the test suite.
The two guards (ready-made in guards/)
Copy them into the project’s tests/ as test_ai_readme.py and test_code_language.py, adjust the
directory lists, run them, commit the Baseline — A recorded “as of today” state — a measurement or a count of violations — later results are compared against. Without a reference point you can’t see whether things got better or worse — and in a ratchet it lets numbers only fall. more in the glossary → — in the first commit (→ 07).
They are pytest reference implementations: a Python — A popular, readable programming language — The Craft’s default for scripts, data and the back end. A proven default: lots of ready tools and libraries, easy to drive with AI. more in the glossary → project copies them; a Go, Rust, Kotlin or TypeScript
project ports the same spec to its own test runner (the index guard needs only file globs; the language guard
needs that language’s identifier parser or linter). The rule is the spec, not the Python file.
guards/ai_readme_guard.py— every directory with code has anAI_README.md; every module is named in it; a 20 kB ceiling (past it the index stops being an index — split the directory, not the file); the list of guarded directories guards itself. It cannot tell whether a description is current — that stays the writer’s duty.guards/code_language_guard.py— flags identifiers that look like the prose language (stop-list of function words + letter shape); a Ratchet — A way to bring a rule into old code: today’s state is frozen, and the number of violations can only fall. Nobody has to fix everything at once, but nobody adds new violations. more in the glossary → with a per-file baseline.
The ratchet — introducing any rule into an old codebase
- Freeze today’s count per file in a committed baseline (empty on a new project).
- New files must be clean from the day the rule is written.
- Counts may only fall; when one falls, lower the baseline on command (
--write-baseline), never silently. - Raising a baseline by hand is weakening the guard — the same sin as skipping a test.
- Exceptions are dated, capped at today’s size, and tied to the backlog item that removes them.
Vendoring into an existing project: run the code-language guard once, commit the baseline as it is, and put “rename foreign identifiers — N left” into the backlog with the number.
Anti-patterns
- 🚫 “Test names don’t count as code.”
- 🚫 Mixed-language identifiers.
- 🚫 Translating a name the tool prints (
--dry-runwritten as “próba”). - 🚫 A rule in
CLAUDE.mdwith no test behind it. - 🚫 Raising the baseline to make the suite green.
- 🚫 An
AI_READMEpast the ceiling “because everything here matters”.