Intent First: Confidence Gates and CI Guardrails for an Agent That Merges Alone

What I changed on a real project so Claude Code could ship on its own: guardrails in the CI/CD chain, an 80% confidence gate on the initial intent, a cheap interview before any expensive brainstorming, and what Anthropic says a good prompt contains.

Three days ago I wrote about Anthropic’s AI-native SDLC: where the bottleneck moves once an agent writes most of the code. That post was the map. This one is a single trip on it: what I set up so Claude Code could ship on its own, and the one place where I refused to let it guess: the intent.

The project and what I wanted from it

The project is a personal one I work on, and a fairly complex one: a microservice architecture running on a Kubernetes cluster, five separate Git repositories, and event-driven communication between some of the components. The experience below comes from one of those repositories. It is built by a small team of Claude Code agents: a lead agent talks to me, and specialists each own their own files and concerns, including one for CI/CD and one that curates the AI context itself.

What I wanted fits in one sentence: I hand over a request, and the next thing I see is either a merged pull request with every check green, or one precise question. Not a stream of “shall I continue?”, not a pull request waiting three days for my click.

The pipeline at a glance

Every run starts from a trigger: a command, a fix, a new feature. It can come from me, from a ticket in a tracker such as Jira, or from the next item of a backlog. Whatever the source, it lands on one hub, the lead agent. The lead does not write the code. It checks the intent, routes the work to the specialist that owns the files, and closes the request.

The pipeline at a glance: a trigger (a human, a ticket from a tracker such as Jira, or a backlog item) reaches the hub, the lead agent; the request goes through the intent gate, delivery by specialists and the CI/CD guardrails before the agent merges and deploys alone; two arrows go back to the human: a question, or a blocked reportTRIGGERSa humana ticket (Jira)a backlog itemcommands, fixes, new featuresHubthe lead agent:routes, asks, closesIntent gateread + confidence,below 80%: challengeDeliveryspecialists, branch,pull requestCI/CD guardrailsevery check greenon the head commitMerge + deployalone, thencheck the runnext taskone question back to the humanblocked after 3 red cycleseverything on the solid path runs without a human
The pipeline at a glance: from a trigger to a merged, deployed change, with two ways back to the human

Only two arrows come back to me. One is a question: the intent is unclear, or a task reached a real choice of direction. The other is a report: a check stayed red and the task stopped. Everything on the solid path runs alone. The rest of this post walks that path step by step, from the cheapest decision to the most detailed machinery.

Step 1: the intent gate

The first place autonomy breaks is the start. Most of my bad runs were not bad code. They were good code for a request I had not actually made: the agent had silently filled a gap in my prompt with the most conventional answer.

The fix is a skill called interview-me, vendored from Addy Osmani’s agent-skills. The lead runs it before it plans, delegates or edits anything. Step one: write your best read of the request in one sentence, with an honest confidence number. As the skill puts it, “The number forces honesty.”

My rule on top is a threshold. At 80% or more, the agent states its one-line read and goes. A precise ask costs one line. Below 80%, it stops executing and starts challenging me, in a strict form:

  • One question per message, each with a guess. The format is Q: plus GUESS:, its best answer and why. The guess becomes the recommended option, so I usually answer with one click. Reacting to a wrong guess is much faster than writing an answer from nothing.
  • A six-line restatement: Outcome, User, Why now, Success, Constraint, Out of scope. The skill is firm that “Including ‘Out of scope’ is non-negotiable.”
  • An explicit yes. “Sounds good” is not a yes, and neither is “whatever you think”.

The vendored skill itself aims for about 95% before it stops interviewing. I keep both numbers: 80% decides whether the interview starts, and the skill’s test, “can I predict the user’s reaction to the next three questions?”, decides when it ends.

The intent gate: the agent scores its read of the prompt; at 80% or more it goes, below 80% it challenges the user one question at a time until a six-line restated intent is confirmed with an explicit yes; brainstorming only runs when the work needs a designPromptwhat the person typedHypothesis + confidenceone sentence: "you want X"and an honest score, e.g. 62%confidence ≥ 80% ?yesGoone-line read,start the workmost precise asksstop here: no interview,no restateno, below 80%Challenge loopone question per messageQ: + GUESS: (recommended)then re-scoreRestated intentOutcomewhat changesUserwho benefitsWhy nowwhat triggered itSuccesshow we check itConstraintthe binding limitOut of scopewhat we will not dointent.mdsaved to docs/intent/only when askedexplicit yes?refine"sounds good"is not a yesdesign needed?yesBrainstormapproaches, design doc, approvalcostly: new module, contract, risknoDeliver
The intent gate: below 80% the agent challenges, one question at a time, until a six-line intent gets an explicit yes

