Learn Claude Code by Building DevPulse · Chapter 3

Project rules Claude remembers

Every new Claude Code session starts knowing nothing about your decisions, so how do you stop explaining them again? By the end of this chapter, DevPulse has a CLAUDE.md with our rules, Claude remembers a preference of yours, and a new session follows both first time.

One sitting~8 min read, ~20 min to build along
You start fromchapter 2's DevPulse: a server and two views
You buildCLAUDE.md with our rules, and an edit button
Chapter 3 of 15Claude remembers
Goes with Episode 3"Why does Claude Code forget my decisions?". The video is being made. This page teaches the same steps, at your own pace.
In a hurry?Jump to the quick reference: every command and key in this chapter, what it does, and when to use it.
Every prompt, ready to copyThis chapter's prompts and commands, each with a Copy button. Type them yourself first; copy if you are stuck or behind.
Where you areDevPulse has a small server, a tasks file and two views, from chapter 2. The server runs in your second terminal tab.

A new session starts with no memory

In chapter 2 we agreed a lot with Claude. The server uses only Python's standard library. Times show as "1 h 30 min". Tests run with one command.

Now close Claude Code and start it again. Ask for something small.

Type this, one line at a time/exit claude Add an edit button to each task, to change its title, tag and minutes.
A new session: Add an edit button to each task. Searched for 2 patterns, read 2 files. I'll refactor validation into reusable field helpers and let PATCH accept any of done/title/tag/minutes.
It searches and reads the files again, from the start. Everything we agreed in chapter 2 is gone.

Say a new colleague joins every morning, a different one each day. Each one is clever. None of them was there yesterday.

The question for this chapter

How do you write your decisions down once, so every new session knows them before it starts?

Stop it, and go back

We do not want this edit yet. Press Esc to stop. In our recording, Claude had already changed server.py by then.

So press Esc twice, quickly. A list of your messages appears. Pick the message before the edit request.

Rewind: Confirm you want to restore to the point before you sent this message: Add an edit button to each task. The code will be restored +11 -34 in server.py. Options: 1. Restore code and conversation, 2. Restore conversation, 3. Restore code, 4. Summarize from here, 5. Summarize up to here.
It shows what it will undo: 11 lines added and 34 removed in server.py. Choose Restore code and conversation.

The file is back exactly as it was. This is called rewind. Chapter 4 is all about undoing, so we only use it here.

Write the project down with /init

Claude Code reads one file at the start of every session: CLAUDE.md, in your project folder. Think of it as the note you leave for tomorrow's colleague. To write the first version, type one command.

Type this into Claude Code/init
I created CLAUDE.md in the project root. It covers: Commands, how to run the server and the tests; Architecture; Testing. I only read the first 80 lines of index.html, so the frontend description is thin.
Claude reads the project and writes CLAUDE.md: how to run it, how it is built, how it is tested. It also says what it skipped.

Add the rules only you know

/init writes down what it can see in the code. It cannot see your decisions. Those you add yourself, in plain words.

Type this into Claude Code, as one lineAdd our rules to CLAUDE.md: the server uses only the Python standard library; the front end is plain JavaScript in index.html with no npm packages or frameworks; run the app with python server.py; run the tests with python test_server.py; times always show as "1 h 30 min".
The diff of CLAUDE.md adds the line Always display times in the format 1 h 30 min, and Claude says: I added a Rules section to CLAUDE.md, above Architecture. It lists all five rules as you gave them.
A new Rules section, in green. The grey line in the input box is only a suggestion; we did not send it.
What you should see in CLAUDE.md## Rules - The server uses only the Python standard library — no third-party packages. - The front end is plain JavaScript in `index.html` — no npm packages or frameworks. - Run the app with `python server.py`. - Run the tests with `python test_server.py`. - Always display times in the format "1 h 30 min".

Keep it short. Every line in CLAUDE.md is read in every session, whether it is needed or not.

Remember a preference of yours

Some things are about you, not the project. For those, just say "remember".

Type this into Claude Coderemember that I like short commit messages
remember that I like short commit messages. Wrote 2 memories. I've saved that to memory: you prefer short commit messages. I'll keep them to a brief one-line subject from now on.
Wrote 2 memories. This is auto memory: notes Claude keeps for you, outside the project.

So there are two places. CLAUDE.md holds the project's rules and lives in the project folder. Auto memory holds your own habits and stays on your computer. We use the short commit messages in chapter 4.

Check what it will read

How do you know both are loaded? Two commands show you.

Type these into Claude Code, one at a time/memory /context
The /memory panel: Auto-memory true; Project instructions saved in ./CLAUDE.md; User instructions saved in ~/.claude/CLAUDE.md; Open auto-memory folder.
/memory lists the memory files and opens any of them. Press Esc to close it.
Part of the /context view: Memory files, /memory: 2 files, 867 tokens.
/context shows everything that fills the conversation. This is the line that matters here: our two memory files are loaded.

Ask again, in a new session

Now the real test. Exit, start a fresh session, and ask for the same edit button.

Memory does not stop Claude reading the files it changes; that is good practice. It stops Claude re-deciding what we already agreed.

Type this, one line at a time/exit claude Add an edit button to each task, to change its title, tag and minutes.
Claude edits the files, then: Running python test_server.py.
It reads the files it is about to change, as it should. Then it tests with python test_server.py, our rule, without being told.
Each task on the Today list now has an edit button next to the delete button. The server tests pass, including a new one for editing. I updated CLAUDE.md to say so. Worked for 50s.
Done in 50 seconds, with a new test. It even updated CLAUDE.md for the new API.

The server is still running the old code, so restart it. Go to the second tab, press Ctrl+C, and start it again.

Windows: type this in the second tabpython server.py
Mac: type this in the second tabpython3 server.py

Refresh the page. Click the pencil next to a task, change the title and the minutes, and press Enter.

The edit button at work, shown 1.5 times faster. 120 minutes shows as 2 h, by our rule.

What memory costs

Memory is not free. CLAUDE.md is read in every session, so a long one fills the conversation before you type a word. Write rules, not essays.

And memory does not undo. When Claude makes a change you dislike, a note will not bring the old code back. Rewind did it once here. In chapter 4 we see where rewind stops, and why we need git.

Quick reference

The prompts from this chapter, ready to copy: every prompt, chapter 3.

Command or keyWhat it doesUse it when
/initWrites CLAUDE.md from what it sees in your codeYou start using Claude on a project
Add our rules to CLAUDE.md: …Adds your own decisions to CLAUDE.mdYou decided something Claude cannot see in the code
remember that …Saves a preference of yours to auto memoryIt is about you, not the project
/memoryLists the memory files and opens any of themYou want to see or edit what Claude remembers
/contextShows what fills the conversationYou want to check what is loaded
Esc EscRewinds code and conversation to an earlier messageClaude changed something you did not want
Ctrl+CStops the running server, so you can start it againThe server must pick up changed code

References

Where each command and file on this page comes from. Every screenshot is from our own recording on 29 Oct 2026, Claude Code 2.1.312.

  1. Anthropic · Manage Claude's memory CLAUDE.md files, /init, auto memory, /memory, and how memory is loaded at the start of every session. https://code.claude.com/docs/en/memory
  2. Anthropic · Checkpointing Esc Esc rewinds the code and the conversation to an earlier message. https://code.claude.com/docs/en/checkpointing
  3. Anthropic · Interactive mode /context shows what fills the conversation, memory files included. https://code.claude.com/docs/en/interactive-mode
  4. My own recording · 29 Oct 2026, Windows 11 The same request, before and after CLAUDE.md; the second time it ran our test command and finished in 50 seconds.