How to Write a CLAUDE.md File (With a Copy-and-Paste Template)

By Prompt Guy · Dec 1, 2026

Feature image: a simple document with an orange folded corner and short lines, with the title How to write a CLAUDE.md file and the small Prompt Guy mascot.

A CLAUDE.md file is a short instructions sheet that Claude Code reads at the start of every session. You put it in your project folder, and it tells Claude Code what your app is, which tools you use, and how you want it to work with you. Write it in plain sentences, keep it short (Anthropic suggests under 200 lines), and update it whenever Claude Code makes the same mistake twice.

That's the whole idea. The rest of this guide shows you exactly what to put in it, with a template you can copy.

What is a CLAUDE.md file?

Think of Claude Code as a very fast new assistant who forgets everything overnight. (New to Claude Code itself? Start with Claude Code for non-coders.) Every morning you'd have to explain the job again. A CLAUDE.md file is the note you leave on their desk so you don't have to.

Anthropic's memory documentation describes CLAUDE.md files as "markdown files that give Claude persistent instructions for a project, your personal workflow, or your entire organization." Claude Code reads them at the start of every session.

One thing worth knowing early: the docs say Claude "treats CLAUDE.md files as context, not enforced configuration." In plain English, it's guidance, not a lock. Clear, specific instructions get followed far more reliably than vague ones.

Where does CLAUDE.md go?

For a project, the file goes in the main (top) folder of your project, named exactly CLAUDE.md. According to the docs, Claude Code also looks in a few other places:

Claude Code reads the CLAUDE.md files from the folder you're working in and every folder above it, so a rule in your home folder applies to every project.

The fastest way to get a first version

You don't have to start from a blank page. In Claude Code, run:

/init

The docs say /init generates a starting CLAUDE.md for you by looking at your project. If you already have one, it suggests improvements instead of overwriting it (thoughtful).

The catch: /init can only describe what it sees in your files. It doesn't know how you want to work, what your app is for, or what it must never do. That's the part you add.

What to put in your CLAUDE.md

Here are the sections I'd include, in this order.

1. What the app is, in one or two sentences

"QuoteQuick is a web app that lets cleaners send a price quote to a customer in under a minute." Who it's for and what it does. That's enough.

2. Your tools (the stack)

The tools your app is built with, for example: "React and TypeScript for the website, Supabase for the database and logins, Stripe for payments, hosted on Vercel." If you're not sure, ask Claude Code to fill this part in after /init.

3. How you want Claude Code to work with you

This is the section beginners forget, and the one that makes the biggest difference. Mine looks like this:

4. Rules for the app

Things that must always or never happen: brand colours, the tone of the words on the site, and a short "never do" list. For example: "Never put secret keys in the website code. Keys live in .env.local, which is never committed."

5. Commands

How to run, test and deploy the app, like npm run dev. If you don't know yet, leave a line that says "Fill this in once we have them" and Claude Code will.

What to leave out

A CLAUDE.md that tries to say everything gets followed less. The docs recommend targeting "under 200 lines per CLAUDE.md file." So leave out:

If you have long reference material, like your full copy guide, keep it in a separate file. The docs explain you can pull it in with @path/to/file, for example See @docs/style-guide.md for the words we use.

A CLAUDE.md template you can copy

Copy this, paste it into a file called CLAUDE.md in your project's main folder, and fill in the brackets:

# [App name] ## What it is [One or two sentences: what the app does and who it's for.] ## Tools (stack) - Website: [e.g. React + TypeScript] - Database and logins: [e.g. Supabase] - Payments: [e.g. Stripe] - Hosting: [e.g. Vercel] ## How to work with me - I'm not a developer. Explain what you did in simple English. - Work one small step at a time, then tell me how to test it. - Ask before deleting any file or data. - Tell me exactly what to click or run. - Commit to git after each working step, with a clear message. ## App rules - Brand colours: [e.g. green #1E4D3A, orange #F26B1D] - Tone of the words on the site: [e.g. friendly, plain English] - Secret keys live in .env.local (never committed). Secret keys are only used on the server. - Never: [one rule per line] ## Commands - Run it: [e.g. npm run dev] - Test it: [fill in once we have tests] - Deploy it: [fill in once it's set up]

It's short on purpose. Add a rule only when you need one.

How to keep it useful

A CLAUDE.md isn't something you write once. A few habits keep it working:

Rules for one part of your project

As your app grows, you may want rules that only apply to some files. The docs describe a .claude/rules/ folder for this: small markdown files that can be limited to certain paths, like only your server code. You won't need it on day one, but it's good to know it's there.

The quick way: generate it

If you'd rather answer a few questions than write from scratch, the CLAUDE.md Generator in Prompt Guy's Build Lab does it for you. It walks you through 5 short screens (about the app, your tools, how you want Claude to work with you, app rules and commands), with the beginner options already ticked, and gives you the file plus simple steps to add it to your project. Lite members get one free try, and Pro and Business members can use it as often as they need. The CLAUDE.md step is also part of the course, The SaaS Roadmap, which walks you from an idea to a live app.

FAQ

What is CLAUDE.md used for?

It gives Claude Code lasting instructions about your project, so you don't have to repeat yourself every session: what the app is, the tools it uses, how you want to work, and the rules to follow.

Where do I put the CLAUDE.md file?

In the main folder of your project, named CLAUDE.md. You can also add one in your home folder (~/.claude/CLAUDE.md) for rules you want in every project.

How long should a CLAUDE.md be?

Short. Anthropic's docs suggest under 200 lines per file. Shorter, more specific files are followed more consistently.

Does /init write a good CLAUDE.md?

It writes a good start. It describes your project from its files, but you still need to add how you want to work and your app's rules.

Will Claude Code always follow my CLAUDE.md?

It reads it every session and follows clear rules well, but the docs say it's treated as context, not enforced configuration. If a rule keeps getting missed, make it shorter and more specific.