That six-line block is my intent.md. The skill offers to save it to docs/intent/<topic>.md, which I do only when the work spans sessions. Most of the time it travels another way: every brief the lead sends to a specialist opens with it. Specialists never interview me; when something is unclear they change nothing and hand back their questions as Q: plus GUESS:, and the lead asks me one per message.

It is the artifact Anthropic’s AI-native SDLC playbook puts at the start of its loop: intent “captured once, in the originator’s own words, as a version-controlled artifact the next stage can act on.” The confidence gate just decides when that needs a conversation and when one line will do.

What the interview aims for: a prompt Anthropic would recognize

The interview’s real job is to turn my prompt into one that follows Anthropic’s own advice. That advice is short:

  • Clear and direct. “Think of Claude as a brilliant but new employee who lacks context on your norms and workflows. The more precisely you explain what you want, the better the result.” (Prompting best practices)
  • Context and motivation. “Providing context or motivation behind your instructions […] can give Claude more information about your goals and help it deliver more targeted responses.”
  • Specific scope. “Claude can infer intent, but it can’t read your mind. Reference specific files, mention constraints, and point to example patterns.” (Claude Code best practices)
  • A way to verify. “Give Claude a check it can run: tests, a build, a screenshot to compare.”
  • Out of scope, stated. “The most useful specs are self-contained: they name the files and interfaces involved, state what is out of scope, and end with an end-to-end verification step that proves the feature works.”
  • Examples, “one of the most reliable ways to steer Claude’s output format, tone, and structure.”
  • Only what matters: “the smallest possible set of high-signal tokens that maximize the likelihood of some desired outcome” (Effective context engineering for AI agents).

The best practices even suggest the move I automated: “For larger features, have Claude interview you first.” Side by side, the six lines are that checklist:

Restated intent What Anthropic asks of a prompt
Outcome The goal, stated clearly and directly
User, Why now Context and motivation
Success A check Claude can run
Constraint Constraints, files, patterns to follow
Out of scope What not to do, stated explicitly

The interview does not replace a good prompt. It is what happens when mine is not one.

Step 2: brainstorm only when the work needs a design

The repository also uses Superpowers, and its superpowers:brainstorming skill is genuinely good: one question at a time, two or three real alternatives with a recommendation, the design played back in chunks, a design document, and “Nothing gets built until your human partner approves the design doc.”

In my experience it is also the most expensive thing an agent can do before writing a line of code: many turns, many tokens, and a lot of my time reading design for work that did not need any. The skill’s own description says “You MUST use this before any creative work”. My CLAUDE.md overrides that on purpose: brainstorming is not the default.

The order is fixed. The interview settles what and why; brainstorming designs how, and only when the request needs it: a new feature or module, a contract or cross-repository change, several valid approaches, a risky or hard-to-reverse impact. A precise fix or a bounded change gets one line saying the brainstorm is skipped, and the work.

Cost ladder of the three ways to start a task: direct execution costs one line, an interview costs a few short questions, brainstorming costs many turns and a design document; climb only as far as the ambiguity and design risk requireCost to start a task (illustrative, not measured)climb a step only when the one below cannot settle the askDirectone-line read,then workconfidence ≥ 80%,bounded askInterviewa few questions,each with a guessconfidence < 80%:settle what and whyBrainstormmany turns,design doc,approvalnew module, contract,several approachesambiguity and design risk →
The cost ladder: start at the bottom, climb only when the step below cannot settle the ask

Anthropic points the same way: “Plan mode is useful, but also adds overhead,” and “If you could describe the diff in one sentence, skip the plan.” “Building effective agents” (December 19, 2024) recommends “finding the simplest solution possible, and only increasing complexity when needed.”

Step 3: guardrails that let the agent merge alone

The end of the chain rests on one rule in CLAUDE.md: once a task’s direction is settled, the lead delivers it as one pull request and, “when every guardrail is green, merge the pull request without asking”. Then it checks the deploy the merge starts, and takes the next task.

