1
0
Fork 0
claude-code-claude-md/exercises/01-write-your-first.md
2026-03-30 10:38:01 +02:00

124 lines
3.6 KiB
Markdown

# Exercise 01: Write Your First CLAUDE.md
**Concept:** CLAUDE.md (CC-010)
**Level:** Basic
**Time:** ~10 minutes
---
## Objective
Write a CLAUDE.md for a real project you own. By the end of this exercise,
Claude will know who you are, what the project does, and how you want it
to behave -- automatically, every session.
This is your first hands-on contact with CLAUDE.md. The only requirement
is that you have a project directory with a few files in it.
---
## Before You Start
Confirm you have:
- [ ] Claude Code installed (`claude --version` prints a version)
- [ ] A project directory you want to write a CLAUDE.md for
- [ ] Claude Code open in that project directory
This exercise works best in your own project. If you do not have one
handy, open Claude Code in any directory that has at least a few files.
---
## Instructions
**Step 1:** Navigate to your project and open Claude Code.
```bash
cd /path/to/your-project
claude
```
Confirm there is no CLAUDE.md there yet:
```bash
ls CLAUDE.md
```
Expected output: `ls: CLAUDE.md: No such file or directory`
If a CLAUDE.md already exists, pick a different project for this exercise
or rename the existing one temporarily (`mv CLAUDE.md CLAUDE.md.bak`).
**Step 2:** Think about three things before you run anything.
- Who you are and what you care about when working on this project
- What the project does in one sentence
- Two or three rules that would save time if Claude knew them up front
(examples: "always use TypeScript", "never modify files in dist/", "prefer short functions")
You do not need to write these down. Just have them in mind.
**Step 3:** Paste this prompt into Claude Code:
```
Look at this project. Read the files here, then write a CLAUDE.md for it.
The CLAUDE.md should include:
1. What this project is (one short paragraph, 2-3 sentences max)
2. How to work on it (language, framework, any tools)
3. Three specific rules I want you to follow in every session
For rule 3, use these rules I care about:
- [replace this with your first rule, e.g. "Never use var, always use const or let"]
- [replace this with your second rule, e.g. "All functions must have a JSDoc comment"]
- [replace this with your third rule, e.g. "Do not modify package.json without asking first"]
Keep it under 60 lines. No headers longer than one line. Plain and direct.
```
Replace the three placeholder rules with your own before pasting.
**Step 4:** Review what Claude writes and ask for one change.
Read the CLAUDE.md Claude produced. Find one thing that is off, vague, or
missing, then ask Claude to fix it:
```
Change [the part that is wrong] to [what it should say].
```
This is a normal part of the process. CLAUDE.md files are written with
Claude, not entirely by it.
---
## Expected Output
After completing the steps above, you should see:
- A `CLAUDE.md` file in your project root
- It has a project description (not generic -- specific to your project)
- It has your three rules stated clearly
- It is under 60 lines total
If Claude produced something generic or padded, ask it to be more specific
and shorter. Generic CLAUDE.md files provide almost no value.
---
## What You Learned
- **CLAUDE.md is a briefing, not a manual:** Give Claude the context it needs
to behave like a new colleague who already knows your project
- **It is auto-loaded every session:** You never have to paste it in or say
"remember, we use TypeScript" again
- **Write it with Claude, not for Claude:** Use Claude to read the project
and draft the file, then you correct and sharpen it
---
## Next
Ready to see how CLAUDE.md files stack on top of each other? Move to
[Exercise 02: Hierarchy in Action](./02-hierarchy-in-action.md).