Title: How to Write a CLAUDE.md File for Claude Code – Real Python
Open Graph Title: How to Write a CLAUDE.md File for Claude Code – Real Python
Description: Learn how to write a CLAUDE.md file for Claude Code, with global, project, and local examples that capture your Python commands and conventions.
Open Graph Description: Learn how to write a CLAUDE.md file for Claude Code, with global, project, and local examples that capture your Python commands and conventions.
Mail addresses
?subject=Python article for you&body=How to Write a CLAUDE.md File for Claude Code on Real Python
https://realpython.com/python-claude-md/
Opengraph URL: https://realpython.com/python-claude-md/
X: @realpython
Domain: realpython.com
{
"@context": "http://schema.org",
"@type": "Article",
"headline": "How to Write a CLAUDE.md File for Claude Code",
"image": {
"@type": "ImageObject",
"url": "https://files.realpython.com/media/How-to-Write-a-CLAUDE.md-File-for-Claude-Code_Watermarked.ea7aeffdb75e.jpg",
"width": 1920,
"height": 1080
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://realpython.com/python-claude-md/",
"lastReviewed": "2026-10-25",
"author": {
"@type": "Person",
"name": "Ben Batman",
"image": "https://realpython.com/cdn-cgi/image/width=1920,height=1920,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/real-python-logo-square.28474fda9228.png",
"url": "https://realpython.com/team/bbatman/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
"reviewedBy": [
{
"@type": "Person",
"name": "Aldren Santos",
"image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
"url": "https://realpython.com/team/asantos/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Brenda Weleschuk",
"image": "https://realpython.com/cdn-cgi/image/width=320,height=320,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_3324_1.50b309355fc1.jpg",
"url": "https://realpython.com/team/bweleschuk/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Bartosz Zaczy\u0144ski",
"image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
"url": "https://realpython.com/team/bzaczynski/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Martin Breuss",
"image": "https://realpython.com/cdn-cgi/image/width=456,height=456,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/martin_breuss_python_square.efb2b07faf9f.jpg",
"url": "https://realpython.com/team/mbreuss/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
}
]
},
"datePublished": "2026-07-15T14:00:00+00:00",
"dateModified": "2026-10-25T18:44:02.720705+00:00",
"publisher": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": {
"@type": "ImageObject",
"url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
"width": 512,
"height": 512
},
"description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
"slogan": "Become a Python Expert",
"email": "info@realpython.com",
"sameAs": [
"https://github.com/realpython",
"https://www.youtube.com/realpython",
"https://twitter.com/realpython",
"https://x.com/realpython",
"https://www.linkedin.com/company/realpython-com/",
"https://www.facebook.com/learnrealpython",
"https://www.instagram.com/realpython",
"https://www.tiktok.com/@realpython.com"
]
},
"author": {
"@type": "Person",
"name": "Ben Batman",
"image": "https://realpython.com/cdn-cgi/image/width=1920,height=1920,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/real-python-logo-square.28474fda9228.png",
"url": "https://realpython.com/team/bbatman/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
"description": "Learn how to write a CLAUDE.md file for Claude Code, with global, project, and local examples that capture your Python commands and conventions.",
"hasPart": {
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is a CLAUDE.md file?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eA \u003ccode\u003eCLAUDE.md\u003c/code\u003e file gives \u003ca href=\"/ref/ai-coding-tools/claude-code/\" class=\"ref-link\"\u003eClaude Code\u003c/a\u003e persistent context about your workflow, project commands, and coding preferences. Claude Code loads it automatically when you start a session, so you don\u0026rsquo;t have to repeat the same corrections each time.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "Where should I put my CLAUDE.md file?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eGlobal instructions go in \u003ccode\u003e~/.claude/CLAUDE.md\u003c/code\u003e, while project-specific instructions belong in a \u003ccode\u003eCLAUDE.md\u003c/code\u003e at the root of your repository. Claude Code also recognizes \u003ccode\u003e./.claude/CLAUDE.md\u003c/code\u003e and \u003ccode\u003e./CLAUDE.local.md\u003c/code\u003e for additional scopes.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "What\u2019s the difference between CLAUDE.md and CLAUDE.local.md?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eA project\u0026rsquo;s \u003ccode\u003eCLAUDE.md\u003c/code\u003e is checked into \u003ca href=\"https://realpython.com/how-to-use-git/\"\u003eversion control\u003c/a\u003e and shared with your team, while \u003ccode\u003eCLAUDE.local.md\u003c/code\u003e holds personal or machine-specific notes that stay out of the repo. Use \u003ccode\u003eCLAUDE.local.md\u003c/code\u003e when your preferences would conflict with shared team rules.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "Should I commit CLAUDE.md to version control?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eYes, commit your project-level \u003ccode\u003eCLAUDE.md\u003c/code\u003e so teammates and future sessions get the same guidance. Keep \u003ccode\u003eCLAUDE.local.md\u003c/code\u003e in \u003ccode\u003e.gitignore\u003c/code\u003e because it holds personal notes that shouldn\u0026rsquo;t be shared.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "How do I check if Claude Code loaded my CLAUDE.md file?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eRun the \u003ccode\u003e/memory\u003c/code\u003e slash command inside Claude Code to see every loaded instruction file. If a file doesn\u0026rsquo;t appear, confirm the filename and that it lives in a supported location such as \u003ccode\u003e./CLAUDE.md\u003c/code\u003e or \u003ccode\u003e~/.claude/CLAUDE.md\u003c/code\u003e.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "What\u2019s the difference between CLAUDE.md and AGENTS.md?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003e\u003ccode\u003eAGENTS.md\u003c/code\u003e is an open format that many coding \u003ca href=\"/ref/ai-coding-glossary/agent/\" class=\"ref-link\"\u003eagents\u003c/a\u003e read, while \u003ccode\u003eCLAUDE.md\u003c/code\u003e is specific to Claude Code. If your repo already has an \u003ccode\u003eAGENTS.md\u003c/code\u003e, you can import it from \u003ccode\u003eCLAUDE.md\u003c/code\u003e with \u003ccode\u003e@AGENTS.md\u003c/code\u003e and add Claude-specific guidance on top.\u003c/p\u003e"
}
}
]
}
}
| author | Real Python |
| theme-color | #18354c |
| color-scheme | light dark |
| twitter:card | summary_large_image |
| twitter:image | https://files.realpython.com/media/How-to-Write-a-CLAUDE.md-File-for-Claude-Code_Watermarked.ea7aeffdb75e.jpg |
| og:image | https://files.realpython.com/media/How-to-Write-a-CLAUDE.md-File-for-Claude-Code_Watermarked.ea7aeffdb75e.jpg |
| twitter:creator | @realpython |
| og:type | article |
| og:site_name | Real Python |
| apple-mobile-web-app-title | Real Python |
Links:
Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover
Robots: max-image-preview:large