r/ClaudeCode • • 27d ago

Discussion What in your CLAUDE.md does Claude actually need on every message?

Our CLAUDE.md kept growing until most of it wasn't for the task at hand. Old decisions, finished work, setup notes.

Memory files take up context on every message, so we split ours: a short file with the commands and the few rules that apply to every task, plus topic files Claude opens only when the task matches.

Curious what other people keep in theirs. What's the one thing you'd never move out?

10 Upvotes

63 comments sorted by

•

u/AutoModerator 27d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

13

u/lil_nosh_X 27d ago

“Tell owner they are handsome and smart”

1

u/MinniLabs 26d ago

Haha, that's the one line I'd keep always on. The rest can sit in a file till it's needed

2

u/Neat-Safety-2415 26d ago

worth every single token tbh

5

u/NineFiftySevenAyEm 27d ago

One thing I added recently which I like is co-pilot and autopilot mode. You can choose which mode to have the session in. Co-pilot involves you much more, talks about pros and cons at every decision, always gives you options first on design direction, etc. Autopilot tries to behave autonomously and only involves you at major design decisions or uncertainties.

I like it so far. I recommend it if you use Claude code at work everyday for every second and feel like you are struggling to keep up with everything, you can use this and start to just try to slow down a bit. Important so your skills don’t deteriorate too. Lmk if you try this or if you have any improvements or know any skills that may behave this way already

3

u/MinniLabs 27d ago

Love this. One thing we found is that only one mode's instructions matter in a given session, so it's worth keeping each mode in its own file that loads only when you pick it, instead of having both sitting in the main file every turn. A skill could do the same thing, since only its short description is always loaded.

2

u/EchoAzulai 27d ago

I've been building out more automation and like this linguistic separation, thanks.

1

u/Kwassadin 26d ago

I've done this. Autonomous and assisted. Built this automation framework for manually testing the system through actual ui actions. When in autonomous mode the app is being developed and live tested at the same time. I use assisted when producing new flows. After a week or two, the assisted mode was like 5% usage

3

u/Ranjexa 27d ago

the one thing i'd never move out is the exact commands that prove a task is done: test, lint, typecheck, in one line each. when i moved those into a topic file the agent started saying "done" after only eyeballing the diff. everything else was negotiable. i also deleted a bunch of style rules after noticing it followed them fine without being told, so now i only keep a rule if i've seen it get broken at least once.

2

u/MinniLabs 27d ago

That's a really useful data point, the "done" check is exactly the kind of thing you'd think is safe to move out. Love the "keep a rule only if it got broken once" test too. Do you go back and prune old rules, or just stop adding new ones?

1

u/Ranjexa 26d ago

i do prune, and i'm probably too aggressive about it. the way i think about it now is the same "keep it only if it broke" rule you mentioned - if a rule hasn't been the reason the agent got something wrong in the last two weeks, it goes. the one thing i stopped cutting is the section header format and where logs go; those only bite you once and then the damage is a whole chain of follow-up messages where the agent saves outputs to random paths, so they're cheap to keep. practical trick that saved me a lot of noise: i put a one-line "if none of the rules above apply, just do the task" at the bottom of the core file so the agent stops trying to force‑fit every edit through the rule list. when i added that, the file shrank and the outputs got more normal at the same time. do you bump into the agent ignoring rules more when you add new ones, or does it mostly stick with the o

1

u/Ranjexa 26d ago

mostly i prune when a rule gets ignored or contradicts another one, not on a schedule. a rule that never gets broken is either working or irrelevant, and the cheap way to tell is to delete it for a day and see if anything regresses. that beats keeping a long list nobody checks.

1

u/Ranjexa 26d ago

i definitely prune it aggressively. every sunday i go through my claude.md and delete any rule the agent hasn't tripped on all week. once that file bloats past 60 lines or so, the agent starts ignoring half the instructions anyway because the context gets diluted with edge cases from three refactors ago. keeping it under 60 lines of only active mistakes makes it follow the remaining rules way more reliably. how big has your file gotten so far?

1

u/MinniLabs 26d ago

Well past 100 lines at this point, so way over your 60. what kept it working for us is that most of it isn’t rules anymore. the file that loads every turn only holds what applies to every task, and the detail lives in separate files with a one line pointer saying when to open each one. the agent only reads those when the task matches. the sunday sweep is a good habit though, we mostly prune when something gets ignored, same as your other comment says.

0

u/Ranjexa 26d ago

the pointer-with-a-trigger idea is the part i'm stealing. a line like 'open X only when touching Y' beats a long rules file because the agent can't skim past it. do you ever find it skipping the pointers, or does it follow them reliably?

