Slash commands are Claude Code's keyboard shortcuts. /compact saves a 30-minute session. /cost keeps your bill predictable. /doctor resolves the one issue that costs everyone an hour their first week. Six tools — Read, Write, Edit, Bash, Glob, Grep — compose into every workflow you'll ever run. Master them once; reuse them forever.
Learning Objectives
After this lesson, you will be able to:
Start Claude Code sessions in two ways: interactive (conversation) and one-shot (quick task)
Use slash commands (/help, /clear, /compact, /cost, /doctor) to control your session
Understand the three permission modes and when to use each one
Know the six core tools (Read, Write, Edit, Bash, Glob, Grep) -- the building blocks of everything Claude Code does
Once you learn these commands and tools, you will never forget them -- they become muscle memory within a day or two. Do not worry about memorizing everything now; just get familiar with the options and come back to this page as a reference.
You are now in an interactive session. Type naturally:
"What does this project do?"
"Find all TODO comments in the codebase"
"Add input validation to the signup form"
The session persists until you type /exit or press Ctrl+C. You can ask follow-up questions, refine instructions, and build on previous context.
Try it! Open your terminal, navigate to any project, and run claude. Then type: "What does this project do?" Watch Claude Code read your files and explain the project back to you. Then try /cost to see how many tokens that used. This takes 60 seconds and will instantly show you the interactive flow.
$ cat error.log | claude "explain this error and suggest a fix"
$ git diff | claude "review these changes for bugs"
$ npm run test 2>&1 | claude "fix the failing tests"
This is powerful for integrating Claude Code into shell workflows and scripts.
The context window is finite. In long sessions (30+ minutes), you may run out of space. The /compact command summarizes the conversation into a condensed form, freeing up tokens for new work. Use it when:
Claude Code says it is running low on context
You are switching to a completely different task in the same session
The conversation has become long and repetitive
What Do You Think?
You have been working with Claude Code for an hour on a complex refactoring. Suddenly it starts giving incomplete or confused answers. What is the most likely cause?
The context window is the most common cause of degraded performance in long sessions. When it fills up, the model loses access to earlier parts of the conversation. The fix: run /compact to summarize the history, or /clear to start fresh if you are switching tasks entirely.
Skip permission prompts and let Claude Code execute freely:
$ claude --dangerously-skip-permissions
Use this for trusted tasks where you want maximum speed: automated refactoring, running tests, formatting code. The name includes "dangerously" as a reminder that Claude Code will modify files without asking.
Grep searches for text patterns across your codebase. It uses ripgrep under the hood for speed.
When it is used: When Claude Code needs to find where something is used or defined. "Where is the User model defined?" triggers Grep for class User or interface User.
Edit makes precise replacements in existing files. It finds an exact string and replaces it with a new string.
When it is used: For most code modifications. Adding a line, changing a function, fixing a bug. Edit is preferred over Write for existing files because it only changes what needs to change.
Bash executes any terminal command: build, test, lint, git, npm, etc.
When it is used: Running tests (npm run test), checking build status (npm run build), installing packages (npm install), git operations (git status, git diff).
pythonplayground.py · Pyodide
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Tests · Match each task to the correct primary tool.
> Explain the authentication flow in this project
[Claude reads files, explains the flow]
> That's using JWT. I want to switch to session-based auth. What files would need to change?
[Claude analyzes and lists affected files]
> Ok, make the change. Start with the backend.
[Claude makes the backend changes]
> Now update the frontend to use cookies instead of localStorage
[Claude updates the frontend]
> Run the tests
[Claude runs tests, sees failures, fixes them]
$ claude "add a health check endpoint at /api/health that returns { status: 'ok' }"
$ claude "update all lodash imports to use individual function imports"
$ claude "find and fix all ESLint errors"
Two session modes serve different workflows -- interactive mode for exploratory work and conversations, one-shot mode for well-defined tasks and scripting
Slash commands manage the session, not your code -- /compact frees context space, /cost tracks usage, /doctor diagnoses problems, /clear resets the conversation
Three permission modes balance safety and speed -- default mode asks before every change (learning), auto-accept mode skips prompts (trusted tasks), plan mode shows without executing (architecture decisions)
Six tools form the complete vocabulary -- Read, Write, Edit, Bash, Glob, and Grep cover every interaction Claude Code has with your codebase; understanding them lets you predict and guide its behavior
You want Claude Code to scope its plan before touching a single file in a high-stakes refactor. Which command starts the session correctly?
You now know how to start sessions, manage them with slash commands, control permissions, and understand the six tools Claude Code uses. Next up: Effective Prompting -- writing instructions that get the best results from Claude Code.