Slash Commands & Skills
/compact frees context in a long session, /cost shows usage, /doctor diagnoses setup problems. Six tools (Read, Write, Edit, Bash, Glob, Grep) compose into every workflow, and custom commands and skills let you package the prompts you repeat. Command names change between versions, so type /help to see what yours supports.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
Before you start
#Starting a Session
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.
#Interactive Mode
Launch Claude Code and start a conversation:
$ cd /path/to/your/project
$ claude
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"
/exit or press Ctrl+D (Ctrl+C interrupts the current step; pressing it twice also exits). You can ask follow-up questions, refine instructions, and build on previous context.Try it! Open your terminal, navigate to any project, and runclaude. Then type: "What does this project do?" Watch Claude Code read your files and explain the project back to you. Then try/costto see how many tokens that used. This takes 60 seconds and will instantly show you the interactive flow.
#One-Shot Mode
Give Claude Code a single task and let it execute:
$ claude -p "fix the type error in utils.ts"
$ claude -p "run the tests and show me any failures"
$ claude -p "add a loading state to the Dashboard component"
claude -p (print mode). It is ideal for quick tasks where you do not need a conversation: Claude Code executes the task, prints the result, and exits. Note that plain claude "some prompt" is different: it opens an interactive session that starts with that prompt.#Piping Input
You can pipe content into Claude Code:
$ cat error.log | claude -p "explain this error and suggest a fix"
$ git diff | claude -p "review these changes for bugs"
$ npm run test 2>&1 | claude -p "fix the failing tests"
This is powerful for integrating Claude Code into shell workflows and scripts.
#Slash Commands
Slash commands control the session itself, not your code. Type them at the Claude Code prompt:
| Command | What It Does |
|---|---|
/help | Show all available commands and keyboard shortcuts |
/clear | Clear conversation history and start fresh |
/compact | Summarize the conversation to free up context window space |
/cost | Show token usage and cost for the current session (what it shows depends on how you sign in) |
/doctor | Diagnose installation and configuration issues |
/init | Create a starter CLAUDE.md for the project |
/resume | Pick up an earlier conversation |
/exit | End the session |
#When to Use /compact
/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
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?
/compact to summarize the history, or /clear to start fresh if you are switching tasks entirely.#Permission Modes
/help):#Default Mode (Recommended for Learning)
Claude Code asks for permission before every file write and command execution. You see a prompt like:
Claude wants to edit src/auth.ts
[Allow] [Deny] [Always Allow]
This gives you full control and visibility. Use this mode when you are learning Claude Code or working on unfamiliar code.
#Auto-Accept Mode
Accept-edits mode lets Claude Code change files without asking each time, while it still asks before it runs most commands. Cycle to it with Shift+Tab, or start in it:
$ claude --permission-mode acceptEdits
claude --dangerously-skip-permissions, skips nearly all prompts. Use it only in a throwaway container or VM with nothing valuable in reach. The name includes "dangerously" on purpose.#Plan Mode
$ claude --permission-mode plan
"Plan how you would add authentication to this app, but don't write any code yet."Plan mode is ideal for complex architectural decisions where you want to review the approach before any code is written.
#The Six Core Tools
Every action Claude Code takes reduces to one of these six tools:
#1. Read — View File Contents
Claude Code reads files to understand your codebase. It can read files your user account can read, subject to your permission rules.
src/auth.ts. "Fix the login bug" causes Read on multiple files related to login.#2. Glob — Find Files by Pattern
**/*.ts or src/components/**/*.tsx.**/*.tsx.#3. Grep — Search File Contents
Grep searches for text patterns across your codebase. It uses ripgrep under the hood for speed.
class User or interface User.#4. Edit — Modify Existing Files
Edit makes precise replacements in existing files. It finds an exact string and replaces it with a new string.
#5. Write — Create New Files
Write creates a new file or completely overwrites an existing file.
#6. Bash — Run Terminal Commands
Bash executes any terminal command: build, test, lint, git, npm, etc.
npm run test), checking build status (npm run build), installing packages (npm install), git operations (git status, git diff).Tests: Match each task to the correct primary tool.
#Custom Commands and Skills
Two ways to package a prompt you keep retyping:
- Custom slash commands: a Markdown file in
.claude/commands/(shared through git) or~/.claude/commands/(personal). The file name becomes the command, so.claude/commands/review-branch.mdruns as/review-branch. Write$ARGUMENTSin the file wherever the text you type after the command should go. - Skills: a folder with a
SKILL.mdfile, in.claude/skills/<name>/. Its frontmatterdescriptiontells Claude when the skill applies, so Claude can use it on its own, and you can still call it by name. A skill can keep scripts and templates besideSKILL.md.
---
description: Review the current branch against main
---
Review the changes on this branch against main. Focus on: $ARGUMENTS
List bugs first, then missing tests. Do not edit any files.
.claude/commands/review-branch.md, then type /review-branch security and auth. A command is a prompt you trigger; a skill is a capability Claude can pick up by itself. Recent versions treat the two similarly in places, so check the current docs for the folder and frontmatter keys to use (as of October 2026).#Multi-Turn Conversations vs One-Shot Commands
#Multi-Turn Example
> 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]
#One-Shot Examples
$ claude -p "add a health check endpoint at /api/health that returns { status: 'ok' }"
$ claude -p "update all lodash imports to use individual function imports"
$ claude -p "find and fix all ESLint errors"
#Key Takeaways
- 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), accept-edits mode skips file-edit 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
#Quick Check
When should you use the /compact slash command?
You want Claude Code to scope its plan before touching a single file in a high-stakes refactor. Which setup starts the session correctly?