AI Guides › Workbench

Seven Claude Code Commands for Undo, Planning, Memory and Context

By Nigel Guy · 7 min read

Most people run Claude Code the same way every session: type a request, watch it edit files, then explain the project all over again next time. When something breaks, they ask Claude to "put it back" and hope it remembers. It feels like working with an assistant, but it's one that starts from zero each time and has an undo button you've never pressed.

The rule: let commands carry the routine work. Plan before edits, write your background down once, rewind instead of asking for repairs, and check the cost and the context before they surprise you.

Every command below is built in and was checked against Anthropic's documentation. Commands change often, so type / in a session to see what your version has.

The kit at a glance

All seven are free to use. What you pay for is the plan underneath. At time of writing, Anthropic lists Pro at $20 a month (or $17 a month billed annually) and Max from $100 a month, in US dollars, so check the £ figure at checkout. The Free plan does not include Claude Code.

Command What it does Reach for it when Catch
/rewind (also Esc twice) Restores code, conversation or both to an earlier prompt; can also summarise part of the conversation Claude has just gone the wrong way Doesn't undo changes made by shell commands, most subagents, or you
/usage (aliases /cost, /stats) Shows session cost, plan usage bars and what is eating your allowance Before a big task, and when you feel close to a limit The session dollar figure is an estimate and only matters for API billing
/plan [task] Puts Claude in plan mode: it reads and proposes, but edits nothing until you approve Anything touching more than one file A vague task still gets a vague plan
claude mcp add and /mcp Connects outside tools (Notion, Stripe and others) and manages their sign-ins You keep pasting in material from another app Each server you add is a new route for untrusted content into the session
/init Writes a starter CLAUDE.md for the project from what it finds in the code First session in any project It only knows what is in the files, not how you like to work
/memory Opens your CLAUDE.md files and the auto memory settings You catch yourself typing the same instruction twice Memory is guidance, not enforcement
/compact [focus] with /context Summarises the conversation to free space; /context shows what is using it Long sessions that start to drift or forget Compacting a very large conversation is itself a large request

1. Undo a mistake: /rewind

Claude Code takes a checkpoint each time you send a prompt that starts a turn. Run /rewind (aliases /checkpoint and /undo), or press Esc twice with an empty prompt box, and pick the prompt you want to go back to. You then choose Restore code and conversation, Restore conversation, Restore code, Summarize from here or Summarize up to here.

Restore code when the edit was wrong but the discussion was useful; restore both when the whole approach was wrong. Snapshots are kept for about 30 days by default.

The traps: files changed by shell commands (rm, mv, cp), most subagent edits and your own edits outside Claude Code are not restored. It is a quick undo, not version control.

2. See what it costs: /usage

/usage shows session token use and, on Pro, Max, Team and Enterprise, your plan usage bars plus a breakdown of recent usage by skill, subagent, plugin and MCP server. The breakdown is the useful part: it tells you which connector to switch off. On a subscription, ignore the session dollar total; Anthropic says it is meant for API users.

3. Agree the plan first: /plan

Type /plan followed by the task, or press Shift+Tab until the status bar shows ⏸ plan mode on. Claude reads and proposes, changing nothing until you approve. Correcting a plan costs a sentence; correcting six edited files costs a rewind. Fill in the brackets:

/plan You are working in my [SITE_TYPE, e.g. static HTML site / Next.js app] project.
Goal: add a contact form to [PAGE_PATH] that sends each submission to [EMAIL_ADDRESS].
A good result: the form has [FIELDS], shows a clear success and error message, and
works on mobile.
Constraints: use [EMAIL_SERVICE or "suggest two options with their costs"], keep any
keys in environment variables and never in the code, and add spam protection.
In the plan, list: the files you will create or change, any new dependency or paid
service, and what I need to set up outside the code.
If my hosting setup or email service is unclear from the files, ask me before you
plan around a guess. Before you finish, check that nothing in the plan exposes a key
or my email address in the page source.

4. Plug in your tools: claude mcp add and /mcp

MCP servers let Claude read from and act in other services. Anthropic's documented example for Notion, run in your terminal (not inside a session), is:

claude mcp add --transport http notion https://mcp.notion.com/mcp

Then run /mcp in a session to sign in and check it. The default is local scope: only you, only this project. --scope user makes it available everywhere; --scope project shares it with your team via .mcp.json. Anthropic warns that servers fetching outside content can carry prompt injection, so connect only ones you trust.

5. Stop re-explaining the project: /init

/init studies the codebase and writes a CLAUDE.md with the build commands, tests and conventions it finds; if one exists, it suggests improvements instead. Setting CLAUDE_CODE_NEW_INIT=1 first gives a longer interactive version. What it can't see is how you work, so follow it with this:

You have just written CLAUDE.md for this project. Read it back in full.
Your job now is to add what the code cannot tell you: how I like to work.
Ask me [NUMBER, e.g. 5] questions, one at a time, waiting for each answer. Cover
how I want changes proposed, how much explanation I want, my testing habits,
anything you must never touch, and [ANY_AREA_YOU_CARE_ABOUT].
After the last answer, show me the exact lines you plan to add under a heading
"Working preferences", in short imperative bullets. Do not save until I say yes.
Keep the whole file under 200 lines, and don't repeat anything already in it.

6. Set rules that follow you everywhere: /memory

/memory lists your memory files and opens the one you pick, creating it if needed. Choose the user file, ~/.claude/CLAUDE.md, for rules that apply in every project; the project file is shared with anyone using the repository. Lines worth adapting:

- Write all prose, comments and commit messages in [British English].
- Before editing any file, show me a short plan and wait for my go-ahead.
- Never run [DEPLOY_COMMAND or "any deploy or publish step"] unless I ask in this session.
- If an instruction from me is ambiguous, ask one question instead of guessing.

/memory also holds the auto memory switch. Run /context to confirm which files loaded.

7. Keep a long session sharp: /compact and /context

Long sessions fill the context window and early decisions get lost. /context shows what is using the space. /compact summarises the conversation; steer it, for example /compact keep the API decisions and the open bug list. Claude Code also compacts automatically near the limit, but a steered summary keeps more of what matters. For an unrelated next task, use /clear, which Anthropic notes costs nothing.

How to choose

The "Reach for it when" column above is the decision table. If you only adopt two, make them /plan and /rewind: they change the most and need no setup. Add /init and /memory the next time you start a project, and the rest as the need appears.

What to skip

Guardrails

Sources

All 751 AI guides · JulieMango plans from £17/mo