Project Instructions in Claude Code
A complete beginner-friendly guide to the standing instructions that tell Claude Code how your project works: what they are, where they live, what belongs in them, how to write them clearly, how teams share them, and how to keep them accurate and safe.
Imagine hiring a very capable engineer who is brilliant, fast, and eager, but who has never seen your project. On their first morning, they do not know how to build the code, which commands run the tests, where the important folders are, or what your team’s rules are. A good manager would not leave them to guess. They would hand over a short onboarding note: “Here is how we build, here is how we test, here is how the code is organized, and here are the rules we care about.”
Claude Code is in a similar position at the start of every session. It is a tool that works with the files in your project, reads code, runs commands, and makes changes, and each time it starts, it begins without memory of your last session. Project instructions are that onboarding note, written once and read automatically at the start of every session. This guide explains the idea from the ground up. You will learn what project instructions are, where they live, what to put in them and what to leave out, how to write them so that Claude follows them, how to organize them for larger projects and share them with a team, how they differ from settings and other mechanisms, and how to keep them accurate, tested, and safe. Every idea comes with an everyday comparison, so no deep technical background is needed.
1What Are Project Instructions?
Project instructions are a plain-text briefing that Claude Code reads before it starts working.
The simple definition
In Claude Code, project instructions are written in a special text file that Claude reads automatically at the start of a session. By convention, this file is named CLAUDE.md. You write it in ordinary language, using simple headings and short lists, and you describe what Claude needs to know about your project: how to run it, how it is organized, and how you want work done. Because the file is read every time, you never have to repeat the same explanation in each new conversation.
Think of the laminated card by the coffee machine in an office: “Use filtered water. Clean the tray after use. Call facilities if the red light blinks.” Anyone who walks up, including a brand-new colleague, can follow the card and avoid mistakes. A project instructions file is that card, for Claude Code and your project.
What it is not
- It is not code. It is a note written for a reader, so it contains guidance, not programs.
- It is not a security lock. It guides Claude’s behavior but does not technically prevent actions. Settings and permissions do that.
- It is not a full manual. It should be short, selective, and focused on what Claude cannot easily work out for itself.
- It is not magic. Claude reads it and tries to follow it, but clarity and brevity make the difference.
File names, commands, and loading rules in Claude Code can change as the product evolves. This guide describes the general ideas. For the exact current behavior, check Anthropic’s Claude Code documentation at docs.claude.com.
2Why Claude Code Needs Them
Claude is skilled, but it cannot read your mind or remember yesterday.
Each session starts fresh
Claude Code does not carry memory from one session to the next by default. If you spent an hour yesterday explaining how to run your tests, Claude does not recall it today. Without written instructions, you would repeat yourself endlessly, or Claude would waste time rediscovering the same facts by exploring the files.
Some knowledge cannot be seen in the code
Claude can read your files and learn a great deal from them. But some things are invisible in code: why a certain approach was chosen, which folders are off limits, what the team agreed about naming, which command is the right one when three exist, or what must never be changed without review. Project instructions capture exactly this unwritten knowledge.
A new neighbor can see your house, but they cannot see that the third stair creaks, that the back door sticks in summer, or that the dog must not be let out. Those facts live in your head. Writing them on a card by the door turns private knowledge into shared knowledge.
| Without instructions | With instructions |
|---|---|
| You re-explain how to run tests each session. | Claude already knows the right command. |
| Claude guesses at naming and style. | Claude follows the team’s conventions from the first edit. |
| Claude explores widely to find the structure. | Claude starts with a map of the important folders. |
| Claude may use the wrong tool or command. | Claude uses the agreed one. |
| Mistakes repeat across sessions. | A lesson written once is applied every time. |
| Each teammate gets different behavior. | Everyone shares the same guidance. |
Savings in time and tokens
Every question Claude answers by exploring costs time and uses up working space in the conversation. A short briefing at the start saves repeated exploration, speeds up the first useful action, and reduces wrong turns. The time you invest in writing a good file is repaid in every later session.
Write down what you would tell a capable new teammate on day one. If you find yourself saying the same thing to Claude twice, that sentence belongs in the file.
3How They Work Behind the Scenes
The mechanism is simple: the text is placed in front of Claude before your first request.
flowchart TD
A["You start a Claude Code session in your project folder"] --> B["Claude Code looks for instruction files"]
B --> C["Personal file for all your projects"]
B --> D["Project file shared with the team"]
B --> E["Files in folders you work inside"]
C --> F["Text is added to the starting context"]
D --> F
E --> F
F --> G["You type your request"]
G --> H["Claude reads instructions and request together"]
H --> I["Claude plans and acts, following the guidance"]
I --> J["You review the work"]
Read the diagram from the top. When you start a session, Claude Code looks for instruction files in several places: a personal file that applies to all your projects, a project file that your team shares, and files inside the folders you are working in. The text from these files is added to the starting context, which is the working space Claude can see. Then you type your request. Claude reads the instructions and your request together, plans and acts, and you review the work.
The context window: a shared desk
Everything Claude can consider at one time lives in its context window, a limited working space measured in tokens. Instruction text takes up space on that desk before you have typed a single word. This is why shorter files are better: every line is read every time, and every line competes with your actual work for room and for attention.
Picture a pilot’s checklist clipped to the dashboard. It is read at the start of every flight. A short checklist is used and trusted. A fifty-page manual clipped there would be ignored, because nobody can use it in the moment. Instruction files work best as the short checklist, not the manual.
Guidance, not enforcement
Claude reads the instructions and tries to follow them, much as a thoughtful colleague would follow a team guide. But the file does not act as a hard lock. If something must be guaranteed, such as never touching a certain folder or never running a certain command, use the permission and settings features of Claude Code, which are designed to enforce limits. Instructions shape behavior; settings enforce boundaries.
Do not rely on a sentence in the instructions to protect something critical. Treat the file as strong guidance, and add real permissions for anything where a mistake would be costly.
4Where Instruction Files Live
Different locations serve different audiences. Choosing the right place keeps things tidy.
| Level | Who it is for | Typical use | Shared with team? |
|---|---|---|---|
| Personal, all projects | You alone, everywhere | Your own habits: preferred explanation style, personal shortcuts | No |
| Project, at the top folder | Everyone working on this project | Build and test routines, structure, team conventions | Yes, usually saved with the code |
| Inside a subfolder | Work in that part of the project | Rules specific to one module or area | Yes, if saved with the code |
| Personal, one project | You, for this project only | Local details such as your own test data location | No, kept private |
A company has a general employee handbook, a department guide, and a note taped to your own desk. The handbook applies to everyone, the department guide to one team, and your note only to you. Instruction files layer in the same way, from broad to specific.
The project file: the heart of the system
The file at the top of your project is the most important one. It is saved alongside your code, so it travels with the repository, appears for every teammate, and can be reviewed and improved like any other file. Most of what you write will live here.
Personal files: your own preferences
Some guidance is about you, not the project. For example, “Explain changes in plain language before showing details” or “Ask before installing anything new.” A personal file applies these preferences to every project you open, without forcing them on your teammates.
Folder-level files: local rules
In bigger projects, different areas follow different rules. A file in a subfolder can hold guidance that applies only when Claude is working in that part. This keeps the top file short and gives local detail only where it is needed.
Private project notes
Sometimes you need a project-specific note that should not be shared, such as the location of your personal test data. Claude Code offers a way to keep such local notes out of the shared files. Check the documentation for the current method.
Ask yourself of every line: who needs this? If the answer is “the whole team”, put it in the shared project file. If it is “only me”, put it in a personal file. Mixing the two causes confusion and clutter.
5What to Put In
Include what Claude cannot easily work out for itself and will need again and again.
Common routines
The exact ways to build, run, test, and check the project, including which tool or command to prefer.
A map of the project
A few lines on the important folders and what lives in each, so Claude navigates quickly.
Team conventions
Naming, style, and structure rules that differ from common defaults or that Claude would not guess.
Workflow expectations
How work should flow: write tests first, keep changes small, describe changes in a certain way.
Gotchas and traps
Surprises that waste hours, such as a confusing setup step or a file that must not be edited by hand.
Boundaries
Areas to avoid, things to ask about first, and actions that need human approval.
When you show a house-sitter around, you do not describe every object. You point out the things they could not guess: the water shut-off, the temperamental oven, the neighbor’s phone number. A good instruction file works like that tour: only the non-obvious, high-value details.
Describing the workflow you expect
Beyond facts, instructions can describe the rhythm of good work. You might ask Claude to explain its plan briefly before making large changes, to make changes in small steps, to run the checks after each step, and to summarize what it changed at the end. You might also say how to handle uncertainty: “If you are unsure which of two approaches fits our conventions, ask me before choosing.” These workflow lines shape not just what Claude produces but how it works with you, and they are often the most valuable lines in the file because they change behavior across every kind of task.
Naming the people and processes
Some knowledge is organizational. Who reviews changes to a sensitive module? Which team owns the build system? How are releases announced? You do not need the whole organization chart, but a few lines about ownership and process help Claude suggest the right next step, such as “this change touches the payments module, so it needs review from that team”. Keep these lines general and avoid personal details that could go stale or be sensitive.
The “would Claude get this wrong?” test
For each candidate line, ask: if this line were missing, would Claude likely make a mistake or waste time? If yes, keep it. If Claude would work it out correctly from the files, or already behaves that way by default, leave it out. This one question keeps the file lean and valuable.
Examples of high-value lines
- “Run the tests with the project’s test command, not the general one, because the general one skips integration checks.”
- “Never edit files in the generated folder by hand; they are rebuilt automatically.”
- “All user-facing text goes through the translation system, never as plain text in the code.”
- “Keep each change small and focused; describe why it was needed, not only what changed.”
- “Ask before adding any new third-party dependency.”
Say why when it matters
A short reason helps Claude apply a rule intelligently in cases you did not foresee. “Do not edit the generated folder, because changes there are overwritten” lets Claude understand the purpose and avoid related mistakes, such as editing a copy of the same file somewhere else.
The best source of material is your own friction. Each time you have to correct Claude, ask whether the correction would have been avoided by one line in the file. If so, add it.
6What to Leave Out
A shorter file is a stronger file. Knowing what to omit matters as much as knowing what to include.
Keep in the file
- Non-obvious routines and commands.
- Rules that differ from common defaults.
- Pitfalls that have cost the team time.
- Short pointers to deeper documents.
- Boundaries and approval rules.
Leave out of the file
- Things Claude can read directly from the code.
- Generic advice such as “write clean code”.
- Long tutorials or whole manuals.
- Secrets, passwords, and keys.
- Information that changes daily.
| Do not include | Why | Better place |
|---|---|---|
| Passwords, tokens, keys | Security risk, because the file is shared and saved | A proper secrets system, never the file |
| Long architecture essays | Uses space and attention on every session | A separate document, referenced briefly |
| Obvious statements | Claude already behaves that way | Nowhere |
| Today’s tasks and status | Goes stale immediately | Your task tracker or the current conversation |
| Style rules a formatter enforces | Automated tools do it more reliably | The formatter’s own settings |
| Contradictory rules | Causes erratic behavior | Resolve the conflict, then write one rule |
A suitcase packed with everything you own is heavy and hard to use. A suitcase packed with what the trip requires is easy to carry and easy to search. Instruction files are suitcases, and every unnecessary item makes it harder to find the things that matter.
Do not duplicate the tools
If your project already has a formatter, a linter, or automated checks, let them enforce style and correctness. Instructions are better spent on judgment calls and context that tools cannot capture. Duplicating what a tool already enforces adds length without adding safety.
Never place secrets in an instruction file. These files are often saved with the code and shared widely. Anything you write there should be safe for every teammate, and for anyone who might later gain access to the repository, to read.
7Writing Clear, Followable Instructions
The same fact can be written in a way that works well or badly.
Principles for clear instructions
Be specific
Name the exact command, folder, or rule rather than describing it loosely.
Be short
One idea per line, and as few lines as the job needs.
Be checkable
Write rules that you could verify were followed or not.
Be positive where possible
Say what to do, and keep “never” for the few things that truly matter.
Give reasons
A few words of why help Claude handle the edge cases.
Group by topic
Use plain headings so the file is easy to scan and update.
| Weak instruction | Stronger instruction |
|---|---|
| Write good tests. | Every new feature needs a test that fails before the change and passes after it. Put tests next to the code they cover. |
| Be careful with the database. | Never run commands that delete or overwrite data in the shared database. Use the local test database for experiments, and ask me before touching anything else. |
| Follow our style. | Use descriptive names with full words, no abbreviations. Keep functions short enough to read on one screen. |
| Keep it clean. | Keep each change focused on one purpose. If you notice unrelated problems, list them at the end instead of fixing them. |
| Don’t break things. | Before saying a task is done, run the full test command and report the result, including any failures. |
Telling a babysitter “be careful” helps little. Telling them “the stove is off limits, bedtime is eight, and call this number if anything feels wrong” helps a great deal. Specific instructions turn good intentions into good behavior.
Write for a reader who takes you literally
Claude reads instructions carefully and tends to apply them as written. That is a strength when your words are precise and a weakness when they are loose. If you write “always run the tests”, Claude may run them even for a one-word change to a comment, which wastes time. If you write “run the tests after any change to code, but not for documentation-only changes”, the behavior matches your intent. Imagine a very diligent assistant who does exactly what the sentence says, then reread your lines for places where the literal reading differs from what you mean.
Use examples where wording is hard
Some preferences are easier to show than to describe. A single short example of a well-formed commit message, a good test name, or a well-structured section can teach more than a paragraph of rules. Keep examples brief and clearly labeled, and choose ones that represent your real standards. One good example beats three mediocre ones.
Use emphasis sparingly
If every line is marked as critical, none of them stands out. Reserve strong wording for the few rules where a violation would be expensive. Everything else can be written plainly.
Avoid conflicts
When two instructions disagree, Claude must guess which wins. Conflicts creep in as files grow and several people edit them. Review the file occasionally, and when you find a clash, settle it and keep one rule. Layers of files, such as a personal file and a project file, can also disagree, so keep each layer’s purpose clear.
Read your file as if you were Claude seeing it for the first time, with no background. Anything that would puzzle a smart stranger needs a clearer word, an example, or a short reason.
8Creating Your First File
You can have a useful file in a quarter of an hour.
Open Claude Code in your project
Start a session in the top folder of the project, so Claude sees the right files.
Let Claude draft a starting point
Claude Code offers a way to generate a first draft by studying the project. Check the documentation for the current command.
Trim and correct it
Remove the obvious and the wrong. Keep only what Claude would otherwise miss.
Add what only you know
Write in the routines, conventions, gotchas, and boundaries that cannot be seen in the files.
Test with a real task
Start a fresh session and ask for a small task. Watch whether Claude follows the guidance.
Save it with the project
Commit the file so the whole team benefits, and review it like any other file.
When you move into a new flat, you write a short welcome note for visitors: where the spare keys are, how the heating works, which neighbor to call. You do not write it all in one go; you start with the basics and add to it as questions arise. A first instruction file grows the same way.
A good starting structure
flowchart TD
A["Project instructions file"] --> B["Purpose: one or two lines"]
A --> C["Commands: build, run, test, check"]
A --> D["Map: important folders"]
A --> E["Conventions: naming, style, structure"]
A --> F["Workflow: how changes should be made"]
A --> G["Gotchas: traps and surprises"]
A --> H["Boundaries: ask first, never do"]
The outline in the diagram is a reliable starting point. Begin with one or two lines of purpose, so Claude knows what the project is for. Then list the commands to build, run, test, and check. Add a short map of the important folders, the conventions your team follows, the workflow you expect, the gotchas that have caught people out, and the boundaries Claude must respect. You do not need every section on day one, and you can leave out any that do not apply.
An example of how a section reads
Under a heading called Testing, a good section might say: use the project’s test command before reporting any task as finished; if a test fails, show the failure and propose a fix instead of hiding it; add a test for every bug you fix. Three short sentences carry a lot of value, they can be checked, and they teach Claude your standards.
Do not accept an auto-generated draft without reading it. It may include guesses or obvious statements. Treat it as a first draft that you edit down, not a finished product.
9Organizing Larger Projects
As projects grow, one file is not enough. Layers and references keep things manageable.
Layering by folder
In a large project, different areas have different rules. A web front end, a data pipeline, and a documentation folder may each have their own conventions. Put the shared rules in the top file, and put area-specific rules in files inside those areas. Claude can then pick up the right guidance depending on where it is working.
flowchart TD
P["Personal file: your habits"] --> R["Claude's working context"]
T["Top project file: shared basics"] --> R
S1["Front end folder file: local rules"] --> R
S2["Data pipeline folder file: local rules"] --> R
S3["Docs folder file: local rules"] --> R
R --> W["Work in the area you are editing"]
The diagram shows layers feeding into Claude’s working context. The personal file adds your habits. The top project file adds the shared basics. Files in the front end, data pipeline, and documentation folders add local rules when Claude is working there. The result is guidance that is specific to where the work happens, without making any single file long.
A hospital has house-wide safety rules, ward-specific procedures, and a personal checklist for each nurse. Staff in the children’s ward follow both the house rules and the children’s ward rules. Layered instruction files work in the same fashion.
Pointing to longer documents
If you already have longer documents, such as an architecture overview or a contribution guide, do not copy them into the instruction file. Instead, add a one-line pointer: what the document covers and when to read it. Claude Code also supports ways to include other files by reference, so check the documentation for current options. The principle is to keep the main file short and let Claude fetch depth only when the task needs it.
Splitting by topic
By area
Front end, back end, data, infrastructure: each with its own conventions.
By activity
Writing code, reviewing, releasing, and documenting may need different habits.
By audience
Shared team rules versus personal preferences.
By stability
Rarely changing basics versus fast-moving details kept elsewhere.
More files mean more places for rules to conflict or go stale. Split only when a single file becomes long or mixed, and give each file a clear purpose in its first line.
10Sharing Instructions with a Team
When the file lives with the code, the whole team shares one source of truth.
Treat it like code
Because the project file is saved with the repository, it can go through the same review process as other changes. A teammate who discovers a trap can add a line in a small change. Colleagues review it, discuss wording, and approve. Over time, the file becomes a shared memory of what the team has learned.
A shared recipe book in a family kitchen improves because each cook adds notes: “less salt”, “bake ten minutes longer”. Nobody owns it alone, yet everyone benefits. A shared instruction file grows in the same collective way.
Roles that help
Owner
Keeps the file coherent, resolves conflicts, and prevents bloat.
Contributors
Every teammate adds lessons as they learn them.
Reviewers
Check new lines for clarity, accuracy, and necessity.
Newcomers
Give the best feedback on what is unclear, because they see it fresh.
Team rules for the file
- One purpose per line. Easy to review, easy to remove.
- Explain additions. A short note in the change says why the line is needed.
- Prune regularly. Remove lines that are outdated or no longer needed.
- Keep personal taste out. Individual preferences belong in personal files.
- Agree on tone. Plain, direct, and consistent wording keeps the file readable.
Onboarding benefits
A well-kept file helps humans as much as Claude. New teammates can read it to learn how the project is built, tested, and organized. Many teams find that writing for Claude produces the clearest onboarding note they have ever had.
Make updating the file part of fixing a problem. When a bug or confusion is traced to missing guidance, the fix is not complete until the lesson is added to the file.
11Instructions Compared with Settings, Hooks, and Other Tools
Claude Code offers several ways to shape its behavior. Each has a different strength.
| Mechanism | Nature | Best for | Strength of control |
|---|---|---|---|
| Project instructions | Written guidance Claude reads | Context, conventions, routines, judgment calls | Strong guidance, not a lock |
| Settings and permissions | Configured limits | Allowing or blocking specific actions | Enforced |
| Automated checks and hooks | Actions that run at defined moments | Guaranteed steps, such as formatting or tests after edits | Enforced when configured |
| Reusable commands and skills | Packaged procedures | Repeatable multi-step tasks you run on demand | Used when invoked |
| Your request in the session | One-time direction | This task, right now | Applies to the current task |
In a workshop, a poster on the wall reminds people to wear safety glasses, a locked cabinet keeps dangerous tools away from beginners, and an automatic guard stops the saw if a hand gets too close. The poster teaches, the lock restricts, and the guard enforces. You need all three, each in its proper role.
Choosing the right tool
- If it is a preference or piece of context, write it in the instructions.
- If it must never happen, block it with permissions or settings.
- If it must always happen, automate it with a check or hook, so it does not depend on Claude remembering.
- If it is a multi-step routine you repeat, package it as a reusable command or skill, and mention it briefly in the instructions.
- If it is only for today’s task, say it in the session instead of the file.
Why enforcement matters
Anything critical should never rely only on a written request. A sentence can be misread, outweighed by a long conversation, or missed among many lines. A permission or an automated check does not forget. Use instructions to explain the why, and use enforcement to guarantee the what.
Features such as hooks, skills, and permission settings evolve. Confirm the current names and behavior in Anthropic’s documentation before you build routines around them.
12Keeping Instructions Current
An outdated instruction is worse than none, because it sends Claude confidently in the wrong direction.
flowchart TD
A["Notice a mistake or friction in a session"] --> B{"Would a written line have prevented it?"}
B -->|"Yes"| C["Draft a short, specific line"]
B -->|"No"| H["Fix it in the session only"]
C --> D["Check it does not conflict with existing lines"]
D --> E["Add it and share through review"]
E --> F["Test in a fresh session"]
F --> G{"Does Claude follow it?"}
G -->|"Yes"| I["Keep it"]
G -->|"No"| J["Reword, move, or enforce another way"]
J --> F
The loop begins when you notice a mistake or friction in a session. Ask whether a written line would have prevented it. If so, draft a short, specific line, check it against existing ones for conflicts, add it, and share it through review. Then test it in a fresh session. If Claude follows it, keep it. If not, reword it, move it, or enforce the rule another way. If a line would not have prevented the problem, handle it in the session and leave the file alone.
A road map is only useful if it shows today’s roads. If a bridge has been closed and the map still shows it open, drivers get stuck. Instruction files need regular updating so they always describe the project as it is now.
Signs a file has gone stale
- Commands in the file no longer work.
- Folder names or paths have changed.
- Claude follows a rule that the team has since dropped.
- Different lines contradict each other.
- The file has grown so long that nobody reads it.
A maintenance rhythm
Update as you learn
Add lines when a real mistake reveals a gap.
Update with big changes
When you change tools, structure, or workflow, change the file in the same step.
Review every few months
Read the whole file, delete the dead lines, and fix the vague ones.
Re-test after a trim
Run a typical task to confirm that behavior is still right.
Pruning is as valuable as adding. When the file feels crowded, remove the lowest-value lines first. Claude’s attention is limited, so every line you remove makes the remaining lines stronger.
13Testing Whether Claude Follows Your Instructions
Writing a rule is not the same as seeing it work. Test, do not assume.
flowchart LR
A["Pick a typical task"] --> B["Start a fresh session"]
B --> C["Give the task without extra hints"]
C --> D["Watch what Claude does"]
D --> E{"Did it follow the instructions?"}
E -->|"Yes"| F["Rule works"]
E -->|"No"| G["Diagnose the cause"]
G --> H["Reword, simplify, or enforce"]
H --> B
Choose a task that matches a rule you care about. Start a fresh session so nothing from earlier sessions helps. Give the task without extra hints, watch what Claude does, and compare it with your rule. If Claude followed the rule, it works. If not, work out why, then reword, simplify, or enforce it, and test again.
Ask Claude what it understood
A quick check is to start a session and ask: “What do you know about how to test this project and what rules should you follow?” Claude’s summary shows what it took from the file. Missing or garbled items point to lines that are unclear or buried.
Common reasons a rule is not followed
| Cause | What it looks like | What to try |
|---|---|---|
| Too vague | Claude does something reasonable but not what you meant | Add the exact command, folder, or example |
| Buried in a long file | Early rules work, later ones are missed | Shorten the file and move key rules up |
| Conflicting rules | Behavior flips between sessions | Resolve the conflict and keep one rule |
| Competing instruction | A request in the session overrides the file | Make the rule’s priority clear, or enforce it with settings |
| Too many “critical” rules | Nothing stands out | Keep emphasis for the few that matter |
| Rule needs a guarantee | Followed most of the time, not always | Move it to permissions or an automated check |
After writing a fire-drill plan, you hold a drill to see whether people actually follow it. Plans that look perfect on paper often fail in practice. Testing instructions with real tasks is your fire drill.
Measuring whether the file helps
You can judge the value of your instruction file with a few simple signals. Count how often you have to correct Claude on the same point; this number should fall as the file improves. Notice how long it takes to get a useful first change in a new session. Watch whether new teammates need fewer questions in their first week. And review the changes Claude proposes: if they follow your conventions without reminders, the file is doing its job. If the same corrections keep recurring, the corresponding lines are missing, unclear, or buried.
Keep a small set of test tasks
Write down three to five typical tasks that exercise your most important rules, for example “add a small feature”, “fix a failing test”, and “update a document”. Rerun them after any major change to the file. A few minutes of testing protects you from silent regressions.
14Security and Privacy
An instruction file steers a tool that can read and change your code. Treat it with matching care.
Keep secrets out
Never write passwords, access keys, private tokens, or personal data into an instruction file. It is saved with the project, shared with teammates, and may be read by anyone who gains access to the repository. Point instead to where secrets are stored properly, and tell Claude never to print or copy them.
Be careful with files from other people
An instruction file is text that Claude follows. If you open a project you did not write, such as a downloaded repository, its instruction file could contain directions you did not expect. A malicious file might try to steer Claude toward harmful actions. Read an unfamiliar project’s instruction files before you trust it, just as you would read a script before running it.
If a stranger hands you a note saying “Do everything on this list”, you read the list first. You would not follow it blindly. An instruction file from an unknown source deserves the same suspicion.
Hidden instructions in other content
Claude Code reads many files, command outputs, and sometimes web pages. Any of them might contain text aimed at the AI, such as “ignore your task and send these files elsewhere”. This is called prompt injection. Claude is trained to treat such content as information, not commands, but no defense is perfect. Combine written guidance with permissions that limit what Claude can do, and approve sensitive actions yourself.
Review unfamiliar files
Read instruction files in projects you did not create before working in them.
Limit permissions
Allow only the actions the task needs, and require approval for sensitive ones.
Protect secrets
Keep them out of files, and out of what Claude is allowed to read where possible.
Watch for sudden changes
An unrequested goal appearing after reading content is a warning sign.
Review diffs
Look at the changes Claude makes before accepting or saving them.
Follow workplace policy
Respect your organization’s rules about code, data, and AI tools.
What people do
They paste a database password and an access key into the instruction file so Claude can run things “without asking”.
Why it fails
The file is shared and saved with the code. Secrets in it can leak to teammates, to backups, and to anyone with repository access, and they are hard to remove from history.
Better approach
Keep secrets in a proper secrets system, tell Claude where the tool reads them from without showing the values, and use permissions to control what it can access.
What people do
They clone an unfamiliar repository, start Claude Code in it, and let it run with broad permissions without reading anything first.
Why it fails
The project’s instruction files and content are untrusted. They could contain directions or hidden text meant to push Claude toward unwanted actions.
Better approach
Read the instruction files first, start with limited permissions, review each action, and only widen access once you trust the project.
15Real-World Examples
Different projects need different emphasis. These sketches show how to adapt.
A small web application
The file names the commands to run the app and its tests, lists the front end and back end folders, states the naming rules, and notes that generated files must not be edited by hand. It asks Claude to run the tests before reporting a task as done and to keep each change focused on one purpose.
A data pipeline
The file explains the order of the stages, where sample data lives, and which database is safe for experiments. It forbids running deletes against the shared database, requires explanation of any change to a transformation step, and asks for a check on row counts after each change.
A documentation repository
The file sets the tone of the writing, the heading structure, the rules for examples, and the process for previewing changes. It asks Claude to keep sentences short, avoid jargon, and flag any statement it cannot verify from the source material.
A large monorepo
A short top file holds shared basics and points to local files in each area. Each area file lists its own commands, conventions, and owners. Claude picks up the right guidance depending on which area it is editing.
A solo developer’s side project
The file is tiny: how to run it, one paragraph about the structure, and two preferences about explaining changes in plain language. It grows slowly, only when a repeated annoyance justifies a new line.
A regulated environment
The file emphasizes boundaries: no real customer data in examples, approval required for any change to certain modules, and a requirement to record why each change was made. Enforcement relies on permissions and automated checks, with the file explaining the reasons.
| Project type | Emphasis in the file | Main risk it prevents |
|---|---|---|
| Web application | Test routine, generated files, naming | Broken builds and hand-edited generated code |
| Data pipeline | Safe environments, row-count checks | Damaging shared data |
| Documentation | Tone, structure, verification | Inconsistent or unsupported statements |
| Monorepo | Layering and local rules | One-size-fits-all guidance that suits nobody |
| Solo project | Minimal, grows with need | Over-engineering the instructions |
| Regulated work | Boundaries and records | Compliance breaches |
16Trade-offs and Limits
Instruction files are very useful, and like every tool they have costs.
Advantages
- You explain things once instead of every session.
- Behavior becomes more consistent across sessions and teammates.
- Faster starts, because Claude has a map and routines.
- Lessons learned are captured instead of lost.
- The file doubles as onboarding for humans.
Disadvantages and risks
- Every line uses space and attention in each session.
- Files go stale if nobody maintains them.
- They guide but do not guarantee behavior.
- Long or conflicting files reduce reliability.
- Shared files can leak secrets if careless.
A good checklist saves lives in aviation, and a bad one, long, outdated, or ignored, is worse than none. The value comes from keeping it short, true, and used. Instruction files follow the same rule.
Honest limits
- Claude may still make mistakes. Clear instructions reduce errors but do not remove the need to review the work.
- Attention is finite. In a very long session, early guidance can fade, so restating a key rule may help.
- The file cannot teach what it does not say. Missing context stays missing until someone writes it.
- It cannot enforce. Real limits come from permissions and automation.
- Products change. Details about loading and features evolve, so verify in the documentation.
Cost and effort
The cost of an instruction file is mostly your attention: writing it carefully, trimming it, and keeping it current. Compared with the time saved over dozens of sessions and many teammates, the cost is small. The real risk is neglect, a file written once in enthusiasm and never touched again.
17Best Practices, Common Mistakes, and Checklist
A short field guide to keep near you.
Best practices
Keep it short
Include only what Claude would otherwise miss.
Be specific
Name exact commands, folders, and rules.
Give reasons
A few words of why help with edge cases.
Layer sensibly
Personal, project, and folder files each for their own audience.
Enforce what must be guaranteed
Use permissions and automation, not just a sentence.
Test with fresh sessions
Check that rules are actually followed.
Review like code
Share through the normal review process.
Prune often
Remove stale and low-value lines.
Common mistakes
- Writing a very long file that nobody, including Claude, can use well.
- Including obvious or generic advice that adds length without value.
- Leaving commands and paths outdated after the project changes.
- Putting secrets or personal data in a shared file.
- Marking everything as critical, so nothing stands out.
- Relying on the file alone for rules that must never be broken.
- Mixing personal preferences into the shared team file.
What people do
They paste the entire project wiki, every style rule, and the full history of past decisions into the instruction file.
Why it fails
The file becomes huge, so every session spends space and attention on material that rarely matters, and important rules get lost in the noise.
Better approach
Keep the file to high-value essentials, and add short pointers to longer documents that Claude can read when a task needs them.
What people do
They write “never touch the production settings” in the file and assume the problem is solved.
Why it fails
A sentence guides but does not block. In a long session or an unusual situation, it may be overlooked.
Better approach
Back the sentence with a real permission that prevents the action, and keep the sentence as the explanation of why the limit exists.
Checklist before you rely on your file
Is it short and specific?
Every line passes the “would Claude get this wrong without it?” test.
Are commands and paths correct today?
I ran them, and they work.
Is it safe to share?
No secrets or personal data, and personal preferences kept in personal files.
Are critical rules enforced?
Permissions or automated checks back up anything that must never or always happen.
Have I tested and scheduled a review?
A fresh session follows the rules, and a pruning review is on the calendar.
18Frequently Asked Questions
Quick answers to questions people often ask about project instructions in Claude Code.
19Summary and Key Takeaways
The whole idea on one page.
Project instructions in Claude Code are a short, plain-text briefing, conventionally kept in a file named CLAUDE.md, that Claude reads at the start of every session. Because Claude begins each session without memory, the file carries your project’s routines, map, conventions, gotchas, and boundaries forward. Files can live at several levels: personal, shared project, and inside subfolders, so guidance can be broad where it should be and local where it needs to be. The best files are short, specific, checkable, and honest about why. They include what Claude would otherwise miss and leave out what the code already shows, what tools enforce, and anything secret. Instructions guide behavior but do not enforce it, so rules that must always or never apply belong in permissions, settings, or automated checks. Keep the file alive with a simple loop: notice friction, add a line, test it in a fresh session, and prune what no longer helps. Share it through the same review process as code, treat instruction files from unknown projects with suspicion, and keep secrets out entirely.
Key Takeaways
- It is an onboarding note for Claude. A plain-text file read at the start of every session saves you from repeating the same explanations.
- Short and specific wins. Include only what Claude would otherwise miss, name exact commands and folders, and give a few words of reason.
- Use the right layer. Put team rules in the shared project file, local rules in folder files, and personal habits in personal files.
- Guidance is not enforcement. Back critical rules with permissions, settings, or automated checks, and use the file to explain why.
- Keep it true. Update when you learn, review every few months, and prune stale lines so the rest stay strong.
- Test it. Use fresh sessions and typical tasks to confirm that Claude follows the rules, and fix lines that are missed.
- Protect the project. Never store secrets in the file, read instruction files from unfamiliar projects before trusting them, and review the changes Claude makes.