- Published on
Using AI as a Pair Programmer
- Authors
- Name
- Eriitunu Adesioye
- @Eri_itunu
Overview
This post explains how to use AI tools (like code assistants) effectively as a pair programmer. It covers a workflow, practical tips, and common pitfalls to avoid so you get useful, reliable help while maintaining control of your codebase.
Why use an AI pair programmer?
- Speeds up routine tasks (boilerplate, refactors).
- Helps brainstorm solutions and alternatives.
- Acts as an on-demand documentation search and example generator.
A practical workflow
- Define the small, well-scoped task you want help with.
- Share the minimal relevant code and explain the desired behavior.
- Ask for one or two suggestions, not an entire redesign.
- Review the suggestions carefully; run tests and linting.
- Iterate: give targeted feedback and request a narrower change.
Tips for better results
- Prefer specific prompts (input, expected output, constraints).
- Share code snippets rather than large files; point to the exact function or area.
- Ask for explanations of returned code so you can learn and audit changes.
- Use tests as a contract: request unit tests or property-based tests for critical logic.
Example: small refactor
Here's a simple example (JavaScript) showing how you might ask an assistant to extract a helper function:
// before
function getUserFullName(user) {
if (!user) return ''
return `${user.firstName} ${user.lastName}`
}
// after: extracted helper
function formatName(first, last) {
return [first, last].filter(Boolean).join(' ')
}
function getUserFullName(user) {
if (!user) return ''
return formatName(user.firstName, user.lastName)
}