4.9GuidePart of Build a website with AI coding agents: the practical guide
Claude Code best practices for building websites
What matters most in Claude Code for website work: checks it can run, a real browser, and your own images and facts. With real steps on an Astro site.

On this page12 sections
Claude Code is a coding agent: it reads your project, edits its files and runs commands when you ask in plain language. The most useful habit on a website is to give it checks it can run, because, as its docs put it, “Claude stops when the work looks done.” On an Astro site, that means astro check, astro build and the page itself in a browser, while you stay in charge of the images, the facts and what goes live.
What Claude Code is
Claude Code works in your project folder. It edits files and runs commands there. It runs in a terminal, an editor, a desktop app or a browser, so you don’t have to start in a terminal.
One thing to know first: new terminal and VS Code sessions start in auto mode. Routine commands run without asking you, and a separate model reviews risky ones before they run. So “Claude ran a command” may not mean you approved it.
Why websites need their own habits
The check examples in the official docs are things like auth tests and a type check. A website is judged by people looking at it, and a small site may have few tests or none.
Three things are different on a website:
- The result is visual. A page can pass every command and still look wrong.
- The content is facts only you know. Your prices, your hours and your story aren’t in the code.
- Images are files that come from somewhere. Someone owns each one.
The check ladder
The docs’ rule: “Give Claude something it can run that comes back pass or fail.” Claude can then run the check, read the result and fix what broke. On a website, no single check is enough, so use all four rungs:
| Check | Catches | Misses |
|---|---|---|
astro check |
Type errors | Whether the site builds |
astro build |
A site that won’t build | Types, and how it looks |
| The page in a browser | Layout, phone width, broken clicks | Whether the words are true |
| You | Facts, tone, the decision to ship | Anything you don’t read |
Claude can run the first three. The last is yours.
A type error means the code passes the wrong kind of value, such as text where a number belongs. You might assume the build catches these. The Astro docs say astro build “will not run any type checking”, and the dev server doesn’t either. A passing build doesn’t cover types, so run both commands.
Put both commands in the project’s instructions, so Claude knows them in every session. The docs call the check command “the single most useful line” in CLAUDE.md. For how to set up that file, see AGENTS.md vs CLAUDE.md, CLAUDE.md best practices and how to write an AGENTS.md.
Then ask for evidence: “the command it ran and its output, or the screenshot”. The docs say “All tests pass” on its own “tells you very little”. Copy this prompt for any change you can see:
Run pnpm check and pnpm build. Open the changed page in the browser at phone width,
in light and dark mode. Click the links and forms, and read the console.
Show me the command output and a screenshot.
A note on your own project: the scripts a new Astro project gets are dev, build and preview. If yours has no check, add "check": "astro check" to package.json. Astro’s TypeScript guide also shows astro check && astro build as a build script, if you want type errors to stop the build.
Ways to let Claude see your page
Commands can’t tell Claude how a page looks. Here are three ways to show it:
| Way | Where | What Claude does |
|---|---|---|
| Browser pane | Desktop app | Starts the dev server, takes screenshots, clicks, fixes what it finds |
| Chrome extension | Terminal or VS Code (claude --chrome) |
Opens tabs in your browser, reads console errors, tests forms |
| Screenshot you paste | Anywhere | Reads the image you hand it |
The dev server is the local copy of your site that updates as you edit. The console is where the browser reports page errors.
The extension needs a direct Anthropic plan and a /login sign-in.
A warning about the extension. It shares your browser’s login state, so Claude “can access any site you’re already signed into”. You manage site permissions in the extension’s settings. In auto mode, a browser call the reviewing model approves skips the extension’s per-site check, unless your permission rules deny the site. The Browser pane uses a clean profile with none of your saved logins, so we’d pick it for testing your own site if you have the desktop app.
Check the build, not only dev. Astro’s preview command serves the build, to catch errors in your build output before you deploy. In Vesper, our free theme, site search works in pnpm preview and not in pnpm dev, so a test in dev would report a bug that isn’t there.
Once Claude says it’s done, you can also run /verify in the session. Claude builds and runs the app and looks at the result.
Playwright, a browser testing tool, is another route. Builder.io’s tips list recommends connecting it for UI changes. This guide doesn’t cover its setup.
Images
Images come up in two ways: the files on your site, and the pictures you show Claude.
On your site. The Astro docs recommend keeping local images in src/ when you can, so Astro can optimize them. Files in public/ are served as they are. The <Image /> component needs alt text, and it sets width and height for you, so the page doesn’t jump as it loads. A theme can keep images elsewhere and still process them: Vesper’s are in content/media/ and its posts point to them from their frontmatter, the settings block at the top of a Markdown file.
In the conversation. Drag a mockup or photo into Claude Code, paste it with Ctrl+V (Alt+V on Windows), or give its path. Claude can read it and draft alt text. Read that draft yourself, because you know what the photo is meant to show.
Where the photos come from. Give Claude the real photo. Don’t let it fetch images from the web unless you have checked the license. Keep a record, as Vesper does: its content/media/CREDITS.md lists each photo’s source and license.
Content and facts
Claude can state things that aren’t true. Anthropic’s own docs say language models “can sometimes generate text that is factually incorrect”. On a website, that risk looks like an invented price, testimonial, phone number or line of legal text, and a build can’t catch any of them.
The rule: facts come from you. Those docs also suggest giving Claude permission to say it doesn’t know. A marker is a good way to do that on a website.
Vesper’s privacy page shows the pattern. It leaves the unknown parts as markers:
[[fill in: your host, and how long its logs are kept]]
Its AGENTS.md file, the instructions a coding agent reads, says: “Fill each [[fill in: …]] marker with the owner’s real facts; never invent them.”
Its setup check backs that up. Once SITE_URL is a real address, a marker in content/pages/ stops pnpm build. A sentence asks. A check stops.
Session controls
Sessions go wrong. These controls from the docs are the ones to know by heart:
| Situation | Do this |
|---|---|
| It’s drifting | Esc stops and keeps the work |
| Wrong result | /rewind rolls back code, conversation or both |
| Corrected twice, still wrong | /clear, and write a better prompt |
Plan first for big changes. For a change across many pages, start in plan mode. Put /plan before your prompt, or press Shift+Tab until the status bar shows plan mode. Claude proposes a plan and doesn’t edit your source until you approve it.
The website trap: /rewind isn’t a full undo. It doesn’t restore a file that only a shell command changed, such as an image converted by a script. Commit before you start, and treat Git as the real undo.
Current Astro answers. The Astro docs warn that “AI tools may use outdated patterns”. Connect their docs server, which gives Claude the latest documentation over MCP, a standard way to link outside tools to Claude:
claude mcp add --transport http astro-docs https://mcp.docs.astro.build/mcp
Rules with no exceptions
Most of what you tell Claude is a guideline, and that’s fine. A few rules have to hold every time. So where does each rule go?
Can Claude find it by reading the code?
Can it ever have an exception?
Yes
AGENTS.md or CLAUDE.md
Claude decides
No
A setting
Claude Code enforces
The docs split this in two. Your prompt and CLAUDE.md are things Claude decides on. Hooks and deny rules are things Claude Code enforces, no matter what the model decided. A hook is a script of yours that Claude Code runs at a fixed point, and a deny rule blocks a tool call outright.
The website example is git push. On many hosts, a push is close to publishing: the Astro deploy guide says a host typically watches your main branch and will “rebuild and republish your site at each new commit”. You could say “don’t push” in the chat. But the docs warn that the sentence can be lost when the conversation is compacted, which is when Claude Code shortens a long conversation into a summary.
A setting doesn’t get lost. Save this as .claude/settings.json:
{
"permissions": {
"ask": ["Bash(git push *)"],
"deny": ["Read(./.env)", "Read(./.env.local)"]
}
}
Now Claude Code asks you before any push, and it refuses to read your .env files, which often hold passwords and keys. Rules match tool calls, not intent, so a script that opens the file gets past them.
Keep this set small, as the docs say. Every rule will occasionally fire when it shouldn’t, and someone has to maintain it. For hooks, see the hooks guide.
A real example: add a post to Vesper
Here is the whole habit on one task. Use a fresh copy of Vesper, which is free and MIT licensed.
-
Copy Vesper, run
pnpm install, and make a first commit. Start Claude Code withclaude --chrome, or use the desktop app. -
Look at the pattern in
content/posts/a-darkroom-in-a-closet-for-180.md. Each post starts with this frontmatter:title: A darkroom in a closet, for $180 date: 2026-07-18 summary: A blackout curtain, a used tank, three thrift-store trays and a fan from the hardware store. ... thumbnail: ../media/analog.webp thumbnailAlt: A film camera resting on sand at the edge of the water category: photography tags: [film, gear] -
Send this prompt. The
@includes that file in your message.Add a post to content/posts/, following the pattern in @content/posts/a-darkroom-in-a-closet-for-180.md. Use content/media/tent.webp as the thumbnail, and draft its alt text from the photo. Use only the facts below. If something is missing, leave a [[fill in: …]] marker. <your notes> Then run pnpm check and pnpm build. Open the post in the browser at phone width, in light and dark mode. Show me the command output and a screenshot. -
Know the guard behind it. Vesper’s content schema, the rules each post’s frontmatter must follow, requires alt text on a thumbnail. Here is the message from
src/content/alt.ts, as it reads for a post:thumbnailAlt is required when thumbnail is set: describe the photo.This is content checked like code, in words Claude can read. Astro’s docs say a file that breaks its schema gets “a helpful error”.
-
Read the output and the screenshot. Then read the diff, the list of what changed, and check the facts yourself. While
sampleContentis on, Vesper’s setup check warns about a marker left in a post. With it off, the check stops the build and names the post. Commit, or/rewind.
Advice you can skip
The docs keep a table called “What you can stop doing”. As of November 6, 2026, it retires these:
- ALL CAPS rules. If a rule can’t bend, make it a hook or a deny rule.
think harderphrases. They are ordinary prompt text. The effort setting is the control.- “Manage your context window aggressively.” Running out is now rare.
/clearbetween tasks still helps. - Subagents for “better answers.” A subagent is a helper session. Handing it the same task doesn’t improve the answer, though a fresh reviewer does help.
- “Loop until done.” Giving Claude a check to pass is what’s still worth doing.
Check the date on any tips list, including this one.
Common mistakes
Taking “done” as the check. Ask for the command and its output, or the screenshot.
Running only the build. It doesn’t type-check, and it doesn’t look at the page.
Testing only in dev. Some things differ in the build, so open preview before you ship.
Letting Claude fill in facts or pick images. Prices, reviews and legal text need a source. Photos need a license.
Relying on /rewind as your undo. Commit first.
Skipping permission prompts to go faster. You may see this as tip number one on a tips list. The docs say bypassPermissions “only makes sense in a disposable container.”
What to do next
Our advice: spend your setup time on checks, not on prompt wording.
- If you do one thing: put
checkandbuildcommands in your instructions, and ask for the output every time. - If the change is visible: connect a browser, and ask for a screenshot.
- If it’s a fact, a price or a photo: bring it yourself.
- If a rule has no exceptions: make it a setting.
- When not to bother: a throwaway page doesn’t need any of this setup.
For the bigger picture, from picking a starter to shipping, read Build a website with AI coding agents.


