AI Coding: Claude Code, Codex, Cursor, Windsurf · Lesson 2
Workflow patterns
Good practices: TDD with AI, refactoring against a plan, limiting blast radius.
TDD with AI
- Write the tests first (or ask the AI to write tests against the interface).
- Then the implementation. The AI writes code so the tests pass.
- The AI runs the tests itself. If they're red, it fixes them.
This saves you from "vibe coding," where pretty code doesn't do what's needed.
Refactoring against a plan
- First, a plan of 5-10 atomic steps.
- Each step is its own commit with tests passing.
- If a step falls apart, you roll back exactly that step.
Limiting blast radius
- Don't give the AI
rm -rfwithout confirmation. - Worktrees for risky migrations.
- A commit check before merge.
- In CI, a separate agent job with restricted permissions.
Anti-pattern
A long, "open-ended" prompt like "improve the project." The AI drifts into adding abstractions and broken interfaces.
The best pattern is a narrow task with an explicit DoD.
Practical exercise
What to do after this lesson
Take a function in your project. Write tests for it via AI. Then ask the AI to improve the function so all tests pass.
Ready-to-use prompt
Template for this lesson
Copy and adapt to your context. Text in angle brackets should be replaced.
Goal: <one narrow task> Context: files X, Y; stack <…>. DoD: tests T1-Tn pass; lint passes; no new dependencies without sign-off. Proceed in this order: 1. A plan (5-10 steps). 2. After approval — implementation step by step. 3. For each step — run the tests. 4. Any external dependency — ask first. Do nothing outside the DoD.
Common mistakes
What people get wrong
- Open-ended prompts without a DoD — the AI "wrecks" the project.
- Ignoring tests — you end up rolling back all the work.
- Giving the AI rights to main without review.
Pro tips
What works but no one documents
- A hard DoD at the start of the prompt.
- The plan as a separate step, implementation after approval.
- One commit — one atomic step.
When to use
Any non-trivial development with AI.
When not to use
A one-line hack fix — the overhead isn't worth it.
Official sources
Квиз — 2 вопроса
1.What is the most important thing when developing with AI?
2.Which of these does NOT belong to limiting blast radius?
Отвечено: 0 из 2