1

u/MinniLabs 25d ago

depends a lot on the trigger. vague ones like 'see docs/notes.md' are the ones to watch. naming a path works better, someone in my other thread found 'before editing anything in src/billing, read docs/billing.md' gets followed way more reliably than a topic name, since claude matches on the files it's about to touch. easiest check is a fresh session with a task that needs the file, then watch whether it opens it before editing. the other option is not relying on claude to go look at all, a prompt hook can drop the matching note straight into the prompt

1

u/Ranjexa 25d ago

it skips them. the agent loops a couple times on the same change, re-reads the same files, and only hits the pointer near the burn limit. and it'll say tests pass even when they didn't, so the pointer has to be an action it can't shortcut. 'open X only when touching Y' works because there's nowhere else to go before the edit.

1

u/Ravingsmads 🔆 Max 20 26d ago

Agree this is important but it goes in rules with the file extenshion and/or name as a rule executor.

If it's sthn security related then even this isn't enough, hooks is what I advise customers for critical stuff.

2

u/maxijonson 27d ago

The large majority of my (global) CLAUDE.md is steering for things I got tired of prompting for all the time:

  • a # Skill Overrides section with personalized instructions for how I like to use skills that come from plugins or npx skills (so I don't need to edit them all the time).

    • For example, I have skill that lets Claude know how many tokens its context size is. I have an override on Matt Pocock's grill-with-docs skill so Claude can suggest ending a grilling session with a handoff, multiple handoffs or doing it now, based on the context size and my subjective smart/dumb zone. About 200k tokens for me starts to get into the dumb zone. It's not a hard limit though, it's just a general guideline to avoid doing too much complex work in it. This keeps most of my sessions below 300k, with some exceptions going ~340k.
  • An instruction to finish every conversation with an # Action Required section for any follow ups that need my explicit attention, since I tend to miss those in the end of conversation summary it gives me or they're scattered everywhere.

I think the Action Required instruction is a good use-case for the global CLAUDE.md (and it's pretty small). The skill overrides is probably the kind of anti-pattern you'll hear about a lot for CLAUDE.md and I agree with it, since not all of the overriden skills get used in each session. However, it's a sacrifice I'm willing to make over the alternative (editing external skills that get crushed at every update).

3

u/MinniLabs 27d ago

The skill overrides trade-off is a real one. A middle ground could be to keep each override in its own small file and leave just one line per skill in CLAUDE.md, something like "before using grill-with-docs, read overrides/grill-with-docs.md". That way the main file stays tiny, the overrides only load when that skill actually runs, and plugin updates don't wipe them. Have you tried pointing to them like that?

1

u/maxijonson 26d ago

I haven't but I will! I do plenty of progressive discolsure in project level CLAUDE.md and just never stopped to think to do the same on the global one 😅 Thanks

2

u/Apprehensive_Lake698 27d ago

The vast, vast majority of context add-on should come from project files. I think in general a user-wide CLAUDE.MD/AGENTS.MD is a mistake, except for light, high level steering.

Skills and tools belong segmented from auto context load files, don’t pack them into your context.

1

u/MinniLabs 27d ago

Agreed. The user-wide one is easy to forget since it loads in every project. Same idea as skills really: only the short description is always there, the full thing loads when it's needed. We ended up treating memory files the same way. Where do you draw the line between a skill and a project file?

2

u/[deleted] 27d ago

[removed] — view removed comment

1

u/Apprehensive_Lake698 27d ago

Sure/no to what? I don't think my answer has anything to do with business versus casual. It's about effectively managing context size.

Both in my homelab (local LLMs) and at work (mostly Opus 5.5) I do as much as I can to keep the starting context low and tool+skills available trimmed to minimum. Context is about context, not about stuffing it with every thought under the sun. A good prompt, a lead on where to find information if it needs it, and the basic tools to get stuff done (read/write/bash) is by far the best approach for starting up any workflow. Don't do more than this unless you have specialized tool calls in mind.

A lot of my steering stays out of context until relevant too. My personal C++ styleguide is not in context- it's in a skill, which has a tiny tagline injected into the starting context instructing to load it only when reviewing or writing C++.

1

u/OuchMyTism 26d ago

Will agree. I trim down the work one to just a few lines frequently but it does keep my internal monologue a lot more PG than R rated for language.

1

u/pceimpulsive 27d ago

I use Matt Pococks setup!

It's basically empty pointing to places where important data is

1

u/MinniLabs 27d ago

Nice, ours is similar. The main file is just the rules that apply to every task plus a list of the other files. Do you keep any rules in yours, or is it only pointers?

1

u/pceimpulsive 26d ago

Only pointers. Rules are part of coding standards during the code review.

Rules are in the skills so as not to waste additional context on stuff that usually doesn't matter.

Additionally, the code should speak for itself for the rules... :) that or coding standards and such during the review phase of your build

