Skip to content
Profile
E. Burgos
November 19, 2026By Esteban Burgos6 min read

Coding agents with limits: what a hook, a worktree and a pull on the wrong branch taught me

#Agentes de IA#Claude Code#SDD#Worktrees#Hooks

Letting a coding agent write into a real repo gives you a bit of vertigo, and that is a healthy feeling. As of November 2026, working this way every day, my conclusion is that it is not about trusting the agent more or less: it is about deciding where the limits are and having something enforce them that does not depend on the model's good will. Here I describe the ones I use, the incidents that taught me each one, and what I still have to figure out.

Permissions: what the agent does alone and what it does not

I work with Claude Code in automatic mode, with a permission classifier that reviews each sensitive action before it runs. At first it felt like a brake; later I understood it is a second pair of eyes that never gets tired.

Two cases where it blocked me and was right. First: the agent wanted to read production credentials. Second: it wanted to start a local server to pull data out of a page. In neither case was the agent doing anything malicious; it was trying to solve the task by the shortest path. But the shortest path is not always one I want it to walk without me looking.

A process rule came out of that, written down in the repo's lessons: for operations involving secrets or email, the agent prepares the command, I run it, and then the agent verifies the result with read-only tools. The classifier blocks reading the .env file and calling external APIs from the terminal, so instead of fighting it I redesigned the flow so that part is mine. It is a little slower, but the boundary is clear: the agent reasons and prepares, the person touches what is sensitive.

Hooks: the limits that are not negotiable

A permission can be granted or denied depending on context. A hook is not negotiable. This repo has one that blocks git push --force even if the agent asks for it, even if it asks with good arguments, and even if I am distracted. What matters is not only that it prevents a common mistake, but that it turns a rule into a fact: nobody has to remember anything.

There is another hook, of a different kind, that runs in every session. The project follows Spec-Driven Development, and a rule I call "rule zero" requires that, before any action in a new task, the agent states which model tier and effort level fits. A SessionStart hook reinjects it at the start of every session. Agents forget long instructions as context grows; a hook that puts them back at the top solves that without relying on the model's memory. It is part of SDD Harness, the kit I maintain: the rule-zero hook arrived in version 0.16.1.

The same logic applies to gates. The SPEC GATE says no code gets written without a registered spec and an open cycle. As a checklist in a document, a model can rationalize skipping it. As a command, it cannot: pnpm sdd:gate returns APPROVED or BLOCKED with an exit code, leaving no room for interpretation. The kit also ships an optional Claude Code mod, sdd-mod, which applies that gate directly to code edits: if the agent tries to edit without an open cycle, the edit comes back rejected with a message explaining what is missing. It ships turned off by default, and the repo rule is that the agent never turns it on or off by itself: that decision is mine.

When an edit comes back rejected, the instruction to the agent is explicit: do not retry it or work around the block with shell commands. If a limit can be bypassed with another tool, it was never a limit.

Worktrees and parallel sessions

So that several agents can work at once without stepping on each other, subagents implement in isolated git worktrees. Each one works on its own copy, and I integrate into main after reviewing the diff. That human review is the last limit in the chain and I do not plan to delegate it.

Worktrees have their traps. In a fresh one, pnpm install does not generate the Prisma client and the type errors look like regressions from the new code; so I run pnpm --filter next-cv exec prisma generate before typecheck and tests.

The other trap is more serious, and it was a real incident. Several sessions shared the same checkout. A pull landed on another session's branch, and I fixed it with a cherry-pick and by restoring the branch. Nothing was lost, but it was a good scare. The rule that stuck: verify the branch before every pull, commit or push. It sounds obvious, but with parallel agents it stops being obvious, because the branch you are on may not be the one you left.

For that problem, the kit added parallel sessions in version 0.19.0: each session is bound to its cycle or fix with pnpm sdd:use, and with the mod active, the first edit to a file reserves it for that session. If another session needs it, it leaves a request in its inbox, and whoever no longer needs the file releases it with pnpm sdd:release. It does not replace worktrees; it complements them, because worktrees isolate files on disk and reservations coordinate intentions.

The limits that show up by reading the log

There is a group of limits that are not technical but habits, and they come from concrete incidents. One: a production build marked completed does not prove the app starts. I had an app down for twelve days with a green deploy. Since then I close every deploy with a real GET to production and a read of the runtime log. Another: the CI on main was red for a week without anyone noticing, so I check it when I open each session. And before opening a PR, every change is verified with pnpm ci:local, so the remote CI is a confirmation and not a surprise.

None is sophisticated: all rely on evidence, not trust (an exit code, a log, a diff). An agent can tell me with complete confidence that everything went fine; my job is to make the system show me whether that is true.

What I take away

  • Permissions are for what is sensitive, and the best answer to a block is to redesign the flow, not to dodge it: the agent prepares, I run whatever touches secrets.
  • A hook is worth more than an instruction in a document, because it holds even if nobody remembers.
  • A gate as a command (APPROVED or BLOCKED) cannot be rationalized; a checklist can.
  • With parallel agents, isolating files with worktrees is not enough: you have to verify the branch before every operation and coordinate who touches what.
  • Reviewing the diff before integrating into main is still my job.

I keep tuning several of these limits, and some will surely fail in ways I have not seen yet. If you work with coding agents in real repos and have your own controls or incidents, I would love to exchange ideas on LinkedIn.

Written by Esteban Burgos

Comments

Be the first to comment.