Coding Agent Workflow: Scaffolding for AI Coding Agents, Step by Step

This guide teaches a complete coding agent workflow in eleven steps. It comes from Carlos Kelkboom, a lead architect who described how he works with coding agents on the Beyond Coding podcast with Patrick Akil. He didn't show slides or code, so we've written up his spoken method step by step. A worked example at the end applies every step to a real agency job. For the short version and the reasoning behind it, see our post on rules for coding agents.

Coding agent workflow: a lead architect's 11 rules for coding agents, Carlos Kelkboom's method from the Beyond Coding podcast. Scaffold first, throw away fast.

Why a coding agent workflow beats prompting harder

Agents are strong at building something in one pass and weak at changing it later. The SlopCodeBench study tested 15 coding agents on 36 problems where they had to keep extending their own code over 196 checkpoints. None solved a problem end to end; the best passed 14.8% of checkpoints, and the code got more tangled in 77% of runs. A good coding agent workflow is built around that fact: put the effort into the first shot, and restart rather than patch.

Why structure beats prompting harder

Here's the reality. I've built, scaled, and sold three companies, generated over $85 million in the last seven years in my own companies. Each of them scaled because the foundation was decided by people before the work was handed out. Agents are the same, as the research and Carlos's own experience below show.

Evidence Source
Best agent passed 14.8% of 196 checkpoints; no end-to-end solves SlopCodeBench, arXiv 2603.24755
Code erosion rose in 77% of runs, verbosity in 75.5% Same
Agent code 2.3x more verbose and 2.0x more eroded than 473 human repositories Same
Without scaffolding, a month or two of brute force kept hitting walls; with it, agents built his compilers "exactly" as needed Carlos Kelkboom

Phase 1: decisions and scaffolding for AI coding agents

Step 1: Decide why you're building

Before anything else, decide what this is. A learning exercise? A quick experiment? Or something you'll ship and maintain? If it's an experiment, don't over-invest: let the agent run, and throw the result away if it fails. If you're going to live with it, the next steps are worth the time.

Step 2: Make the big decisions yourself

Get the spec clear: who it's for and what it must do. Then decide the architecture and how it will run. His examples: will it deploy to a cloud host or run locally, and will data live in object storage, Postgres or SQLite? These are choices he says you shouldn't hand to the agent. Write them down in a short spec file at the top of the project.

Step 3: Scaffold by hand

This is the heart of the method. By hand, he:

  • creates the folders (or projects, or packages) and gives them names;
  • puts a short markdown note in each one explaining what belongs there and what doesn't;
  • sketches a rough diagram of how the parts connect;
  • creates the core files with comments, class names and function signatures;
  • defines the key data shapes exactly (his example: precisely what a "token" holds in a compiler);
  • writes examples of the output he wants.

It takes him 20 minutes to an hour. Without it, he says, agents brute-force a solution and forget how it fits the rest of the app, which leads to duplicated code and giant do-everything files. He admits he scaffolds deeper than most people need to; start with folders, notes and data shapes.

Phase 2: main agent and sub agents

Step 4: Keep the main agent in "open mode"

The first agent he talks to never edits code or changes his machine. Its only jobs are to discuss, ask questions, teach him and learn from him. He made the switch after asking an agent for its opinion on an idea and getting an offer to build it into his project. A talk-only agent stays focused on understanding the request. When the work is clear, it starts sub-agents to do the building.

Step 5: Feed context as a graph of small notes

Agents forget between sessions, and stuffing everything into context makes them worse and more expensive. His fix works like a social network: small markdown notes are the nodes, each with a one-line summary and a pointer to more detail (a file path, a commit or a web link). Search over the notes' headers finds candidates, the agent ranks what fits, checks with him, and only then goes deeper. He has the agent read recent changes (the diff) before the full code, to warm it up. He deliberately keeps this as plain files rather than a database.

Step 6: Start only when it's confident

He uses a small model to score how well the main agent understands the request. Only above 90% does the agent ask permission to start sub-agents.

Git worktrees for AI agents

Step 7: Go big, one shot, in a worktree

Because agents build better in one pass, he gives sub-agents the largest chunk of work he can, sometimes running for hours. Every run happens in a Git worktree: a separate working copy of the repo on its own branch, so nothing touches the main code until he chooses. For important work, he sometimes runs three agents in three worktrees and asks a fourth to compare them and merge only the best parts.

Phase 3: check, restart, harden

Step 8: Check in early and throw away what you don't recognize

He doesn't wait for a twelve-hour run to finish. After an hour or two he pauses, opens the worktree and looks. If the things he expected aren't immediately visible, it goes. "If I don't understand it, I throw it away." His reasoning: if he can't recognize it, it has left the scaffold, and merging it will cause trouble later.