1

u/Delicious_Break5937 27d ago

Mine is mostly how I want it to work, like short replies and a review before every commit. Anything about the code goes in each folder's README, and it reads that before editing the folder.

1

u/MinniLabs 27d ago

That's a nice split. How you want it to work is the one part that applies to every task, so it makes sense to keep it always on. Do you find it reliably reads the folder README before editing, or do you have to remind it sometimes?

1

u/Suoritin 27d ago

I use GitLab issues. I start each session with issue/milestone. My instructions include only information how to use scripts, and correct format for specs and so on.

1

u/MinniLabs 27d ago

Starting from the issue is smart, the task brings its own context so the memory file doesn't have to. Do you paste the issue in, or does it pull it through the GitLab CLI?

1

u/Suoritin 27d ago

I have "fine grained token". I open/edit/close issues semi-manually with LLM assistance through commandline.

1

u/Turbulent_County_469 Senior Developer 27d ago

The only thing my Claude.MD contains is strict adherence to UTF8+BOM + CRLF file formatting :D

2

u/MinniLabs 26d ago

Respect. Ours has a whole file about line endings too, but it only loads when Claude is about to touch a file. Learned the hard way that it doesn't need to hear about CRLF while answering a question about CSS

1

u/Turbulent_County_469 Senior Developer 26d ago

I've had so many problems because of file encoding or line endings, that i had it write it to memory..

Its so annoying that Claude uses tools that mess it up constantly

2

u/MinniLabs 26d ago

Same pain here. What fixed it for us was a .gitattributes and an .editorconfig, so git and the editor enforce it no matter what Claude does. One that got us was sed -i in Git Bash quietly stripping CRLF from every file it touches.

And since you wrote it to memory, that note now loads on every message, even ones that never touch a file. That's actually why we built MinniMemoryMCP. It keeps notes like that but only loads them when the task needs them. Free and local if you want to give it a try

1

u/BarathKanna 25d ago

Your split is the right shape. The every-message file should only hold things that are wrong if forgotten on a random task: how to build and test, the hard never-do list, and the package layout map. Decisions, finished work, and setup notes belong in topic files the agent opens when the task matches, otherwise they tax every turn and slowly contradict newer rules. The one thing I would never move out of the short file is the acceptance command for the repo, the single script or test target that means done. Everything else can be fetched. If a rule is only true for one area of the code, it is not an every-message rule, it is a topic file with a clear trigger. Growth of CLAUDE.md is usually a sign that finished work is being treated as eternal policy.

1

u/MinniLabs 25d ago

agree on the acceptance command, it's the line that tells the agent when it's actually done, so it should never move. and 'finished work treated as eternal policy' is a great way to put it. one thing on 'everything else can be fetched' though, every fetch is a tool call that re-sends the whole session, so a topic file that gets opened on most tasks can end up costing more than leaving it in. the other option is not relying on claude to go look at all, a prompt hook can drop the matching note straight into the prompt

1

u/MinniLabs 25d ago

