Назад к подкастамClaude
Claude Code 101
Файл CLAUDE.md
[Music starts]
[Music starts]
One of the most useful parts of Claude Code is the claude.md file.
Одна из наиболее полезных частей Claude Code — это файл CLAUDE.md.
It gives Claude Code persistent memory about your project.
Он дает Claude Code постоянную память о вашем проекте.
When you open up Claude Code without a claude.md file, it's like it has to start fresh every single time.
Когда вы открываете Claude Code без файла CLAUDE.md, это как будто ему приходится начинать с нуля.
It has to re-explore your codebase, understand what dependencies are needed and the features that are already implemented.
Ему нужно заново исследовать вашу кодовую базу, понять, какие зависимости нужны,
Sometimes it has to make assumptions which makes it harder for us to steer Claude in the right direction.
Иногда приходится делать предположения, что затрудняет для нас управление Claude в правильном направлении.
But that's where claude.md comes in.
Но именно здесь на помощь приходит CLAUDE.md.
It's a markdown file that you add to the root of your project and Claude Code reads it automatically every time you start a session.
Это файл Markdown, который вы добавляете в корень проекта, и Claude Code читает его каждый раз.
It's like an onboarding script for your codebase.
Это как скрипт адаптации для вашей кодовой базы.
Simply put, the contents of claude.md file are appended to your own prompt. You can run the /init command which will make Claude generate one based off of your codebase.
Проще говоря, содержимое файла CLAUDE.md добавляется к вашему собственному промпту. Считайте его——
So let's have a look at one.
Давайте посмотрим на пример.
This is a Next.js 15 app using the app router, Tailwind, and Drizzle ORM.
Это приложение Next.js 15 с использованием App Router, Tailwind и Drizzle ORM.
Commands: dev server, run tests, lint.
Команды: сервер разработки, запуск тестов, lint.
Code style: use two space indentation, prefer named exports, all API routes go in app/api, use server actions instead of API routes where possible.
Стиль кода: использовать отступ в два пробела, предпочитать именованные экспорты, все API-маршруты идут в——
And it's pretty straightforward.
И это довольно просто.
Now, if I ask Claude Code to create a React component, it knows how to style it with Tailwind or any other CSS framework that I'm using.
Теперь, если я прошу Claude Code создать React-компонент, он с самого начала знает, как его стилизовать.
We can see that Claude does a better job at doing its job right off the bat versus having to understand where everything is at first.
Мы видим, что Claude справляется лучше с самого начала по сравнению с прежними сессиями.
And before you ask, the answer is yes.
И прежде чем вы спросите, ответ — да.
You share this in your version control for your team to use.
Вы делитесь этим в системе контроля версий для использования вашей командой.
But there's actually a hierarchy of memory files depending on who it's for.
Но на самом деле существует иерархия файлов памяти в зависимости от того, для кого они предназначены.
So first you have your project-level claude.md that lives in the root directory of your project.
Сначала у вас есть CLAUDE.md на уровне проекта, который находится в корневом каталоге.
You have a user-level claude.md that lives in your configuration folder.
У вас есть CLAUDE.md на уровне пользователя, который находится в вашей папке конфигурации.
This one is just for you and goes across all your projects.
Этот предназначен только для вас и применяется ко всем вашим проектам.
So put your personal preferences here, like how you write code comments.
Разместите здесь свои личные предпочтения, например, как вы пишете комментарии к коду.
First, if you have to correct Claude to do something, like always use server actions instead of API routes, then explicitly ask Claude to save this to memory so that when you come back to this project, it will know every single time.
Во-первых, если вам нужно скорректировать Claude, чтобы делать что-то определенное, например всегда использовать Server Actions——
Second, if you have docs in your project that you want Claude to reference, just use the @ symbol with the file path.
Во-вторых, если у вас в проекте есть документация, которую вы хотите, чтобы Claude использовал, просто——
And third is we recommend you start off a project without a claude.md file so you can see where you have to constantly course correct the model.
В-третьих, мы рекомендуем начать проект без файла CLAUDE.md, чтобы вы могли——
This keeps your claude.md file compact and contains only the necessary information that Claude can work with.
Это сохраняет ваш файл CLAUDE.md компактным и содержит только необходимую информацию.
[Music transition]
[Music transition]
The difference between a frustrating Claude Code session and a productive one comes down to the context, and the claude.md file's how you provide that context.
Разница между разочаровывающей и продуктивной сессией Claude Code часто определяется вашим файлом CLAUDE.md.
Start with your stack, your preferences, and then commands, and just build from there as you go.
Начните со своего стека, своих предпочтений, затем команд, и развивайте это дальше.