AI pair programming: how to work with an AI as your pair
AI pair programming means working on code alongside an AI assistant the way two people pair: one decides direction and checks the work, the other writes. You can drive and let the AI suggest, or navigate and let the AI write. It works best in small steps with a test or a clear check after each one, and it fails when you stop reading what the AI produces.
What is AI pair programming?
Pair programming is an old practice: two people share one task. Martin Fowler's article On Pair Programming describes the standard roles. The driver is at the keyboard, focused on the tiny goal at hand and talking through what they are doing. The navigator observes, reviews the code as it appears, and keeps the larger issues, bugs and next steps in mind. The idea of the split is two perspectives on the same code: tactical and strategic.
AI pair programming borrows the roles and puts an AI in one seat. In a chat or an editor, the AI can write code, explain code, propose alternatives and spot mistakes. You supply what it lacks: knowledge of the goal, taste, and the ability to say that something is wrong. Done well, you get the benefit of a second set of eyes at any hour. Done badly, you get a confident partner who agrees with everything and whom nobody is checking.
That second sentence is the heart of the practice. A human pair challenges you. An AI tends to go along with the direction you set, so the challenge has to come from how you work: small steps, tests, and a habit of asking it to find faults.
| Two people | You and an AI | |
|---|---|---|
| Availability | Needs two calendars to line up | Any time |
| Pushback | A person disagrees and explains why | Usually agrees unless asked to critique |
| Knowledge of your codebase | Builds up over weeks | Only what is in its context (see context engineering) |
| Speed of typing | Human speed | Seconds for a block of code |
| Risk | Two people can both be wrong | You can accept code you do not understand |
| Learning | Both learn from each other | You learn if you ask for reasons; it does not carry lessons between sessions unless you write them down |
What are the ways to pair with an AI?
There is more than one way to sit, and the right one depends on what you are doing and how well you know the area.
| Mode | Who drives | How it feels | Use it when | Main risk |
|---|---|---|---|---|
| You drive, AI suggests | You type; the AI completes lines and answers questions | Autocomplete and a chat panel beside you | You know the area and want speed on the boring parts | Accepting suggestions on autopilot |
| AI drives, you navigate | The agent edits files; you set goals and review the diff | You describe, read, correct and approve | Features and fixes of a few files; areas you can judge | Reviewing too lightly as the diff grows |
| Ping-pong | You write a failing test, the AI makes it pass; then swap | A tight loop of red, green, refactor | Logic with clear inputs and outputs; code you must trust | Tests that only test the AI's own assumptions |
Most builders using agents such as Claude Code or Cursor work in the second mode. If that is you, the navigator job is real work. You are responsible for the direction, the scope and the verdict. The AI does the typing.
How do you run an AI pair programming session?
A routine keeps you in the navigator seat. This one fits a session of thirty to ninety minutes.
- Set one goal. Write it in a sentence that includes how you will know it is done. "Add a Reset button that clears the form, tested by a new unit test."
- Load the context. Name the files to start from and any fact the code does not show. A short project instructions file saves repeating yourself.
- Ask for a plan before code. Have the AI say what it will change in a few lines. Correct the plan, not the code.
- Take one small step. One function, one test, one component. If the AI wants to touch ten files, say no and ask for step one.
- Run it. Run the tests or the app yourself. Do not trust "this should work".
- Read the diff. Read every changed line before accepting. If you cannot explain a line, ask the AI to explain it, then decide.
- Commit. A commit after every working step gives you a place to return to when the next step goes wrong.
- Swap roles now and then. Write the next function yourself, or ask the AI to review your code. Keep the skill from fading.
What prompts work for pairing with an AI?
These prompts set the working agreement. Paste them at the start or reuse them mid-session.
We are pair programming. I navigate, you drive. Rules for this session: 1. Propose a short plan and wait for my go-ahead before you edit any file. 2. Work in small steps. One step is one function, one test or one component. 3. After each step, tell me how to check it, and run the check if you can. 4. If my instruction looks wrong, say so before doing it and explain why. 5. Do not add anything I did not ask for. Do not refactor unrelated code. Goal for today: <one sentence with a done-check>. Start from: <files>.
Here is a failing test I wrote: <paste the test> Make it pass with the smallest change. Do not edit the test. Show me the change, then stop. I will write the next test.
Before you write code for this, give me the two best reasons it could be a bad idea, and one simpler alternative. Then ask me one question that would change your recommendation.
Explain the change you just made as if I know the language but not this codebase. For each changed block, say what it does, why it is needed, and what would break if I deleted it.
Review the diff above as a strict reviewer. List bugs, missing edge cases, missing tests and anything you added that I did not request. Do not praise. If you find nothing, say what you checked.
Stop. Summarise in five lines: the goal, what we tried, why each attempt failed, what we know for certain, and the next thing to test. I will start a new session from your summary.
Which skills matter when you pair with an AI?
The AI changes where the effort goes. Less of it is typing. More of it is these four things.
- Describing precisely. A vague request gets a plausible guess. Name the file, the behavior and the limit.
- Reading code you did not write. The diff is the product. A slow, honest read of it is the main safeguard you have.
- Writing the check first. A test or a manual script that fails now and passes when the work is right turns the AI's output from an opinion into evidence.
- Knowing when to stop. The AI will keep adding. You decide when the goal is met.
If you are learning, pair differently. Ask the AI to hold back. Claude Code's output styles include a Learning style, which its documentation describes as Claude explaining its choices and leaving small pieces of code for you to write yourself, and an Explanatory style that adds short notes on the reasoning. Other tools have no such switch, but you get the same effect with a prompt: "Do not write the solution. Give me a hint and let me try." The guide to coding with AI as a learner goes further.
When does AI pair programming go wrong?
- You stop reading. The most common failure. Past a certain size, the diff looks like a wall and you approve it. Keep steps small enough to read.
- The AI marks its own homework. Tests written by the same AI after the code often assert what the code does, not what it should do. Write the test first, or at least read it hard.
- Invented APIs. The AI may call a function or option that does not exist. Run the code and check names against the library's documentation.
- Security by omission. Authentication, payment, file upload and anything that handles other people's data deserves a human-level review, not a skim. Never paste secrets into a chat.
- Scope creep. Left alone, the AI adds options, abstractions and files. Say what is out of scope in the first message.
- Skill drift. If you only navigate, your ability to write the code yourself will fade. Keep a few tasks you do by hand.
For checking the output in a more structured way, see AI code review. For ideas to practise on, the board has plenty of small, well-scoped ones: a tool like Meeting cost ticker fits in one session, and every idea carries a generated build prompt you can use as a kickoff. A bigger map of the field, including agents that work on their own for longer, is in what agentic coding is.
Frequently asked questions
What is AI pair programming?
AI pair programming is working on code with an AI assistant in the manner of two programmers: one steers and checks, the other writes. You can type while the AI suggests, or describe goals while an agent edits files. In both cases you remain responsible for direction and for reading the result.
Is AI pair programming better than working alone?
It is faster on routine code, unfamiliar syntax and first drafts, and useful as a second opinion at any hour. It is not better when you stop reading what it writes. The benefit depends on small steps, tests and your willingness to review, not on the tool.
Can an AI replace a human pair programmer?
Not entirely. An AI types fast and answers questions at any hour, but it usually agrees with your direction and only knows what is in its context. A human pair brings real disagreement, knowledge of your team and shared accountability. Use the AI for speed and a person for judgment.
What are the driver and navigator roles?
In pair programming the driver writes the code and focuses on the immediate goal, while the navigator reviews each change and watches the bigger picture, bugs and next steps. With an AI, the common arrangement is that the AI drives and you navigate, setting goals and checking every change.
How do I stop the AI from agreeing with everything?
Ask for disagreement directly. Prompt it for the two best reasons an approach could fail and a simpler alternative, or ask it to review its own diff as a strict reviewer who may not praise. Write tests first so a result is judged against facts rather than opinion.
Which tools support AI pair programming?
Most AI coding tools can be used this way: editor assistants that complete code, chat panels, and agents such as Claude Code or Cursor that edit files. The tool matters less than the routine: a small goal, a plan, one step at a time, a check and a read of the diff.
Created with AI assistance and edited for this site. Examples are illustrative and do not represent customer research. About the publisher.