Who Drives the Code in AI Pair Programming?
10 min läsning
Key takeaways
- Humans should drive security-sensitive edits, unfamiliar code, and ambiguous requirements; AI should drive scaffolding, mechanical refactors, and test generation.
- Autocomplete keeps the human as driver with the AI suggesting lines, while coding agents invert the roles and make the human a navigator reviewing merge requests.
- Write acceptance criteria and explicit stop conditions before launching an agent; specification quality sets how long a leash it gets.
- Give every parallel agent its own git worktree so handoffs are branches you inspect rather than shared working directories.
- Kill any agent that runs long without a reviewable diff and restart it with a tighter spec instead of letting it finish one more step.
The human should drive scaffolding, security-sensitive edits, and unfamiliar code; the AI should drive mechanical refactors and well-specified scaffolding where you can review the diff after. In practice, who drives the code in AI pair programming comes down to task type plus how fast you can spot drift. Below, a decision table plus mid-task signals for retaking the keyboard.
What is the default answer for who holds the keyboard?
Who holds the keyboard depends on the task type: humans drive scaffolding decisions, security-sensitive edits, and unfamiliar code, while autonomous agents drive well-scoped refactors and parallel work across repos. The default should be deliberate switching between driver and navigator, not reflexive autocomplete. Teams running agent fleets already pay for getting this wrong: the Ticksly team runs up to thirty Claude Code and Codex sessions at roughly $8 per merge request in API costs, noting "the three of us provide the tasks and the direction" (Dev.to). The sections below give you a decision table for mapping tasks to drivers, plus the signals that tell you when to retake control. For how this applies across your stack, see our breakdown of agentic AI coding tools.
What does 'driving' mean in AI pair programming?
Classic pair programming roles, briefly
In a human pair, the driver holds the keyboard and writes the code. The navigator watches, reviews each change as it lands, and steers: they set acceptance criteria, catch drift early, and decide what gets built next. One person types; the other thinks a step ahead.
How the roles shift when the pair is an AI
With autocomplete assistants, you stay the driver and the AI navigates, suggesting lines you accept or reject. Autonomous agents invert that: the agent holds the keyboard, types fast, and you become the navigator. Your job is no longer typing but task distribution, state tracking, and writing acceptance criteria sharp enough that a fast, confident agent cannot wander off. That inversion is the core decision behind agentic AI coding tools: who drives, and for how long.
How do driver and navigator roles map to autocomplete assistants versus coding agents?
The roles flip depending on which tool holds the keyboard. With autocomplete, the human types and the AI suggests the next lines. With agents, the AI types and the human reviews what comes back.
Autocomplete: human drives, AI suggests
In Cursor or Copilot-style autocomplete, you hold the task in your head, write the code, and accept or reject suggestions inline. The AI never acts on its own; it cannot open a branch, run tests, or touch another repo. Control is continuous and cheap to retake.
Agents: AI drives, human navigates
Devin, GitHub Copilot coding agent, and Cursor Cloud Agents invert this. You assign a task with acceptance criteria, the agent writes the branch, and you review the merge request. Your navigation happens through the task description and the diff, not the keystrokes. The Second Shift writeup on running four agents at once calls the trick "splitting the thinking from the doing": the navigator defines direction, the driver executes.
| Autocomplete | Coding agent | |
|---|---|---|
| Who holds the keyboard | Human | AI |
| Human role | Driver | Navigator |
| Unit of review | Line/keystroke | Merge request |
| Failure mode | Bad suggestion accepted | Agent wanders or overwrites siblings |
| Control switch | Instant, per line | Deliberate, per task |
The inversion has a cost: leave four agents alone together and they "overwrite each other's work, duplicate each other, and burn your token budget arguing about who is right," per the same writeup. That is why fleet-level orchestration like Aerunit exists: someone has to keep navigating while the agents drive.
When should the human drive instead of the AI?
Three task types need a human on the keyboard: security-sensitive edits, unfamiliar or high-blast-radius code, and ambiguous requirements.
Security-sensitive edits
Auth flows, token handling, permission checks, and anything touching secrets. An agent will produce plausible-looking code that passes tests while quietly widening an attack surface. You write these changes yourself, or you review the diff line by line before it merges.
Unfamiliar code and high blast radius
Blast radius is the real test. If a change touches a migration, a payment path, a shared library, or a repo three other services depend on, an agent that is 90% right is more expensive than one that is 50% right, because the last 10% lands in someone else's code and nobody notices until production. Unfamiliar code compounds this: you cannot review what you cannot evaluate, so the agent's confidence becomes your only signal, and confidence is the least reliable signal an agent emits. A confident wrong answer in a codebase you do not know is worse than a visible human mistake, because there is no instinct telling you to double-check it. When you have not worked in the codebase and the change is wide, drive yourself. Use the agent as navigator: ask it to map call sites, draft the plan, and flag edge cases while you hold the keyboard.
Ambiguous or underspecified requirements
If you cannot state acceptance criteria, the agent will invent them, and it will invent them wrong with full confidence. Resolve the ambiguity first, then hand over a task with explicit criteria. That split, thinking versus doing, is what keeps a fleet of parallel agents on target instead of burning your token budget on the wrong thing (stories for coding agents).
When is it safe to let the AI drive the code?
AI can hold the keyboard when the work is verifiable: scaffolding, mechanical refactors, test generation, and any task with acceptance criteria you could check yourself. The pattern is the same in each case. You can tell whether the output is right without re-deriving it, so a wrong agent burns a review cycle instead of a week.
Scaffolding and boilerplate
New endpoints, config files, CRUD routes, docker-compose setups. The shape is predictable, the diff is easy to skim, and nobody loses sleep if the naming is slightly off. This is the safest territory for an autonomous agent, including across multiple repos at once.
Mechanical refactors and test generation
Renaming, extracting functions, upgrading a dependency, writing tests against existing behavior. The task has a definition of done, and a failing suite catches drift immediately. Agents still make confident mistakes here, so keep approval prompts on for anything touching shared interfaces.
Specification quality sets the leash length
The same agent that wanders for hours on a vague ticket will run clean on a tight one. Write acceptance criteria before you launch, not after the third wrong turn, and you can let it go longer between check-ins. Aerunit's instant feedback loop for coding agents exists for the gap between those two states: agents report against your criteria as they work, so a longer leash does not mean discovering the problem at merge request time.
Which task gets which driver? A decision table
Scaffolding and boilerplate: the AI drives end to end. The task has clear acceptance criteria, the blast radius is small, and a failed attempt costs a retry, not a refactor.
Refactors across a known codebase: AI drives, human navigates. You define the invariant (tests stay green, public API unchanged) and let the agent work, checking in at the merge request rather than mid-edit.
Unfamiliar code: shared control. The AI drafts, you read the diff line by line, because neither of you has ground truth yet.
Security-sensitive edits: you drive, always. Auth, payments, and data access get human hands on the keyboard.
The bottleneck is rarely task selection, though. Practitioners report the real constraint is whether the model behind the orchestrator can hold context across steps (one founder's thread on orchestration tools with local models). Match driver to task, then check your model can survive the task's length.
How do you switch control between human and AI mid-task?
Set the handoff point before the run starts
A handoff you decide at kickoff beats one you improvise at hour three. Write the switch into the task story: "run solo until tests pass, then stop for review" or "pause after the schema migration and wait." Agents follow explicit stop conditions far better than implied ones, and you get a clean state to take the keyboard from instead of a half-finished refactor.
Worktrees and isolation for parallel drivers
When several agents run across the same repo, each one needs its own git worktree. Without isolation, one agent's mid-task experiment becomes another agent's merge conflict, and retaking control means untangling who touched what. A worktree per agent gives every driver, human or AI, a private checkout, so a handoff is a branch you inspect rather than a working directory you share.
Approval prompts as steering wheels
Approval prompts are your mid-task steering mechanism, not an annoyance to batch away. Route the high-consequence gates (deleting files, schema changes, dependency installs) through manual approval, and let low-risk steps run through. Each approval is a checkpoint where you can read the diff, correct course, or take over entirely, which is how you retake the keyboard deliberately instead of discovering drift after the merge request opens.
What signals tell you the AI is driving off course?
Time and token signals
A session that runs long with no merge request is the clearest warning. If an agent has burned tokens for an hour without a diff worth reviewing, it is likely stuck in a retry loop or wandering a codebase without a plan. Kill it and restart with tighter acceptance criteria rather than letting it finish "one more step."
Diff and merge request signals
Read the diff, not the agent's summary. A diff touching files far from the task scope, or rewriting code the task never mentioned, means the agent is fixing the wrong thing. Devin (Cognition) and other autonomous agents surface their plan as they work, so a plan that drifts from your instructions is an early retake signal (devin.ai).
Coordination signals across a fleet
With parallel agents, watch for two agents editing the same files. Overwritten work and duplicated merge requests mean your task distribution failed, not the agents. As one developer running thirty sessions put it, one agent waiting on an answer while another spends three hours fixing the wrong thing is invisible without state tracking. Assign owners per repo, and stop an agent the moment its scope overlaps a teammate's.
How does this play out for a team running parallel agents?
Humans as navigators at fleet scale
At fleet scale, the driver/navigator split inverts. The Ticksly team runs up to thirty Claude Code and Codex sessions and pays roughly $8 per merge request at API prices, with "The three of us provide the tasks and the direction." Nobody holds a keyboard. Every human is a full-time navigator, and the job becomes writing acceptance criteria, triaging approval prompts, and spotting which of thirty tabs has been waiting on an answer or has spent three hours fixing the wrong thing.
Why orchestration tooling matters more than autocomplete skill
At that scale the bottleneck is not how well anyone prompts an autocomplete assistant. It is task distribution, retries, and state tracking across multi-repo worktrees, so agents do not overwrite each other's work or duplicate effort while burning the token budget. Splitting the thinking from the doing is the whole trick: the orchestrator holds the map, humans review the route, and the agents keep driving.
FAQ
Is AI pair programming still pair programming if the AI does all the typing?
Yes, as long as the role split holds. In classic pairing, the driver types and the navigator thinks ahead. With agents, the AI types and you navigate: you set acceptance criteria, review diffs, and steer direction. The typing was never the valuable half of the pairing.
How many coding agents can one person realistically navigate at once?
Teams report anywhere from four to thirty sessions per person, but the ceiling is set by your state tracking, not your typing speed. The Ticksly team runs thirty sessions with three people doing task distribution and direction. Start small and add agents only when you can spot which one is stuck.
Should I let an AI agent commit directly to main?
No for anything with real blast radius: migrations, payment paths, shared libraries, or auth. Keep agents on their own branches and review the merge request before it lands. Direct commits to main remove the one checkpoint where you can catch a confident mistake. For throwaway scaffolding in an isolated repo, the risk calculus changes, but the default is branch plus review.
What is the cheapest way to let AI drive without burning my token budget?
Tight acceptance criteria before launch, explicit stop conditions in the task, and a hard kill rule: if an agent runs long with no reviewable diff, restart it with a tighter spec rather than letting it finish one more step. Approval prompts on high-consequence gates also help, since each one is a cheap checkpoint against an expensive wrong turn.
Do I need a different workflow for Claude Code versus Cursor autocomplete?
Yes, because the roles invert. In Cursor autocomplete, you drive and evaluate suggestions per keystroke, so control is continuous and cheap to retake. With Claude Code or other agents, you navigate through task descriptions and diffs, so you need written acceptance criteria, worktrees for isolation, and deliberate handoff points instead of inline accept-or-reject decisions.