top of page

The Art of Pair-Coding with AI

  • Writer: Yanbing Li
    Yanbing Li
  • Feb 7
  • 3 min read

A Practical Guide for Modern Developers


Generative AI is rapidly reshaping how we build software—not by replacing developers, but by augmenting them. As someone who advises engineering teams and mentors software leaders, I've seen firsthand how a well-structured collaboration between a developer and a large language model (LLM) can unlock immense productivity, creativity, and technical precision.

This article distills the best practices we've developed at iSterna for using AI as a pair-coding partner. It covers what works, what doesn't, and how to make the most of this new collaboration model.


  1. Be Specific

    1. Provide clear, unambiguous goals.

    2. Include expected input/output types, performance requirements, and coding style. Vague prompts lead to vague code. Be clear about what you want:

      • "Write a function to merge two sorted lists without using extra space."

      • "Optimize this algorithm to run in under 0.5 seconds on 10,000 nodes."

      • "Refactor this C/C++ code using object-oriented design."

      • “Write a function to find the median of a list of integers (O(n log n) or better). Must handle empty input gracefully.”

    3. The more precise your goal, the better the LLM can assist.

  2. Set Constraints

    1. AI thrives on boundaries. Some examples:

      • "Don’t use recursion."

      • "Must be compatible with Python 3.7."

      • "Avoid external libraries."

    2. Limitations or preconditions help the model generate solutions that actually fit your context.

  3. Assign Roles

    1. You’re not just talking to a chatbot. You’re assigning a job.

      • "Act as a compiler. Where would this fail?"

      • "You're a C/C++ code reviewer. Spot bad patterns."

      • "You’re my DevOps mentor. What’s wrong with this pipeline config?"

    2. Giving the model a persona or function improves alignment and output quality.

  4. Iterate, Test, Refine

    1. AI is fast, but not always right. Use it like a human collaborator:

      • Ask for multiple approaches

      • Run quick tests on outputs

      • Give feedback and improve the prompt

    2. Great results come from conversations, not one-shot prompting.

  5. Use AI for Thinking, Not Just Typing

    1. AI is not just autocomplete. It’s a co-designer.

      • Ask "What’s the time complexity of this?"

      • Say "Explain this bug to me like I’m a five years old."

      • Request "Give me edge cases this might fail."

    2. These kinds of prompts tap into the model’s reasoning abilities—not just syntax.

  6. Verify and Own the Output

    1. Don’t blindly trust the result:

      • Validate logic

      • Check edge cases

      • Be mindful that AI still hallucinates

    2. Able to explain the code at code reviews, demos or product launches etc. for code transparency.

  7. Build Prompt Reusability

    1. Save good prompts:

      • For test generation

      • For common refactorings

      • For project scaffolding

    2. Organize in themes: "Debugging", "Security Review", "Optimization", “Scalability”, “Performance”, “Reusability”, “Sustenance”, “Coherency”, “agility” etc.


Bonus: Prompt Template You Can Steal

### Role
You are a [role: senior software engineer | debugger | architecture reviewer]

### Task
I want to [goal: build X / refactor Y / debug Z]

### Constraints
- Do not use [specific tools or patterns]
- Must meet [performance or compatibility] criteria

### Context
Here is the code I have:
[insert code here]

Expected Behavior

  • Should handle [X, Y, Z] cases

  • Return value must be [format]

  • Needs to be secure and maintainable

Questions / Next Steps

  • What are the performance bottlenecks?

  • How can we simplify this?

  • Suggest unit tests to validate it


Start small. Try one or two principles today and build up your prompt discipline over time. Great pair coding with AI is not magic — it's method.



---

## Further Reading & References

---

Appendix A: References and Public Resources

The following references provide publicly available best practices, studies, and examples related to AI-assisted software development.

 

GitHub Copilot


OpenAI


Google Codey (PaLM for Code)


Academic Research


Additional Guides

Prompt Engineering Guide (Awesome List): https://github.com/dair-ai/Prompt-Engineering-Guide

 
 
 

Comments


bottom of page