Article illustration 1

The Promise and Peril of AI Pair Programming
For decades, pair programming meant two humans collaborating in real-time to write code. Today, it increasingly involves developers teaming up with AI assistants like ChatGPT Codex—a shift that promises unprecedented productivity but demands new strategies. I recently spent 60 hours in an immersive pair programming session with Codex, completing what would have taken four years of solo development in just days. The experience was transformative, accelerating feature upgrades for my core product and spawning four add-ons. Yet, it wasn't without turbulence: AI hallucinations, misinterpreted prompts, and workflow inefficiencies surfaced repeatedly. Through trial and error, I distilled 10 essential lessons that every developer should heed before integrating AI into their coding practice.

1. Ditch Monolithic Specs for Incremental Wins
Conventional wisdom touts product requirements documents (PRDs) as the gold standard for AI-driven development, but feeding an AI a massive spec is a recipe for disaster. One misunderstood instruction can cascade into catastrophic errors. Instead, adopt a stepwise approach:
- Start by having the AI generate UI elements without wiring functionality.
- Refine positioning and styling iteratively before enabling logic.
- Only implement core features once the foundation is solid.
This method mirrors Agile principles, minimizing risk and making debugging manageable.

2. Build Step-by-Step, Not All at Once
AI excels at rapid creation but falters with holistic comprehension. When I tasked Codex with constructing an entire dashboard UI in one go, elements landed chaotically. Success came from deconstructing the process:
1. Layout first: Add buttons, checkboxes, and inputs with placeholders.
2. Style next: Iterate on CSS for positioning—expect 5–10 adjustments.
3. Functionality last: Enable JavaScript interactions only after UI refinement.
This phased build prevents overwhelming the AI’s context window and yields more robust results.

3. Expect—and Mitigate—Catastrophic Mistakes
AIs create at lightning speed but destroy just as fast. A single malformed prompt can corrupt your codebase. Always:
- Version control religiously (e.g., Git commits after each change).
- Leverage Codex’s undo button immediately when output veers off-course.
- Isolate experiments in branches to contain fallout.

4. Resist the AI’s ‘Feature Creep’ Guilt Trips
Mid-session, Codex often suggests premature features like auto-saving configurations. Ignore these—it lacks context for cohesive integration. Document ideas for later review, but prioritize stability over novelty.

5. Standardize with AGENTS.md
Create an AGENTS.md file in your project root to enforce consistent rules. For example:

Never modify files in /lib directories. These are external libraries and must remain updatable.
This eliminates repetitive instructions and safeguards critical paths.

6. Screenshots Are Your Secret Weapon
When descriptions fail, visuals bridge the gap. Paste screenshots directly into Codex’s chat to highlight issues. For instance, I captured misaligned UI elements, added arrows, and prompted "fix this"—resolving stubborn CSS errors instantly.

Article illustration 2

7. Feed Raw HTML/CSS for Precision
Struggling with selectors? Use browser inspectors to copy HTML/CSS snippets into the chat. This gives Codex exact context, accelerating styling fixes.

8. Master Session Handovers
Context windows fill fast. When resetting sessions, prompt:

Provide a summary I can paste into a new session to resume our work. Think shift-change handover.

Codex will output a concise recap, preserving continuity without data loss.

9. Enforce Refactoring Early
Left unchecked, Codex dumps JavaScript/CSS into monolithic files. Combat bloat by commanding:

Refactor inline CSS into /styles/core.css and move JavaScript to /scripts/module.js
This maintains modularity and eases long-term maintenance.

10. Demand Maintainable Code
AI won’t prioritize readability unless directed. Explicitly request:
- Comprehensive comments explaining logic.
- Modular functions with descriptive names.
- Consistent formatting for human reviewers.

The Double-Edged Sword of AI Acceleration
Pair programming with Codex isn't just about speed—it's about rethinking collaboration. These lessons reveal that AI's greatest strength (scale) is also its weakness: without guardrails, it amplifies errors as efficiently as it generates code. For developers, this means embracing AI as a copilot, not a replacement. Tools like AGENTS.md and incremental builds turn chaos into controlled innovation, but vigilance remains non-negotiable. As one commenter noted, 'AI writes the first draft; humans write the final story.' The future of coding isn't solo—it's symbiotic, and mastering these nuances will define the next era of software engineering.

Source: David Gewirtz, ZDNET