Vibe coding with Claude Code course ยท Module 5: Reddit clone
The long voyage: context and sessions in Claude Code
In this lesson7
Crew Council was built over several evenings: voting, threads, guilds, Markdown and search. If all that work had gone through one conversation, then at the search feature Claude would still have in front of its eyes the arguments about votes, old test results and two abandoned versions of the comment tree. And when you close the terminal in the evening, a second question appears: do you have to explain everything again tomorrow? This lesson gathers in one place what you did by instinct in this location: when to clear a conversation, when to summarize it and when to come back to it.
The context window: what Claude has in front of its eyes
The context window is everything Claude sees in a given session: CLAUDE.md and automatic memory loaded at the start, your requests, the files it read, command output and its own answers. Automatic memory is notes Claude writes itself based on your corrections and preferences; it is on by default, and you can look at it through /memory. Every next request sends the model the whole conversation. The documentation gives an example: a session that gathered three unrelated tasks reads all three on every turn at the fourth. Sessions, meanwhile, are independent of each other: every new one starts with an empty window, without the history of earlier conversations, and only CLAUDE.md, automatic memory and the project files connect them.
Room is rarely what runs out. Most current models have a window of a million tokens, and Claude Code summarizes the conversation itself when it nears the limit (as of November 2026). So the problem is not a hold that bursts but two other things: every turn costs more of your limit the longer the conversation is, and old, outdated decisions mix with new ones.
/context: look into the hold
Before you clear anything, you can check what takes up the space:
/contextThe command draws a colourful grid of window usage split by kind of content and suggests what takes too much. It also shows which CLAUDE.md and memory files were loaded. When you are looking for the answer to "does Claude even see my rules?", this is the first place to check.
/clear: a new feature, a new conversation
/clear starts a new conversation with an empty context. The previous one does not vanish, it is saved so you can resume it. You can give it a name right away:
/clear communitiesThe name goes to the conversation you are leaving, so in the session list you will find it under communities. Claude Code's best practices say two things about /clear. First, between unrelated tasks it costs nothing, and the next task does not pay for the history of the previous one. Second, when you have corrected the same thing twice and it is still wrong, a third correction only adds a failed attempt to the conversation. Better /clear and one new request in which you gather what you have learned. And if you type /clear too early, in the same Claude Code run the /rewind menu has the previous conversation at the top and restores it with one choice.
What matters is what survives /clear and what does not. Everything on disk survives: CLAUDE.md and automatic memory load at the start of every conversation, the project files and Git commits stay, and the old conversation waits in the session record. What does not survive is the conversation in the context, that is, decisions from the chat, test results shown earlier and every decision nobody wrote down. That is why the trap from lesson 4_1, "you do not change expected values in tests without my consent", stands in CLAUDE.md and not in one of the requests. I recommend a simple habit: commit before /clear, and add whatever every future conversation should remember to CLAUDE.md.
/compact: the same task, a shorter history
Sometimes a task goes on and the conversation swells, for example after an hour of fixing the same search. You do not want to clear, because the decisions are still needed. Then /compact replaces the history with a summary, and you say what should stay in it:
/compact keep the search rules, the list of tests and the test commandWithout the note, the summary picks for itself what matters. After the summary CLAUDE.md is loaded from disk again, and Claude re-reads a few recently changed files. Detailed instructions from the start of the conversation can be lost, though, so lasting rules belong in CLAUDE.md once more. There you can also add a "Compact Instructions" section with what every summary should keep. In a long session /compact is itself a big request, because it reads the whole conversation to summarize it. The distinction is simple: a new topic is /clear, the same topic with a long history is /compact.
You close the terminal, the session waits
Claude Code saves the conversation as you go in a file on your computer, so leaving through /exit deletes nothing. You come back with one of these commands, run in the project folder:
claude -c # the last conversation in this folder
claude -r # a list of sessions to pick from
claude -r search # the session with this name
claude -n highlighting # a new session, named right away-c is short for --continue and -r for --resume. -c always takes the last conversation in the folder, so when you pull two threads in turn, name your sessions and come back through -r with the name so you do not land in the wrong one. Inside an open session the same list is given by /resume, and /rename renames the current session and shows it on the prompt bar. A resumed conversation comes back with its history, model and permission mode, but without things it did not save, for example commands that were running in the background. Session records disappear after 30 days by default, so this is not an archive for ever.
Two things may greet you after a break. When you return to the terminal after a longer while, Claude Code shows a one-sentence summary of the session, and on request /recap gives it to you. On the Pro, Max and Ultra plans (as of November 2026), after a long break you may also get the question "Resume this conversation?" with an estimate of how much of the five-hour limit the saved conversation alone will eat. You pick Resume when further work needs it, or Start a new conversation when it does not.
Your logbook from this location
This is what the Crew Council voyage looked like if you followed the lessons:
day 1 4_3 guilds commit, then /clear
4_4 Markdown commit, red strikethrough test, /exit
day 2 claude -c remark-gfm to green, commit, then /clear
4_5 search commit/clear stood between features, because Markdown did not need a conversation about guilds. claude -c opened the conversation the next day, because the strikethrough task was half done and Claude had the request and the red result in it. Once the task was closed with a commit, /clear again, because search is a new topic.
Practise it now. In a session type /context and find your CLAUDE.md on the list. Then /clear search, and right after it /resume: the conversation about search waits on the list under the name you gave it. Close the list with the Esc key, leave through /exit and come back to that conversation through claude -r search. One warning from the documentation: do not resume the same session in two terminals at once, because some messages may be lost from the record.
Captain's review
- Before
/clear: is everything important on disk, in a commit or inCLAUDE.md? - After
claude -c: start with/recapor the question "where did we stop?" and compare the answer withgit log, instead of assuming Claude remembers every detail. - After
/compact: check that the summary kept what you asked for, for example that Claude still knows the test command.
Remember: the ship's logbook, that is CLAUDE.md and the commits, survives every change of watch, while the conversation is the hubbub on deck: /clear hushes it, /compact summarizes it and claude -c calls it back.
Code for this lesson: App.jsx
// The long voyage: which command fits the situation and what survives /clear
import { useState } from 'react';
const situations = [
{
text: 'The search is done and committed. Now you start the pirate profile.',
answer: '/clear search',
why: 'A new topic is a new conversation. The name stays with the conversation you leave, so you can come back to it through /resume.',
},
{
text: 'You have been fixing the same search for an hour, the conversation is very long, and its decisions are still needed.',
answer: '/compact keep the search rules and the test command',
why: 'The same task, a long history: a summary with a focus keeps what you point at.',
},
{
text: 'Yesterday you stopped on a red test and closed the terminal. Today you want to finish.',
answer: 'claude -c',
why: 'It opens the last conversation from this folder, with the request and the test result.',
},
{
text: 'You pull two threads in turn: highlighting and the profile. You want to go back to highlighting.',
answer: 'claude -r highlighting',
why: 'It resumes the session by name. -c would take the last conversation, which may be the wrong one.',
},
{
text: 'You corrected the same mistake twice and it is still wrong.',
answer: '/clear and one better request',
why: 'A third correction adds another failed attempt to the conversation. A new request gathers what you have learned.',
},
{
text: 'You do not know whether Claude loaded your CLAUDE.md at all.',
answer: '/context',
why: 'It shows window usage and the list of loaded CLAUDE.md and memory files.',
},
];
const things = [
{ name: 'CLAUDE.md', survives: true, note: 'loads at the start of every conversation' },
{ name: 'Automatic memory', survives: true, note: 'loads at the start of every conversation' },
{ name: 'Project files and commits', survives: true, note: 'they sit on disk and in Git' },
{ name: 'Decisions from the chat', survives: false, note: 'they stay only in the old conversation, to resume through /resume' },
{ name: 'A test result shown an hour ago', survives: false, note: 'the new conversation does not know it, run the tests again' },
];
export default function App() {
const [open, setOpen] = useState(null);
const [revealed, setRevealed] = useState(false);
return (
<div className="min-h-screen bg-gray-100 p-4 text-gray-900">
<div className="mx-auto max-w-2xl space-y-4">
<h1 className="text-2xl font-bold">The long voyage: what do you type?</h1>
<p className="text-sm text-gray-600">Click a situation, think of an answer, then compare it.</p>
{situations.map((situation, i) => (
<button
key={situation.answer}
type="button"
onClick={() => setOpen(open === i ? null : i)}
aria-expanded={open === i}
className="block w-full rounded-lg border border-gray-200 bg-white p-3 text-left hover:border-orange-400"
>
<span className="block">{situation.text}</span>
{open === i && (
<span className="mt-2 block text-sm">
<code className="rounded bg-gray-900 px-2 py-0.5 text-white">{situation.answer}</code>
<span className="mt-1 block text-gray-700">{situation.why}</span>
</span>
)}
</button>
))}
<section className="rounded-lg bg-white p-3">
<h2 className="mb-2 font-bold">What survives /clear?</h2>
<ul className="space-y-1 text-sm">
{things.map((thing) => (
<li key={thing.name}>
<span className="font-semibold">{thing.name}</span>
{revealed && (
<span className={thing.survives ? 'text-green-700' : 'text-red-700'}>
{thing.survives ? ': stays, ' : ': gone from the context, '}
{thing.note}
</span>
)}
</li>
))}
</ul>
<button
type="button"
onClick={() => setRevealed((prev) => !prev)}
className="mt-3 rounded bg-orange-600 px-3 py-1 text-white hover:bg-orange-700"
>
{revealed ? 'Hide answers' : 'Show answers'}
</button>
</section>
</div>
</div>
);
}Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. You have been fixing the same search with Claude for an hour. The conversation is very long, and its decisions are still needed. What do you type?
2. You type /clear. What does Claude still know in the new conversation?
These are 2 of 3 questions for this lesson. Solve the rest in the game.
Hands-on tasks in the game
- Horizontal ordering
Arrange the command that resumes the session named search (one line, left to right):