Eight shell and git mistakes our agents made, and the rule for each
Agents write shell commands fast and confidently, and some of the failures repeat. Here are eight real mistakes from October 2026, what each one broke, and the one-line rule we wrote after it. Copy the rules into your own agent instructions.
π― For Anyone who lets an agent run shell, cron or git commands on a shared machine
- Eight concrete shell and git failure patterns and the rule that prevents each
- How to turn each incident into one checkable line
- Where to keep these rules so that agents actually read them
π Why keep a list of your own mistakes
General advice about shell safety is easy to find and easy to ignore. A rule that names a date, a command and a consequence is read differently. We keep one short list in the file every agent loads at the start, and each entry is a real failure. When a new one happens, one line is added: what broke, and the rule.
π The eight
- A whole crontab replaced. On 12 October 2026 the root crontab was overwritten with three lines and 59 jobs, including backups and database dumps, disappeared. It was noticed a day later. Rule: never rewrite the crontab. Add a new job as its own file under the cron directory, and run a guard that compares the job list.
sshinside a read loop. Inwhile read ... < file,sshreads the rest of the file from standard input. Only one of five writers ran. Rule: read the list into an array first, or callssh -n.- Killing yourself with a pattern.
pkill -fandpgrep -fmatch the command line of your own shell if the pattern appears in it. An agent killed its own shell, and a watcher waited for itself. Rule: kill by process id, and check that the pattern does not appear in the launching line. - An empty list means everything.
git reset HEAD --pathspec-from-file=with an empty file reset the whole shared index. Rule: before any command that takes a list from a file or fromxargs, check that the list is not empty. - Reserved shell names. Assigning to
GROUPS,RANDOM,SECONDS,UIDorHOSTNAMEis silently ignored. Rule: give your own variables a prefix. &&andset -e.cmd && echo okdoes not stop a script whencmdfails underset -e, and in our agent toolset -edid not work at all, because the command is wrapped. A commit went out with ten red tests. Rule: check the exit code explicitly withif ! cmd; then exit 1; fi.- The pipe takes the exit code.
pytest | tail -1 && git commitcommits on red, since the exit code of a pipe belongs to its last command. Rule: run tests without a pipe, or setpipefail. - A command that never ran. A
chmod +xinside a command that was blocked did not execute, and nobody checked. Rule: check the file mode before you commit.
π οΈ Practice: build your own list
- Open the last five incidents caused by an agent or by a script. Write one line each: date, command, consequence.
- For each, write one rule that a script could check. If it cannot be checked, rewrite it until it can.
- Put the list in the file your agents read first, and keep it under thirty lines.
- Add a checker for the rules that can be tested: for example a script that refuses a commit when the staged list is empty or a mode is wrong.
- After every new incident, add one line the same day.
- Once a quarter, delete rules that a tool now enforces.
β Check yourself
- Pick any rule at random. You can name the incident behind it.
- Run a loop with
sshinside it on two hosts. Both hosts are reached. - Make a test fail under a pipe and confirm that the commit is refused.
- An agent that has never seen your system reads the list and avoids at least three of the eight on its first task.
π§ When this does NOT work
- A list nobody loads. If the file is not in the agent's start context, the rules do not exist.
- Rules without a trigger. "Be careful with cron" is not a rule. "Add jobs as files, never edit the crontab" is.
- Too many rules. Past thirty lines the important ones disappear. Remove what a tool already enforces.
- Different shells. Some of these behave differently in other shells. State the shell the rule is about.
- Rules instead of permissions. An agent that must not touch production should not hold production credentials, whatever the list says.
π Evidence
| What we measured | Incidents recorded in our agent rules file between 12 and 14 October 2026 |
| When | Records read on 3 November 2026, 22:06 UTC |
| Artifact | The "mistakes from our own work" section of our agent rules file, in a private repository |
| Limit | Eight cases, one team. It shows the shape of the failures, not their frequency |
β‘οΈ Next
Put recovery steps in place with Recovery after a failed, stuck or uncertain run, and read how to write the instructions agents load in AGENTS.md and rules files.
Sources
- AGENTS.md and rules files: set a coding agentβs scope: where the list lives.
- Recovery after a failed, stuck or uncertain run: recovery steps.
- An AI incident playbook for a small team: what to do when an agent gets it wrong.
- Permissions and data flow: what an agent may touch.
π Article connections
Open the full knowledge graph βPublished article links. Select a node to open its article at the heading.
Article links Β· keyboard / text view
Same topic
- A vector base is a map, not a source: what we learned from retrieval
- When you cannot tell what a model call cost: freeze, then reconcile
- Splitting a big task for a cheap model: the 24,000-byte lesson
- Skills, MCP tools and rules: three ways to give an agent capabilities
- Several agents, one repository: ownership rules from real incidents
- Keep provider keys out of the agent: one gateway, one token per task
Next steps
Related reading
A vector base is a map, not a source: what we learned from retrieval
A vector base finds passages that are close in meaning to your question. It does not know which are true or current. Treat every hit as a pointer: open the file it names, check the hash, and take numbers from the artifact, never from the retrieved paragraph.
AI agents and MCP explainedWhen you cannot tell what a model call cost: freeze, then reconcile
Sometimes a model call times out and you do not know whether the provider charged you. Never record that as zero. Mark it uncertain, stop new paid calls, and let a named person reconcile it with the provider's statement. Refusals before generation are the exception.
AI agents and MCP explainedSplitting a big task for a cheap model: the 24,000-byte lesson
A cheap model does well on one small, well-defined job and badly on a big pile. We cap a task at 24,000 bytes and refuse larger ones before any model is called. Split by unit, one file or one country per task, and check the size before you start.
AI agents and MCP explainedSkills, MCP tools and rules: three ways to give an agent capabilities
Agents get abilities in different ways. A rule constrains what they do, a skill tells them how to do a job, and an MCP tool lets them call a function. Each has its own risk, so declare all three in a register and test that nothing exists unlisted.
π¬ Comments