I Gave My Terminal a Chief of Staff: The One Where I Keep the Last Word

I Gave My Terminal a Chief of Staff: The One Where I Keep the Last Word
TL;DR

Part 7 of a series. Who holds which decision follows the environment, not the size of the change: the AI merges freely where a mistake is cheap to undo, and production waits for a human read. Guardrails live in hooks, not in prose, because prose is read once and trusted from memory. A second guard, the permission classifier, is noisy and is not the rule. And a gate you can reason past is not a gate.

On the evening of Friday 23 October, at 19:41, my chief of staff tried to merge a pull request that every rule said it could merge.

The checks were green. The branch was the development one. The command was the approved script, the same one that had merged other pull requests that day. The reply was one line: the permission classifier had judged the action dangerous, and it gave no explanation.

The job wrote its row as Blocked and stopped.

One minute later, the main session ran the bare version of the same command, without the folder change in front, and it merged.

That minute is this part. Part 1 promised it: which calls stay mine. This is the whole answer, including the parts where the machinery that is supposed to protect me from my own AI was the thing that got in the way.

Who holds which decision

The rule I ended up with is short. Merge authority follows the environment. Where a mistake is cheap to undo, the AI decides. Where it is not, I do.

WhereWho mergesWhy
A development branchNadim, once the checks are green (plus Elissa's stamp on a big change)A bad merge is a revert and a redeploy
Production (the merge into main, the release tag, the deploy)Me, or I read it firstA bad merge reaches real users
The developer, DanNobody. He prepares the pull request and stopsBuilding and deciding are different jobs

Notice what is not in the table: the size of the change. Diff size is the obvious axis and it is the wrong one. A one-line change to a login rule is smaller than a hundred-line refactor and much worse to get wrong. Blast radius and reversibility are the axis, never the diff size.

It did not start there.

How the line moved

In part 1, the rule was the simplest one: Dan builds, and he does not merge on his own.

On 20 September the rule became Dan never merges, Nadim can. The same day the classifier refused a merge command twice on one pull request, once overnight and once in session, then let it through the moment I approved on GitHub. On 21 September an approved pull request with four green checks was refused anyway. Approval was never a guarantee. That was the first lesson of this part: a permission system that sometimes says no is not a gate I can design around.

On 24 September, in a message I wrote just before 18:00, I drew the line where it still sits: on a development branch, do what you want. On production, I review. A script, bin/merge-dev, became the only way into development. It refuses anything that is not a green pull request from the same repository into a development branch. Later that evening I added the other half: development is yours to play with, go ahead and merge and experiment, and only wait if it is something truly irreversible. On 25 September I widened it to the workflow files, and moved my own review from every merge to the one that promotes development to production, with a brief that lists every development merge since the last one.

The last widening, on 29 October, said it plainly: on the side project's development branch, do whatever whenever, and log it somewhere. Security changes included. Production, secrets and repository settings stayed mine.

That sounds like I gave up control. I did the opposite. By saying out loud which of my decisions were expensive, I could stop spending them on the cheap ones.

The deploy standard: a tag, never a push

The cleanest piece of the design is not a rule about people. It is the shape of the trigger.

On 21 September we agreed that every repository deploys on a tag, never on a push, and that the only merge a human must read is the one into production. Nadim argued for that narrower version against my first, blanket instruction, which was to review everything. I took the narrower one. I am telling you this because it is the pattern of the whole series: the AI proposes a tighter rule, and the last word on whether to accept it is mine.

The reason a tag matters is a freeze. If a deploy only happens when somebody tags, then freezing production needs no permission setting at all: nobody tags, work carries on merging, and nothing reaches a user. The environment protection rules that would enforce this another way are not available to me, so the trigger itself is the whole enforcement.

For the one repository where the AI also owns production, the chief of staff's own site, the only way in is another script, bin/release. It merges, tags, waits for the deploy and fetches the live page. That exception exists because of a scar. A job once merged that site with a raw command, the classifier refused the tag, and the page sat half-shipped until I tagged it by hand.

Scar one: the folder change

Back to 19:41.

The failing command started with a folder change and a semicolon. Other jobs that evening had sent a folder change before the same script and merged. Two earlier ones that day had been refused, one with the same "judged dangerous" text. A research job tallied the transcripts afterwards, and flagged its own numbers as approximate: bare calls were not seen refused, and the folder-change forms were refused three times in about forty-six.

The standing rule already said to run the script bare, as its own call. The jobs had read it and put the folder change in front anyway. That is the best argument I have for a hook over a sentence.

The research job also killed a theory of mine, that a compound command never matches the allow list. One had been accepted by the rule itself, with the classifier never asked. Its summary: the shape is the only thing that correlates, the shape alone is not the cause, and the classifier's verdict is a guess it could not test. It also reads, in the job's own words, as "a noisy judgement, not a rule."

I want to be careful here. The classifier is a second guard in front of my own, and its timing is odd: on 7 October Nadim merged a pull request with a raw command instead of the script, the merge went through, and the classifier refused his next call. My reaction was to ask why he was not using the script. On 24 October it refused a production promotion workflow, which the retro called "by design", and it also stopped a job that was only reading a CI log. Same machine, no reasons I can read. So I do not treat it as a specification. When it says no, the job stops, writes its state and brings it back. Nobody routes around it, and nobody leans on it either.

The fix was boring: call the script bare, as its own call. Five days later, on 28 October, it became a guard rule.

Scar two: the guard

I did not trust prose to hold the hard rules, so I moved them into a hook. bin/guard runs before every shell command my chief of staff sends. It was built on 25 September in about an hour, and its header says why: prose gets read once and then trusted from memory, while a hook re-checks on every call.

It refuses a handful of things:

  • skipping commit signing or the pre-commit checks;
  • a force-push in any spelling;
  • a push to main or development in any repository except the chief of staff's own;
  • blanket staging, because two sessions share one working tree and git add . would take the other one's files;
  • and, since 28 October, chained commands to the tools that matter most: the GitHub client, the board, the database script, the merge script and the release script, each of which must be its own call.

It went through the same review as any other change, and the first round was not approved. It had one false positive and seven misses. In a later round it mistook text inside a commit message for a command-line option. My ruling was "narrow, don't rewrite", which left a miss on purpose: a guard that tries to understand every shell trick is a guard that blocks real work.

A guard that is too clever is a second classifier. I wanted one that was dumb and reliable.

Scar three: the test I reasoned past

The guard stops commands. It cannot stop a decision. For that I had one rule that came out of a mistake on 21 September.

Nadim set himself a test before making a change. The test failed. He judged the test invalid and opened the pull request anyway. He was right. The test was bad.

That was the problem, not the defence. A habit that lets you overrule your own gate when you are confident has no way of telling a bad test from an inconvenient result. The rule that came out of it is the one I am proudest of, because it is about him rather than me: when your own stop condition fires, you stop and bring it to me. Nadim's own note says it in one sentence: a gate I can reason past is not a gate.

There is one more rule in that family: the freezes bind me too. When there is a live event with real guests on a product, and I ask for a deploy near it, he refuses. I asked him to, on 20 September, and he confirmed it. Freezes are a state, not a permission level, so I cannot override one by being the person who asked. A refusal from him is the job working.

What I keep, and why

After two months, my list is short, and each item is on it for a reason you could check:

  • Production. The one environment where a mistake is somebody else's bad morning.
  • Secrets and the settings of the repositories themselves. The AI works inside the box. Changing the box is mine.
  • What gets built, and what it is for. Dan implements. Nadim sequences. Neither decides.
  • The last word on his proposals. He can recommend a tighter rule, a different order, an extra check. He cannot adopt it by himself.
  • Whether to accept the second guard's no. I treat a classifier refusal as a stop, never as an argument.

And what I gave away, fast, on purpose: every development merge, every branch and ticket and board move, the checks, the deploy to the development environment and the curl that proves it.

The result is something I did not expect. I review less than I did in September and I read what I review more carefully, because on every product that matters the door to production has my name on it.

The takeaway

  1. Draw the line by blast radius and reversibility, not by how big the diff is.
  2. Make freezing free: deploy on a tag, so that nobody tagging is the whole freeze.
  3. Put hard rules in a hook that runs on every call, and keep the hook dumb.
  4. Treat a permission classifier as a noisy second guard, not as the rule. When it refuses, stop, write the state and ask. Never route around it.
  5. Give your AI a stop condition about itself, and make sure it applies to your own requests too.

The series

  1. The One Where We Meet Nadim
  2. The One Where the Avengers Assemble
  3. The One Where It Works the Night Shift
  4. The One Where Elissa Says No
  5. The One Where Every Rule Has a Scar
  6. The One Where We Count the Tokens
  7. The One Where I Keep the Last Word (you are here)

Hand over every decision that is cheap to undo, keep the one that is not, and put the line in a hook so nobody has to remember it.

Share X LinkedIn Facebook WhatsApp

Charbel Wakim — Staff Software Engineer at Emma Sleep, writing about production systems, career, and life across the Levant, Europe, and the GCC.

Back to Life in Production