Lessons From 60 Hours Of AI Pair Programming
After spending an intensive 60-hour week pair programming with ChatGPT Codex, I’ve come away with some hard-won lessons that can dramatically improve any developer's experience with AI coding assistants. This wasn't just a casual experiment; it resulted in a major feature upgrade for my core product and the creation of four new add-on products. It was, without a doubt, the most productive development period of my career.
However, the path was filled with challenges. The AI's quirks and tendencies required a new way of thinking about development. Here are the ten most valuable lessons I learned, plus a bonus tip, to help you navigate the world of AI-assisted coding.
1. Ditch Comprehensive Spec Docs
This might be controversial, as providing a detailed Product Requirements Document (PRD) is often seen as a best practice for AI coding. In my experience, however, feeding the AI a massive, monolithic set of instructions is a recipe for disaster. If the AI misunderstands a single detail or if your spec is even slightly incomplete, the entire project can go off the rails. It’s also incredibly difficult to test and debug a large system that materializes all at once. While you should still have a clear plan, don't give it to the AI in one go.
2. Embrace Step-by-Step Building
Instead of a single large spec, I found enormous success with an incremental, step-by-step approach. I started by asking the AI to generate the user interface elements without any underlying functionality. At first, the layout was messy, but I could iteratively instruct the AI to rearrange, style, and position everything until it looked right. Only after the UI was perfect and local JavaScript interactions were working did I begin asking the AI to build the core business logic. This modular process made the build manageable, robust, and much easier to debug.
3. Be Wary of AI's Speed
AI tools can create code at an astonishing speed, enabling achievements like condensing four years of product development into four days. But this speed is a double-edged sword. A single misinterpreted prompt can lead the AI to destroy or corrupt your codebase just as quickly as it created it. This is another strong argument for making small, incremental changes and committing your code to version control frequently.
4. The Undo Button is Your Best Friend
ChatGPT Codex provides an undo button that reverts the entire set of changes from the last prompt. Don't hesitate to use it. If the AI generates something incorrect, confusing, or destructive, undoing the action is the fastest way to get back on track. It’s an essential tool for safe experimentation.
5. Resist Premature Feature Suggestions
As the AI begins to understand your project, it will often suggest new features or try to add business logic before you're ready. While these suggestions can be tempting, they are often premature and don't fit well into the current stage of your build. It's better to make a note of the idea and implement it later, under your explicit direction, once the foundational components are stable.
6. Use AGENTS.md for Standing Instructions
The AGENTS.md file is a standard used by many coding AIs to provide persistent, project-wide instructions. I keep one in my project's root directory with guidelines like, "Never modify any files in library directories." This prevents the AI from altering external libraries and saves me from having to repeat the same core instructions in every session.
7. Leverage Screenshots for Clarity
A picture is worth a thousand words, especially when communicating with an AI. When the AI struggled to understand a verbal description, I would provide a screenshot with arrows pointing to the relevant areas. Often, simply pasting a screenshot into the chat with the prompt "this" was enough for the AI to grasp the context and proceed correctly.
8. Feed the AI HTML and CSS for Context
If the AI is having trouble with web page styling or identifying the correct CSS selectors, you can help it by providing direct context. Open the browser's inspector, copy the relevant HTML or CSS, and paste it directly into the chat. This gives the AI the exact code it needs to analyze and modify.
9. Manage Session Context Windows
Long coding sessions can exhaust the AI's context window, especially after pasting large code blocks or error logs. To avoid losing progress, you can ask the AI to summarize the current session. I use a prompt like: "I want to start a new session. Please provide a summary of our discussion that I can paste into the new session to bring you up to speed, like a patient handover between hospital shifts." This creates a concise brief that you can use to seamlessly continue your work in a fresh session.
10. Command the AI to Refactor Its Code
By default, Codex tends to create large, monolithic files, often inlining CSS and JavaScript directly into PHP files. This is not ideal for maintainability. You should explicitly instruct the AI to refactor its code. I regularly tell it to extract JavaScript into .js
files and CSS into .css
files. You can also ask it to group related functions into separate category files, leading to a much cleaner and more organized codebase.
Bonus Tip: Explicitly Ask for Maintainable Code
The AI does not prioritize human-readable, maintainable code unless you ask it to. Always instruct it to add comments, format the code properly, and structure it logically. You can also ask it to provide explanations and reference information for the code it writes, but you must make the request explicitly.
What are your favorite tips?
Have you tried pair programming with an AI? What strategies have worked for you? Share your experiences and insights in the comments below.