Best practices for working with AI coding assistants
How to get high-quality results from AI pair programmers and agents, and stay the engineer in charge.
Key takeaways
- Context is everything. Give goals, constraints, examples and relevant files.
- Ask for a plan first, then implement in small, verifiable steps.
- You are accountable for every line. Read, run and test it.
AI coding assistants range from autocomplete to autonomous agents that edit many files and run commands. Used well, they remove drudgery and speed up learning. Used carelessly, they produce confident, subtle bugs at scale.
#1. Give rich context
The AI only knows what you show it. Good context includes:
- The goal: "Users should be able to export invoices as CSV."
- Constraints: "Use our existing
csvutil; no new dependencies; must stream for large files." - Examples: "Follow the pattern in
exports/orders.ts." - Definition of done: "Include tests for empty data and special characters."
Many tools support a project instruction file (conventions, commands, architecture). Write one. It pays off every day.
#2. Plan before code
Ask for a plan first: "Before writing code, list the files you'll change and your approach." Correcting a plan takes seconds. Correcting 500 lines of wrong code takes an afternoon.
#3. Work in small steps
One change, one verification, then commit. Small steps keep diffs reviewable and make it easy to roll back when the AI goes in a wrong direction.
#4. Verify everything
- Run it. Does it actually work?
- Run the tests, and check that they'd fail if the code were wrong.
- Read the diff. Look for invented APIs, swallowed errors and duplicated helpers.
- Check dependencies. Make sure any new package really exists and is trustworthy.
#5. Know where AI shines and where it struggles
| Great at | Be careful with |
|---|---|
| Boilerplate, tests, migrations | Security-critical code |
| Explaining unfamiliar code | Subtle concurrency |
| Refactoring with clear rules | Ambiguous requirements |
| Writing scripts and configs | Large architectural decisions |
| Drafting docs | Anything you can't verify |
#6. Protect secrets and production
- Never paste secrets into prompts.
- Give agents least-privilege tokens and sandboxed environments.
- Require human approval for destructive commands.
#7. Keep learning
Use the AI as a tutor: "Explain why this approach is better than X." Engineers who use AI to understand more grow faster than those who use it to think less.
Remember: The AI is a fast, tireless collaborator. You are the engineer of record.
Keep reading
What AI-DLC is, how its three phases work, and how to adopt it without losing control of quality.
Write the spec first, let AI plan and build from it, and keep the spec as the source of truth.
AI makes coding faster, but estimates don't shrink the way you'd expect. Here's how to adjust.