This article was created with the help of AI. The incidents and the config lines come from my own server.
I run Claude Code on a small server that also hosts a live site. Six lines in my setup are there because something broke first. Four of them sit in files Claude Code reads, one in the server's config and one in a crontab.
1. Keep session transcripts longer than 30 days
On October 11 I counted the session transcripts on this server. My first prompt here is dated May 26, and the oldest transcript on disk was from September 11. Claude Code deletes session transcripts after 30 days, and nothing tells you when it does.
{
"cleanupPeriodDays": 365
}
The key goes into ~/.claude/settings.json. It only works forward, so what was deleted stays deleted.
2. Two builds at a time
On September 25 I let six agents work in parallel. Each one installed dependencies, ran the typecheck and the tests and built the app, all of it next to the live services. The server ran out of memory and froze until a hard reboot. None of the agents did anything wrong on its own.
The rule went into CLAUDE.md, the project notes Claude reads at the start of every session:
At most two build-heavy processes at a time [...] When fanning work out to subagents,
tell them to typecheck and test only their package and not to run `next build`;
run full builds one at a time yourself.
A month later Claude laid out a seven-step plan for me and offered two ways to run it: by itself, or with a separate agent for every step. It recommended the first. One of its reasons was that the server allows two heavy processes at a time.
A line in CLAUDE.md works only in a session that has read it. On November 24 a reader on Reddit suggested putting a hook behind the rule, and I added one the same day. Build-heavy commands now go through two slots, and a third one waits for a free slot.
If you write a hook that has to stop a command, check how it exits. Only exit code 2 blocks. With the usual exit 1 Claude Code reports an error and runs the command anyway. Since version 2.1.295 you can also set "onFailure": "block", so a hook that crashes or times out stops the command too.
3. Kill the hungriest process early
Three weeks later the server froze again. On October 16 a nightly job started a Docker build while three Claude Code sessions were open. The system log simply stops at that minute, with no out-of-memory kill in it. The machine was thrashing while swap was still free.
That day I installed earlyoom. This is /etc/default/earlyoom:
EARLYOOM_ARGS="-r 3600 -m 5 -s 100 --avoid ^(postgres|dockerd|containerd|containerd-shim|systemd|sshd|journald)$ --prefer ^(chrome|chromium|tsc|next-server)$"
-s 100 makes it act on low RAM alone, without waiting for swap to fill up. Builds and the browser go first. The database and Docker are the last it would pick.
4. Back up ~/.claude and keep nothing in /tmp
The second reboot also wiped /tmp, and the running session kept its scratch folder there: watchdog scripts, a test harness, logs. Two days later a backup went into the crontab:
15 3 */2 * * /bin/bash ~/.claude/.../blackbox-backup.sh >> ~/.claude/.../blackbox.log 2>&1
Every two days it copies ~/.claude off the server together with the database. The memory notes, the settings and the transcripts are in there. .credentials.json and the plugin cache are left out.
5. A rename ships to every app in one push
On October 1 a push failed its checks, so nothing was deployed. The next push compared itself only with the one before it and rebuilt the API, but not the site. The old site read a field the new API had renamed and dropped every post from the sitemaps until I ran a full deploy by hand.
CI now compares each push with the last deploy that succeeded. CLAUDE.md got a line of its own:
When a contract field is renamed, update api, web and site in the same push:
a half-shipped rename once emptied the sitemaps.
6. Never pipe a file back into itself
In September the config of a self-hosted search service was edited with a one-liner of this kind:
python edit.py settings.yml | sudo tee settings.yml
tee emptied the file before Python had read it. The secret key was gone, and the service died with "Invalid settings.yml". The line in CLAUDE.md is blunt:
Never rewrite `settings.yml` with `python ... | sudo tee settings.yml` while reading the same file.
The server has been up since that second reboot on October 16.
The same newsroom publishes AI news in English as Promtime.
Top comments (4)
For the CLAUDE.md rule requiring api, web, and site to update together on a contract rename, how do you verify that subagents check every affected package before merging instead of only their own?
I don't make subagents check it. They typecheck and test only their own package, that is the rule from item 2. The cross-package check happens once, for the whole repo. Field names live in one shared types package that all three apps import, so after a rename the typecheck fails in every app that still reads the old name. CI runs it across the whole workspace on every push, and the deploy does not start until it passes. It only catches code typed against that package. A field name written as a plain string would slip through.
Thanks for the detail on keeping subagents scoped to their own package tests while workspace CI enforces the shared types package and noting that untyped plain-string field names can still slip past typechecking, I'm building AI Lint as a pre-flight engineering checklist and doctrine pack so coding agents check cross-package boundaries, callers, and neighbours before a change ships: ai-lint.dosaygo.com/go/forum-20261...
The plain-string field name is the real hole, and no typecheck closes it. It needs a habit: on a contract rename, search the old name as text across api, web and site before the change counts as done. Cheap enough that an agent does it every time once it is on the list it reads first. AI Lint's checklist has the agent check callers and neighbours before a change ships; the apps pack is $49, one-time: ai-lint.dosaygo.com/go/ft2-2026112...