Building with an AI agent, one step at a time
An AI coding agent can build a working site from your words, but only if you steer it in small, checkable steps. This lesson starts a real Next.js project with the agent, gives it a briefing file, and shows the loop you will repeat for every feature.
By the end you can
- Start a Next.js site with the agent and see it running at localhost:3000
- Write an instructions file (CLAUDE.md or AGENTS.md) the agent reads every time
- Give instructions with a goal, a place, a limit and a check
- Read what the agent changed, and recover when it gets stuck
The everyday picture
Picture a new kitchen helper who is fast, keen and has never seen your stall. Say "make the whole menu" and you get twelve dishes, three of them wrong, and no idea which step went bad. Say "make the lentil soup, mild, for four, and call me before you salt it" and you can taste it and fix it.
You also pin a card on the wall: what the stall sells, where things are, what never to do. The helper reads it every morning. The AI agent is that helper, your instruction is the dish, and the card is the instructions file.
The loop: ask, plan, change, check, save
Every feature goes round the same loop. It feels slow for the first hour and saves days later.
- Ask for one small thing.
- Plan: for anything bigger than a small change, the agent first says what it will do. You read the plan and say yes or adjust it. In Claude Code, Shift+Tab switches to plan mode, where it plans without touching files.
- Change: it edits files and may ask to run commands. Approve each one until you trust the pattern.
- Check: open the site and test what you asked for, yourself.
- Save: make a save point in Git (lw-03), so the next step can never ruin this one.
Quick check
The agent says "Done! The recipe page is ready." What do you do before the save point?
"Done" is a claim, not a test. Agents sometimes report success on things that don't work. Testing two features together means that when something breaks, you can't tell which step caused it.
The instructions file: the agent's briefing
Agents forget between conversations. An instructions file fixes that. Claude Code reads CLAUDE.md; many other agents read AGENTS.md. Kolom has one too, and it grew with every lesson its owner learned.
Keep it short: what the site is, the tools, how to run it, and your rules. Add a rule each time the agent makes the same mistake twice. In Claude Code, the /init command drafts one for you to edit.
Quick check
Twice this week the agent installed a new package without asking. What is the lasting fix?
The instructions file is read every session, so one line covers every future request. Repeating it by hand works until the day you forget.
A good instruction, and reading what changed
A good instruction has four parts: the goal, where it goes, what not to touch, and how you will check. End with "stop after this step and list the files you changed".
Then read the change. You don't need to understand every line:
- Look at the list of changed files. A recipe card should touch one or two files, not the sign-in page.
- In VS Code's Source Control panel, click a file to see green (added) and red (removed) lines.
- Ask "explain this change in plain words" about anything you don't follow.
When it goes wrong, copy the exact error from the terminal or the browser into the chat. "It's broken" gives the agent nothing to work with. If three fixes in a row fail, stop, go back to the last save point and ask for a smaller step.
Do it
Start the project and give the agent its briefing. Screens and commands change between versions; follow what the agent shows you.
Make the folder
Create a folder such as
Documents/sites. In VS Code choose File, Open Folder and pick it. Open Terminal, New Terminal and typeclaudeto start the agent.Ask for the project
Send this instruction. The agent will run Next.js's own setup command and ask for permission first; read what it wants to run, then approve.
MarkdownCreate a new Next.js project called mangrove-kitchen in this folder, using the App Router and TypeScript, with the default settings. Then start it and tell me which address to open. Don't add any other packages. Explain each command before you run it.See it running
The agent runs
npm run dev. Open the address it prints in your browser. You should see the Next.js starter page.Output▲ Next.js 16.0.1 (Turbopack) - Local: http://localhost:3000 Ready in 1.8slocalhost means only you can see it. Going live comes in lw-05.
Write the briefing
Ask the agent to create
CLAUDE.md(orAGENTS.md) with this content, then read it and change anything that isn't true for your site.Markdown# Mangrove Kitchen Recipes-and-offers site for Mangrove Market. Members sign in, save favourite recipes and can get a weekly offers e-mail. ## Stack Next.js (App Router), TypeScript, plain CSS. Supabase for data and sign-in (later). Hosted on Vercel. ## Run npm run dev, then open http://localhost:3000 ## Rules - Small steps. Plan first and wait for my OK if a step touches more than 3 files. - After each step, list the files you changed and explain the change in plain words. - Ask before installing any package. - Never put keys or passwords in code; read them from environment variables. Never ask me to paste a secret key. - Every database table gets row-level security. - Don't change files I didn't ask about.Make the first small change
Use the four-part shape. Check the result in the browser, then look at the changed files in Source Control.
MarkdownGoal: replace the starter home page with a heading "Mangrove Kitchen" and the line "Recipes built around this week's offers". Where: the home page only. Don't touch: the layout file and the global styles. Check: I open localhost:3000 and see the heading and line. Stop after this step and list the files you changed.
Bring it to your team
Whoever helps you build, agree on these:
- Does every instruction say how we will check it?
- Did anyone read the list of changed files before saving?
- Is the instructions file up to date with the mistakes we have fixed?
- Which commands do we let the agent run without asking, and why?
Red flags
- "Build the whole site" as one instruction.
- Approving every command without reading it.
- Pasting a secret key into the chat "so the agent can set it up".
Practice
Rewrite a vague instruction
Imran's note says: "Make the site nicer and add a way to find recipes." Rewrite it as two separate agent instructions, each with the four parts and the "stop and list files" line. Then send the first one to your agent and check the result.
- Each instruction asks for one thing only
- Each names the goal, where it goes and what not to touch
- Each check is something you can see in the browser
- "Nicer" is turned into something concrete, such as a font size or spacing
Show a model answer
1. Goal: show the recipe cards in a grid, two per row on phones and three on laptops, with 16 pixels between cards. Where: the home page styles. Don't touch: the header. Check: I resize the browser and see two, then three cards per row. Stop and list the files you changed.
2. Goal: a search box above the cards that filters recipes by name as I type. Where: the home page. Don't touch: the recipe pages. Check: typing "soup" leaves only soup recipes; clearing the box shows all. Stop and list the files you changed.
Check yourself
You ask for a "Print recipe" button. The agent's list of changed files includes the sign-in page. What do you do?
A change outside the place you named is the first sign of a wrong turn. Asking costs a minute; finding a broken sign-in a week later costs much more.
The agent has tried three fixes for the same error and each one fails differently. What is the best next move?
Going in circles means the step was too big or the agent misunderstood. The save point gives you a clean start without throwing away the work that already worked.
Which line belongs in the instructions file rather than in a single instruction?
Rules that apply to every change belong in the file the agent reads each session. The others are one-off tasks.
Flashcards
Key takeaways
- Repeat one loop for every feature: ask, plan, change, check, save.
- An instructions file gives the agent your rules every session; add a rule whenever a mistake repeats.
- Good instructions have a goal, a place, a limit and a check, and ask the agent to stop and list its changes.
- Read the changed-file list, paste exact errors, and go back to a save point when the agent goes in circles.
Sources and further reading
- Claude Code quickstart, Anthropic docs
- Manage Claude's memory (CLAUDE.md), Anthropic docs
- Installation, Next.js docs
- AGENTS.md, an open format for agent instructions
- Source control in VS Code, VS Code docs