Stop Repeating Yourself: Put Project Context in CLAUDE.md
As we saw in the insights report from last week, there are usually a few suggestions on how to improve our CLAUDE.md file. But if you never used a CLAUDE.md file that may not help you enough. In this post we take a close look at this helpful file and how we can use it to our advantage.
The two CLAUDE.md files
There are two places we can put a CLAUDE.md file and it is important to keep them apart.
The first location is in the project folder. Here the CLAUDE.md file goes into the top folder (next to the .git folder) and is only about this one project. In this file we put all the instructions that are specific to this project.
Inside the .claude folder for the user (C:\Users\USERNAME\.claude) we can create a CLAUDE.md file that Claude Code will read for all projects on this computer. Therefore, make sure that this global file only contains things that are true for every project you do. That is especially hard if you use different programming languages, technology stacks and project management methods. Should you have such a large variety of projects you may skip this file entirely and only focus on project specific CLAUDE.md files.
Keep it short
Claude Code will read the CLAUDE.md file in every session and keep it inside its working memory. Therefore, make sure that this file is to the point and does not waste important tokens.
Important: While CLAUDE.md will clutter your context, there is no guarantee that Claude will always follow it. If you depend on the run of certain steps, better put them into hooks.
Create the first CLAUDE.md file
When we run
Claude Code will analyse our project and create a basic CLAUDE.md file for our project. How useful that is depends on how much code you have. If you have an empty folder, then skip that and try it with a project that has code.
For a minimal project I created in Visual Studio I ended up with this CLAUDE.md file:
As we can see, there is not much useful content – because we lack anything specific that Claude could find.
If we have a large project with a lot of code, we can get something like this:
Here we have a much better example with clear insights that not only show us what this project is all about but also helps Claude Code to find its way.
Build on top of an existing CLAUDE.md
When you have a larger project and can use /init to generate a useful CLAUDE.md file, you can take it and copy it to your fresh project. Do not forget to modify it so that it matches the goal you have with this new project.
If you do not have a good starting point, go to GitHub and search for CLAUDE.md. When I tried that, I got over a million results. Filter for languages to better match what you are looking for. Just be aware that there will be so many files to choose from that it will be overwhelming.
Helpful resources
Here are a few helpful resources that you can use to write your own CLAUDE.md file:
- Awesome Claude Code offers inside the resources folder a nice selection of templates for the
CLAUDE.mdfile. It does not offer a template for every technology stack, but feel free to copy what you find useful. - HumanLayer wrote a helpful blog post that offers ideas on how to optimise your
CLAUDE.mdfile. - Dometrain offers us a nice introduction with samples for .Net.
- Bijit Ghosh wrote a great list of things to put into
CLAUDE.mdand what should stay outside.
Next
Thanks to the /init command we can create a first CLAUDE.md file without much effort. As long as the project is not empty or only contains a template project, Claude can build something useful. From there we can add and change until it fits our needs.
Next week we go one step further and use Claude to improve our CLAUDE.md file for us.