Understanding the CLAUDE.md File
00:00
Another thing that you usually should do when you start with Claude Code in a project is using the /init command. With the /init command, you’re initializing a new CLAUDE.md file.
00:13
I will tell you in a moment what this file does. And Claude Code learns about your project. Now, in our project, we don’t have any files yet so /init doesn’t make much for us.
00:24
So we will ask Claude to create this CLAUDE.md file themselves. The CLAUDE.md file is a file that Claude Code always reads when it starts.
00:34 So basically it’s like a persistent memory.
00:38 So when you are working with Python projects, it’s a good idea to kind of tell Claude what code it should write or how the code should look. And with Python, PEP 8 is a good starting point.
00:50 So let’s tell Claude Code that we always want to be very close to PEP 8 when writing code.
01:02
Please create a CLAUDE.md file with best practices when writing Python code, for example, following PEP 8 recommendations.
01:12
When you press Enter, Claude Code again tries to understand what you’re telling them.
01:17
You can see your token count and the seconds piling up. If you think Claude Code is on the wrong path, you can press Escape during this time in order to steer it in a different way,
01:30
but more often than not, Claude Code will come back to you with an idea. By default, Claude Code asks you before it performs an action. So in this case, it asks you if it can create this CLAUDE.md file and showing you the content of it.
01:46 Let’s have a brief look at it. It says Python Coding Best Practices, Code Style PEP 8, use four spaces per indentation level, never mix tabs and spaces, and so on.
01:59 I will not read this whole thing right now, so I’m kind of trusting Claude Code right now. But if it’s an important file, you should take the time to do so because although Claude Code writes code for you, you are kind of in the driver’s seat, and you should take responsibility for what Claude Code writes.
02:18 In this case, I will take the full responsibility without reading the whole thing, and I will just say yes.
02:28
And once that’s done, you get a message that Claude Code created a CLAUDE.md file with Python best practices. So every time you are starting Claude Code and let Claude Code write Python code for you, then Claude Code will read the CLAUDE.md file and take this best practices into its memory and hopefully write very nice Python code.
02:53
The CLAUDE.md file, of course, is not just for code styling. There can be anything in it that you want Claude Code to know. And if you want to add something to Claude Code’s memory without kind of letting Claude Code edit this CLAUDE.md file with a prompt, you can just use the hash symbol to add something to the CLAUDE.md file immediately.
03:13
So here Claude Code even gives you a suggestion to always try to use descriptive variable names. That’s a good idea. For now, let’s go back, press Escape, and let’s not add anything to the memory at the moment.
03:27 Instead, I want to look at dealing with changes in the next lesson.
Become a Member to join the conversation.