Step 9: Restart with the cause fixed

He closes that agent, opens a fresh context, and tells the talk-only agent what went wrong. Together they find the cause, usually two ideas that clash somewhere in the scaffold or the notes. He fixes that and runs again. In his experience, the second run usually works, occasionally the third.

Step 10: Push toward deterministic

Language models give different answers each time. Whenever a problem repeats, he moves it into something that always behaves the same: a script that does exactly the job, or a firmer scaffold.

Mutation testing AI generated code

Step 11: Review for less code and real tests

Big agent changes are hard to review, so he asks agents to write less code and keep features small. He's wary of unit tests on their own, because they are easy to fake. Mutation testing goes a level deeper: a tool plants small bugs in the code and checks that the tests fail. If tests still pass, they aren't really testing anything. It's slow and heavy to run, so save it for important code. He also suggests checking how much of your original scaffold is still standing, and how each commit moved the work forward.

Worked example: a coding agent workflow for a location page builder

Here's how we'd apply this coding agent workflow to a common agency job: generating 40 service-area pages for a plumbing client from a spreadsheet.

  1. Why: this ships and gets maintained, so we invest.
  2. Decisions: static pages on the client's existing site framework; data from one CSV; each page needs a unique intro, the services offered in that area, and LocalBusiness schema. Written in SPEC.md.
  3. Scaffold (40 minutes): folders data/, templates/, pages/, checks/, each with a README. A type for the page: slug, city, services[], intro, schema. One finished example page written by hand.
  4. Open mode: a planning chat told not to edit files. It asks: which services differ by city? Any cities to exclude? What's the URL pattern?
  5. Context notes: notes/brand-voice.md, notes/client-facts.md, notes/past-mistakes.md (for instance, "don't invent license numbers"), each with a one-line summary.
  6. Gate: the planning chat restates the job; we don't start until it gets the URL pattern, the schema fields and the exclusions right.
  7. Build: two sub-agents each generate all 40 pages in separate worktrees. A third compares them; we keep the better template and the better intros.
  8. Check at 30 minutes: five pages opened. One run invented opening hours; that run is binned.
  9. Restart: the cause was a vague field in the spec ("hours" was optional). Fixed to "omit if blank". The second run is clean.
  10. Deterministic checks: a script validates the schema on every page, flags duplicate intros, and confirms every page links back to the main service page. Our scaffold-check script confirms the folders, files and data type survived the run.
  11. Review: we ask for a smaller template with no unused code, read one full page closely, spot-check ten, and only then merge.

Result: the human time goes into the spec, the scaffold and the checks, not into patching 40 pages one by one.

Common mistakes

  • Letting the agent choose the stack or folder structure.
  • Patching a run you don't understand instead of restarting.
  • Giving the agent everything at once as context instead of small, linked notes.
  • Waiting until the end of a long run to look.
  • Trusting green unit tests without asking what they actually test.

Want us to run this workflow for you?

We use this workflow for client automations and page changes at scale: spec, scaffold, worktrees, early checks and human sign-off. You approve the spec and every release, so there's no risk of agent code shipping unseen. Why now: the sooner the scaffold exists, the cheaper every later change is.

What we do Where
Automations built with this workflow: spec, scaffold, checks, human sign-off AI automation
Template and page changes at scale, built in branches and validated before release Technical SEO

Free tools

One free, MIT-licensed skill for Claude, Codex and Grok comes with this guide: Scaffold Check (records your hand-made scaffold; after an agent run, measures how much of it is still standing and flags new folders, giant files and duplicated functions, then says keep, look closely or throw it away; checks and searches your context notes summary first; and only clears the build once the main agent restates at least 90% of your must-haves). Download the skill (free zip)

FAQ

What is progressive disclosure for AI agents?

Giving an agent small summaries first and letting it pull in more detail only as needed, instead of loading everything at once. Kelkboom does it with linked markdown notes.

How long should scaffolding take?

He spends 20 minutes to an hour. For most projects, folders, a note per folder, data shapes and one example are enough.

Do I need Git worktrees?

You need some way to keep each agent run separate from your main code. Worktrees make it easy to run several attempts side by side and throw away the bad ones.

What if the agent never gets it right?

After two or three restarts, look for clashing instructions in your spec, scaffold or notes. That's usually the cause.

Is this only for developers?

The ideas apply to any agent build, from scripts to page templates. Someone on the team does need to read code well enough to recognize when it has left the scaffold.

Ready to build with agents, not around them?

Book a call and we'll scope one workflow your team could hand to agents with a scaffold and checks.

Book a Search Strategy Call