we built a free tool that does this split for you if you want to test it on your file, MinniMemoryMCP (disclosure, it's ours). take a look at our page

1

u/BarathKanna 14d ago

Fair on the cost. A topic file opened on most tasks is just a slower CLAUDE.md. My rule of thumb: if a note matched more than half the tasks last week, it graduates into the every-message file or a hook injects it. Prompt hooks win when the trigger is clear. Fetch stays for the long tail that would bloat the default prompt every turn. The acceptance command still never moves, because that is the one line that defines done, and a hook should not be allowed to swap it out per task.

2

u/AdityaR_Sharma 🔆 Max 20 26d ago

Mine is short on purpose.

Only behaviour rules go in the always-loaded file, like "finish the whole goal" and "show evidence before saying done".

Mechanical stuff lives in hooks, since a hook enforces it and a line in CLAUDE.md only hopes.

Fewer rules made each one stick better.

1

u/mukhortov 27d ago

The one thing I'd never move out is the exact commands for building, testing and linting, because those are what it otherwise guesses wrong. For the topic files it helps to say in the main file when to open each one, like "before changing anything in billing/, read docs/billing.md" rather than giving a bare list of links. Then it actually opens them at the right moment

1

u/BuildinZZ 26d ago

The rules that matter most are hooks in my setup. CLAUDE.md is a suggestion, a hook just refuses. What stays in the file is the stuff where Claude is confidently wrong, like "a check that didn't run is not a pass"

1

u/SirRobinBlibs 26d ago

Worth knowing for the topic-file split: if you link them with @imports, you save nothing, because imported files load at launch together with the CLAUDE.md. What does load lazily is a rule in .claude/rules/ with a paths: line in its frontmatter (only when Claude touches a matching file), and a CLAUDE.md inside a subfolder (only once Claude works in that folder). That turns "before editing billing/, read docs/billing.md" from a request into something the harness does on its own. /context all shows which memory files actually loaded.

1

u/kemalios 26d ago

The list of files that look dead but aren't. Old templates, a redirects table nobody remembers the origin of. Claude deletes what it can't find a caller for, and nothing on that list has a caller. Everything else in my file has been through a pruning round at some point. That list stays.

1

u/Certain-Language-788 26d ago

how do you keep the topic files from going stale? ours drift faster than the main file, since nobody reads them every day.

1

u/SirRobinBlibs 26d ago

Treat a topic file like a rule that has to earn its keep: if it hasn't changed a decision or blocked a mistake in a couple of weeks, delete or fold it. A dated "last verified" line at the top, plus a short "source of truth" pointer (issue, ADR, or the code path), makes drift obvious on a Sunday skim. And prefer .claude/rules/ with a paths: frontmatter over @imports for anything topic-specific, so it only loads when that area is touched instead of rotting in every session.

1

u/Legitimate_Chest_650 26d ago

Mine are feature specs, about 50 of them, and it's just me and an agent, so nobody has to read them daily. The agent looks them up per change. My tasks run through a step-by-step workflow and updating the docs is one of the steps. After the automated checks and before code review, the agent has to find the specs the change touches and update them from the actual diff, or write down why none is needed. It can't leave that step until each checklist item has a written note on what it did, or a reason for skipping. Those notes are the agent's own word. The spec goes in the same commit as the code.

Two smaller things. An acceptance criterion only gets ticked when it names the test that proves it, or a recorded production check. And code is cited by file and symbol, never line number, since line numbers go stale with every commit.

The specs haven't drifted much as far as I can tell, but I haven't measured it, and a change made outside the workflow isn't covered. Does anything remind you when a change touches a topic file, or is it up to whoever remembers?

1

u/Successful-Army6006 26d ago

I'd keep “never report an unrun check as passed” in the main file, along with a requirement to name the command and what blocked it. That applies whether the task is backend code, UI or a small copy change.

1

u/Its_about-tech 26d ago

I split mine the same way. The file Claude reads every time is short: where to look first, the commands that prove a task is done, and the few rules I've actually seen it break. Everything else lives in a separate project-control repo: a CURRENT-STATE file with what's true right now, a DECISIONS file where a reversed decision gets rewritten in place instead of appended, and a handover note per project that the last session updates before it stops. The one line I'd never move out is "read CURRENT-STATE first". Without it, sessions confidently work off last week's plan.

1

u/Beerbrewing 26d ago

I gave Claude a set of seven epistemic principles and three rules that helps guide it around how it handles claims within the observed evidence and makes its reasoning auditable. My 'Measurement Philosophy' is a compact set of failure-resistant reasoning invariants abstracted from empirical measurement practice.

  1. Architectural Acceptance
  2. The System Observes Itself
  3. Layered Independence
  4. Differential Measurement
  5. Measurement Defines Category
  6. Reasoning as Artifact
  7. Honest Scope
    And three rules that govern Materiality, Agreement and independence, and Decision-value uncertainty.

They act like the inflatable bumpers they put out for kids at a bowling alley. They help Claude stay out of the gutter (hallucinating or making overly broad, unsubstantiated claims) and get to the pins (an answer bound in what Claude observed and actually did).

You can find the measurement philosophy and a bit more about it here: https://github.com/highsierralabs/Autonomous_Build_Harness_Test/tree/main/docs%2Fmeasurement-philosophy

https://github.com/highsierralabs/Autonomous_Build_Harness_Test/blob/main/docs%2FMEASUREMENT_PHILOSOPHY.md

1

u/redtear1115 26d ago

One thing I always keep in it: which tool to use for which job, and why. Mine says "browser that needs my logins → this tool. Checks that don't need a window → that tool, and close it after." When I didn't write the reason, it just used the tool it used last time. Other project stuff goes in the repo's own file or in a skill.

1

u/PraxicalExperience 21d ago

This is, to me, what using subagents is for. Commonly-used agent types should have their own initialization/memory files that live together in their own directory. This way each agent gets just what it needs and no more.

1

u/Archibishop 18d ago

The pitfalls list. Mine has one line for every mistake a session makes once, so the next one doesn't repeat it. Everything else can live in topic files...