That rule is only safe because “green” means something:

  • Locally, before every push: lint, typecheck, the tests the change touches, and a script that validates the AI configuration.
  • In CI, on self-hosted runners: a job that cancels the run if the commit is already in main, one that detects whether code changed, a commit-message check with cocogitto, and a test job with lint, typecheck and a mandatory test subset kept under one minute. The full suite, about ten minutes, runs by hand.
  • At merge time: “two branches green on their own can still break each other”, so when main has moved the agent merges it in, pushes and waits for the new run. A red production deploy is fixed at once, in a new pull request.
  • A test floor, 6,651 tests in 628 files today, that no pull request may lower unless the tests go with deleted code.

Two limits keep it honest. At most three fix-and-push cycles per pull request; after the third, the task stops and reports what fails. “Building effective agents” says it plainly: “it’s also common to include stopping conditions (such as a maximum number of iterations) to maintain control.” And autonomy covers delivery, never direction: an architecture, a UX choice, the scope, a contract, a new dependency all come back to me, while unrelated tasks keep going. Some merges always wait for a human too: a check red or missing, an open review finding, a backend change not yet deployed, a manual step, anything irreversible.

Some guardrails sit on the agent’s own context. A PostToolUse hook runs after every edit and pushes back (exit code 2, which sends the reason to Claude so it corrects itself) when an edit writes dates, PR numbers or “next steps” into CLAUDE.md or an agent file. Product rules are backed by tests, not prose: every deletion needs the object’s reference typed into one shared dialog, and each new delete feature ships with a test proving it.

This is Anthropic’s guidance applied to the merge button. The Claude Code best practices: “Give Claude a check it can run […] It’s the difference between a session you watch and one you walk away from.” And: “Unlike CLAUDE.md instructions which are advisory, hooks are deterministic and guarantee the action happens.” The playbook says the same at the governance level: “A skill is an advisory control while a hook is the deterministic layer behind it.”

Here is the whole loop, with every check on the way.

The detailed delivery and guardrails loop: branch, conventional commits, local guardrails and a ready pull request; CI runs four jobs on self-hosted runners; when every check is green on the head commit the agent updates the branch with main if needed, merges with a merge commit and checks the production deploy, then takes the next task; a red check gets at most three fix cycles before the task is reported blocked; hooks and tests guard the context and the product rules all along; directions and some merges always go back to the human1 · DELIVERBranchfresh from main,namedtype/scope-subjectCommitsconventional,lowercase,attribution footerLocal guardrailslint, typecheck,tests touched,AI config checkPull requestpushed, openedready for review,never a draft2 · CHECK, MERGE, MOVE ONCI on every push1 skip if already merged2 detect code changes3 commit messages4 lint, typecheck,mandatory tests < 1 minself-hosted runners only,at most two jobs at once;full suite (~10 min): manualevery checkgreen on head?yesUp to date?main moved: mergemain, push, waitfor the new runMerge alonemerge commit,branch deletedProduction deploycheck the run;red: fix in a new PRNext taskredDiagnose, fix, pushcycle 1, 2 or 3rerunstill red after 3Blockedreport what failsand what was tried3 · ALWAYS ONcontext hook (exit 2)test floor: never lowerdeletion: typed referenceflags history in CLAUDE.mdunless code is deletedproved by a test4 · NEVER ALONEDirections: stop and askapproach or architecture, UX,scope, contract or data model,new dependency, product rule:one question, 2 to 4 options;other tasks keep goingMerges that wait for a humana check red, missing or not run,an open review finding, a backendchange not yet deployed, a manualstep, an irreversible effect
The detailed loop: what runs at each step, when the agent merges alone, and what always comes back to the human

Practices I would keep

  1. Make “done” machine-checkable first. Without lint, types and tests, autonomy just postpones the review.
  2. Keep the gating check fast. A one-minute subset runs on every push; a ten-minute suite gets skipped.
  3. Let CI decide the merge, not the model, and cap the retries at three.
  4. Separate delivery from direction. Write down which choices the agent may settle and which come back to you.
  5. Gate the intent with a number. Imperfect, but visible, and a visible number can be challenged.
  6. Reserve heavy design for heavy work. Interview first; brainstorm only when there are several valid designs.
  7. Put non-negotiables in hooks and tests, not prose, and guard the context files too.

What this does not solve

A confidence number is self-reported, and a model can be confidently wrong, so 80% is a trigger for a conversation, not a measure of truth. Green CI only proves what the tests check. That is why direction always comes back to me. But the trade has been worth it: my time now goes to a few questions when the intent is unclear, a decision at a real fork, and very little in between.

References

Share: X (Twitter) Facebook LinkedIn