Most people start Claude Code, type a request and hope for the best. That works until the conversation gets long, the answers get worse, and a change you did not want lands in your working tree. A small set of slash commands fixes most of that: they control what Claude remembers, how much context it carries, whether it may act, and how you get back when something goes wrong. These ten are the ones worth learning first, followed by a few command-line options for scripts and CI.
Everything here was checked against Claude Code 2.1.318. Commands change between versions, so type /help in your own install to see what yours has.
The ten at a glance
| # | Command | Use it to |
|---|---|---|
| 1 | /init |
Create a CLAUDE.md for your project |
| 2 | /memory |
Edit CLAUDE.md files and memory settings |
| 3 | /clear |
Start fresh when the topic changes |
| 4 | /compact |
Summarize a long session and keep going |
| 5 | /context |
See what is using the context window |
| 6 | /plan |
Plan before any code changes |
| 7 | /rewind |
Go back to an earlier point |
| 8 | /resume |
Continue an earlier conversation |
| 9 | /permissions |
Control what Claude may run without asking |
| 10 | /usage |
Check cost and usage (aliases: /cost, /stats) |
1. /init: give Claude project knowledge
Claude starts every session without knowing your project. /init analyzes the codebase and creates a CLAUDE.md file with documentation about it, which Claude reads at the start of future sessions. Run it once in the project root, then edit the result. A generated file is a draft: delete anything wrong or vague, and add the facts only you know. For a Laravel project, the useful lines are the ones that save a wrong guess:
# Project notes
- Run tests: php artisan test
- Format code: ./vendor/bin/pint --dirty
- Do not edit migrations that are already merged; add a new one.
- Authorization lives in app/Policies; every controller action must use it.
2. /memory: edit what Claude remembers
The command opens your CLAUDE.md files and memory settings for editing. Use it when you catch yourself correcting the same thing twice. Put the rule in the file once instead of repeating it in every session. Keep the file short, because everything in it is loaded into context each time.
3. /clear: start clean
It starts a new session with empty context. The previous session stays on disk and can be reopened with /resume, so nothing is lost. Use it between unrelated tasks. A long conversation about a billing bug is noise when you move on to a CSS problem, and stale context makes answers worse and costs more.
4. /compact: shrink a long session instead of abandoning it
/compact summarizes the conversation so far to free up context. It accepts optional instructions for what the summary should keep:
/compact keep the failing test names, the files we changed, and the decision to use a queue
Use it when you are mid-task and want to continue. Use /clear when you are done with the task.
5. /context: see where the context goes
It shows current context usage by category. I ran it in a fresh session and got a table like this:
**Tokens:** 31.7k / 500k (6%)
| Category | Tokens | Percentage |
| System prompt | 3.7k | 0.7% |
| System tools | 21.2k | 4.2% |
| Skills | 6.8k | 1.4% |
Your numbers will differ with your model, tools and settings. The point is that even an empty session uses some of the window, and MCP servers, skills and big CLAUDE.md files add to it. When responses start degrading in a long session, check this before blaming the model.
6. /plan: think before changing files
/plan enables plan mode, or shows the current session plan if one exists. Use it for any change that touches more than a file or two: ask for the approach, read it, correct it, then let Claude implement. Catching a wrong approach in a plan costs a minute. Catching it in a 20-file diff costs an hour. Plan mode is also one of the permission modes you can start a session with, using claude --permission-mode plan.
7. /rewind: undo to an earlier point
The command restores the code and/or the conversation to a previous point. It also answers to /checkpoint and /undo. It is the fast way out when an approach goes wrong. Do not treat it as a replacement for git: commit before larger tasks, and check the Claude Code documentation for exactly what is tracked, since changes made outside Claude's own edits may not be.
8. /resume: pick up where you left off
/resume (alias /continue) reopens a previous conversation, and accepts a session ID or a search term. From the terminal, two flags do the same job:
claude -c # continue the most recent conversation in this directory
claude -r # open the picker; or: claude -r "invoice export"
I tested claude -c in a scratch directory: it resumed the previous session and could repeat my earlier message back. Name sessions with -n or --name when you start them, so they are easy to find later.
9. /permissions: decide what runs without asking
It manages allow and deny rules for tools. Allow the safe, repetitive commands (running tests, git status) so you are not clicking "approve" all day, and leave everything else on ask. Be conservative: an allow rule is a standing permission. The same rules can be given at startup. The CLI help shows the syntax:
claude --allowedTools "Bash(git *) Edit"
Avoid --dangerously-skip-permissions on a normal machine. The help text itself recommends it only for sandboxes with no internet access.
10. /usage: know what you are spending
It shows session cost, plan usage and activity statistics, under the aliases /cost and /stats too. Check it after long agentic runs, and before you decide to automate something at scale.
Bonus: use Claude Code in scripts
The -p (--print) flag runs one prompt, prints the answer and exits, which makes Claude usable in shell pipelines and CI. Pipe data in, and ask for structured output when another program reads the result:
php artisan test 2>&1 | claude -p "Summarize the failures in one sentence each"
claude -p "List the routes without auth middleware" --output-format json
I piped a failing test line (Expected 200 but received 419) into claude -p and got back an explanation that a 419 in Laravel means a CSRF token problem. The JSON output format returns one object. In my run, the answer was in the result field, and the object also included fields such as session_id, total_cost_usd and usage, plus many other diagnostic keys, so read only the fields you need. The other output formats are text (the default) and stream-json.
Two more options worth knowing: claude -w feature-x starts the session in a new git worktree, so experiments do not touch your main checkout, and claude doctor checks the health of your installation.
Common mistakes
-
Never clearing. One endless session accumulates stale context. Use
/clearbetween tasks. - An unreviewed CLAUDE.md. A bloated or wrong file misleads every session. Edit it like code.
- Skipping the plan. Large changes without a plan produce large diffs that are hard to review.
- Trusting rewind instead of version control. Commit before big tasks.
-
Allow-listing broad commands. A narrow rule such as
Bash(git *)is safer than allowing arbitrary shell access.
Frequently asked questions
How do I see all available commands?
Type /help in a session. It shows help and the available commands for your version.
What is the difference between /clear and /compact?
/clear starts a new session with empty context. /compact keeps the same session but replaces the history with a summary.
Do these commands work the same in an IDE?
I only tested the terminal version. Check your IDE integration's documentation for differences.
Can I run slash commands in print mode?
Some, yes. In my tests /context and /usage worked with claude -p. Others, such as /rewind, are interactive only.
Sources
- Claude Code documentation: CLI reference
- Claude Code documentation: Overview
- @anthropic-ai/claude-code on npm
Originally published on DEV Talk.
Top comments (0)