The AI coding workflow: spec, plan, build, review
AI can write code in seconds, but code you do not understand is a liability. Learn the four-step loop of spec, plan, build in small steps and review that professionals use, and why skipping a step costs more time than it saves.
Type "make me a coffee shop website" into an AI chat and you will get code within a minute. It may even run. Then you ask for one change, the AI rewrites half the file, something else breaks, and an hour later you are lost in code you did not write and cannot read.
This is the most common way beginners fail with AI. The AI is not the problem. The missing process is. This lesson gives you a simple one.
Why "just ask for the whole app" fails
A language model writes the most likely code for your request. If the request is vague, it fills the gaps with guesses: which framework, which folders, what the data looks like, what happens on errors. You find out about those guesses only after they are baked into 400 lines.
Three things go wrong again and again:
Common failures of one-shot prompting
| Failure | What it looks like | Root cause |
|---|---|---|
| Wrong guesses | The AI picks a library or structure you did not want | The request left room for guessing |
| Big-bang changes | One new feature rewrites files that worked | The AI had no small, clear target |
| Unknown code | It runs, but you cannot explain or fix it | You never read what you accepted |
The loop: spec, plan, build, review
Professional developers who use AI well follow the same four steps they would follow with a human teammate. The AI does the typing. You stay the engineer.
The four steps
| Step | Question it answers | Who leads | Output |
|---|---|---|---|
| 1. Spec | What are we building, exactly? | You | A short written description of the goal, users, features and limits |
| 2. Plan | In what order, and with which files? | You and AI together | A numbered list of small tasks |
| 3. Build | Can we do just task 1? | AI writes, you run it | Working code for one small piece |
| 4. Review | Is it correct, safe and understood? | You | Tested code you can explain, then commit |
Steps 3 and 4 repeat for every task. Think of it as a loop: build a small piece, review it, save it, move to the next.
Step 1: Spec
A spec is a written answer to "what exactly should this do?" It is the single biggest improvement you can make to AI output, because it replaces the AI's guesses with your decisions. You will write a full one in *Write a project spec an AI can build from*.
For now, notice the difference. Here is a vague request and the same request with a mini spec.
Make a website for my coffee shop.What to expect: The AI must guess everything: the stack, the pages, the design, whether there is a backend, whether orders exist.
I run Brew & Bean, a small coffee shop in Indiranagar, Bengaluru. Build the home page of its website.
Stack: React with Vite, plain JavaScript (JSX), plain CSS. No other libraries.
The page must have: a header with the shop name, a short intro, opening hours (8 am to 10 pm daily) and a footer with the address.
Out of scope for now: menu, cart, login, backend.
Before writing code, list the files you will create and wait for my approval.What to expect: A good answer lists a few files (for example src/App.jsx, src/App.css) and waits. It does not invent a menu or a cart.
Step 2: Plan
A plan splits the spec into tasks small enough that you can check each one in a few minutes. A good task changes one or two files and has a visible result: "the header shows the shop name", not "build the frontend".
You can ask the AI to draft the plan, then edit it yourself. The plan is where you catch wrong guesses cheaply, before any code exists.
Here is my project spec:
[paste your spec]
Do not write any code yet. Break this into a numbered plan of 5 to 10 small tasks. For each task give: the goal in one sentence, the files it touches, and how I can check that it works (what I should see in the browser or terminal). Order the tasks so the app runs after every task.What to expect: Check that every task has a visible way to verify it, that the order makes sense, and that nothing from the out-of-scope list sneaked in.
Step 3: Build in small steps
Give the AI one task at a time. Paste the task, plus the current code if the AI cannot see your files. After each answer:
1. Run it. See it work (or fail) yourself. 2. If it fails, give the exact error message back. Do not describe it from memory. 3. Only when it works, move on.
Do not stack unverified changes
If task 3 is built on task 2 and task 2 never actually worked, you will not know which of them caused the bug. Always run the app between tasks. Small steps make bugs easy to find because the bug is in the last thing you changed.
Step 4: Review
Review means reading what the AI wrote and testing it before you keep it. AI code can look confident and still be wrong: it may call a function that does not exist, trust data it should check, or skip error handling. You will practise this in *Reading and reviewing AI-written code*.
A light review after every task takes two minutes:
Two-minute review after each task
- I ran it and it did what the task said.
- I can explain in my own words what each new function or component does.
- There are no new libraries or files that I did not ask for.
- Nothing that worked before is broken.
- No secrets (API keys, passwords) are written in the code.
- I saved the work with a git commit and a clear message.
The last point matters. A git commit is your undo button. If the next AI change wrecks the project, you can go back to the last good state. You will set up Git in *Set up your machine*.
A worked example of the loop
Say you want a "Today's special" banner on the Brew & Bean home page.
Spec line: "A banner under the header shows the text 'Today's special: Cold Brew, ₹220'. The text comes from a variable at the top of App.jsx so I can change it easily."
Plan: (1) add a special variable and a Banner component; (2) style the banner; (3) hide the banner when special is empty.
Build: ask for task 1 only. Run the page. You see the text. Commit: "Add Banner component".
Review: you notice the AI also added a library for icons. You did not ask for it, so you ask it to remove it. Commit again.
Each loop took a few minutes, and at every point the project worked.
How this comes up in interviews
Interviewers increasingly ask how you use AI tools. A weak answer is "I paste the whole task and copy the result". A strong answer describes the loop: "I write down the requirements first, ask for a plan, build one piece at a time, run and read everything before I commit, and I write tests for anything important." Interviewers want to see that you can judge code, not only generate it. Expect questions like "Tell me about a bug the AI introduced and how you caught it."
Try it: Run the loop on a small idea
Pick a tiny project, for example a tip calculator page (HTML and JavaScript) for splitting a restaurant bill among friends.
1. Write a spec of 5 to 8 lines: inputs, outputs, one thing that is out of scope. 2. Ask an AI chat for a plan with 3 to 5 tasks, no code. 3. Edit the plan: remove or reorder at least one task. 4. Build only task 1. Run it. Write down one thing you checked.
Key takeaways
- AI is fast at writing code, but only a process keeps the code correct and understood.
- The loop: spec (what), plan (order), build (one small task), review (read, run, test, commit).
- A spec replaces the AI's guesses with your decisions.
- Small tasks with a visible result make bugs easy to find.
- Always run the code, and commit after each working step so you can undo mistakes.
- Interviewers want to see that you can judge AI code, not only generate it.
Check yourself
Finishing the quiz marks the lesson as done.
1. Why is asking an AI for a whole app in one prompt risky?
2. What is the main purpose of the plan step?
3. Task 2 failed to work but you move on to task 3 anyway. What is the likely result?
4. A tester reports a crash. What should you give the AI to help fix it?
5. What is the best reason to commit to Git after every working task?
Saved on this device. Create a free account to keep it on every device.
Practise this with Sam
A real mock interview, out loud, with an honest scorecard. Free to start.