The rule Claude never read
· · Not by Prompt Alone · episode 16 · Czytaj po polsku
Claude Code signed its own commit in Zakupomat. And the PR description too. Meanwhile AGENTS.md said in black and white that there should be no such signatures. So what now, write it a second time, IN CAPS? 😉
First it made sense to check whether Claude had read that file at all. It hadn't. And that was only the beginning.
A link is not an import
We had two files in the repo. AGENTS.md held the rules shared by all agents, CLAUDE.md had a little table with a link to AGENTS.md. Obvious to me - I click the link and read. Except that at the start of a session Claude Code loads CLAUDE.md, and reads AGENTS.md on its own only when there is no CLAUDE.md. Whether it opened the second file depended on whether it happened to feel like looking there.
The worst part was that the rest of the PR looked exemplary. It even had the English Closes next to the issue number, exactly as I wanted. If not for that signature, I'd have assumed the agent knew all the rules. It had simply followed a few of them by accident.
The fix is one line: @AGENTS.md in CLAUDE.md. In Claude Code, such an entry loads the second file together with the first. Claude Code docs on imports
While we were at it, we read the instructions that from now on would land in every session. One of them said the backend had no tests - while CI had been running them for ages, on SQLite and MariaDB. The list of open questions still had "merge the repositories", in an already merged repo. A little longer and I'd have had a perfectly working import of nonsense 😂
Who actually enforces this rule?
That's when I asked myself the question I now ask about every rule. Not "does the agent know it", but "who carries it out if the agent forgets". And it turned out our rules sit on three shelves.
Shelf one - the tool enforces it. I turned off the commit signature with the attribution setting in Claude Code, separately for commits and PR descriptions. Now the agent doesn't have to remember, because there's nothing to remember. Same with production. Claude Code's auto mode won't let a deploy to the server through until I write "deploy" in plain words in the conversation. The rule "deploy only on my command" is also in the file, but it no longer hangs on the file.
Shelf two - CI enforces it. A few weeks earlier I found six issues that were done and released, yet still sat there as open. Some for two weeks. The culprit was our PR template, which suggested the Polish Zamyka # ("Closes #"). Any human knows what it means. GitHub doesn't - it closes an issue only after Closes, Fixes or Resolves. And it doesn't warn you that it didn't understand the Polish word. GitHub docs Today Zamyka #87 in a PR description ends in red CI with a hint on what to fix.
Shelf three - only a sentence in a file enforces it. "Never push to main". Releases to two stores and to the server come from main, so it's probably the most important rule in the whole repo. And nothing on GitHub's side enforces it. Branch protection on a private repo needs a paid plan, and a local git hook doesn't work in agent sessions. I decided consciously that with one repo and one person I won't pay. The rule in AGENTS.md is the only safeguard, and that's written down in a decision, together with the condition that would reverse it - "a real incident".
Today there almost was an incident
Tonight Claude was finishing a small change on the server. One line of data, PR open, CI running. It wrote itself a command: wait for CI, then merge. Except it joined the two steps with a semicolon, not a condition. Meaning: wait for CI... and merge whatever the result.
It noticed by itself, after a moment, stopped it and changed it to "merge only if green". Good thing, because the MariaDB test failed. Twice in a row. The cause wasn't in the code - on the Mac that runs our CI, port forwarding to the database containers had stopped working. Probably since the Mac went down during the day (What?! A Mac went down?! Impossible!!! 😜). But with the first version of the command, the PR would have landed on main with red CI. And GitHub wouldn't have blinked.
This time nothing would have happened. The change was harmless and the red CI was a false alarm. But the rule "main is always green" is guarded here by... the agent's attention. It failed once because of an unread file. Today it almost failed because of a semicolon 😉
A twist I didn't expect
I sit down to write this, I'm writing about the 4 dollars a month I consciously didn't pay... and I look at my GitHub account settings. GitHub Pro. Since this month 😂
How come? Claude, Codex and I burned through all the free GitHub Actions minutes in a third of the month, and I wanted to run something quickly. Later I realised it doesn't change much, and CI moved to the Mac mini. But Pro stays. It's only 4 dollars a month, and branch protection plus the option to run something on GitHub when the Mac mini goes down, or when something needs to run in parallel, are worth more to me.
So for a few weeks I'd been paying for branch protection and not using it. The rule hung on the agent's attention for no reason at all.
That same evening "never push to main" moved from shelf three to shelf one. GitHub now has a rule that accepts changes to main only through a PR and only with green CI. No exceptions, me included, because the agents work on my account. And Claude no longer waits for CI to merge. It marks the PR for auto-merge and GitHub does it itself, only once it's green. The semicolon has nothing left to break 😉
While we were at it, we went through my other repositories. Where we work through PRs, the same rule. Where I push straight to the main branch (my PoCs and other little things), at least a ban on rewriting history and deleting the branch.
How I'd check it in a new repo
First a fresh session, from the directory I actually start work in, and the list of loaded instruction files (in Claude Code: /context all, the "Memory files" list). Not the question "do you know our rules?" - the model will happily summarise a file it only opened after I asked.
Then a list of rules, and one question for each: which shelf? If a setting can enforce it, it goes into the setting. If CI can check it, it goes into CI, and then I open one PR that breaks it on purpose, to see red. And whatever stays on shelf three, I write down separately. Those rules are the fewest, but they decide what happens on the day the agent doesn't read the file. Or puts in a semicolon.
At ANSLAN we help teams prepare their repositories for this kind of work, from instructions for agents to automated checks in CI. How we work at ANSLAN
Zakupomat is free and has no ads.