Slash Commands in Claude Code | CampusX
Based on CampusX's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
Slash commands are typed shortcuts inside Claude Code sessions that trigger predefined workflows without writing full prompts repeatedly.
Briefing
Slash commands in Claude Code are fast shortcuts typed inside a working session that trigger predefined actions and workflows—often without writing a full prompt. The practical payoff is less repetition: instead of re-explaining the same intent every time, developers can invoke reusable patterns with a short command, making Claude Code feel more like a programming assistant that supports repeatable development flows.
Claude Code supports two kinds of slash commands. Built-in commands ship with the tool and appear by default after installation. Custom slash commands can be created by users to match recurring project-specific workflows—useful when the same requirement keeps repeating across a particular kind of work.
A major portion of the walkthrough focuses on session-related commands, because sessions are the unit of work in Claude Code: each session is one conversation, starts when the user enters the Claude keyword in the command prompt, and ends when the user types /exit. Every session carries a unique ID and stores the full message history, including user messages, assistant responses, and tool messages. Sessions are automatically saved and can be resumed later even after closing the terminal.
Resuming is handled through the /resume flow. The user can resume a prior conversation by using Claude with a resume flag (described as “Claude -r”), which lists past conversations with timestamps. There’s also a /resume slash command that jumps between sessions so work can continue in the middle of switching contexts.
To keep projects organized, the walkthrough recommends a disciplined session strategy: plan and solve one task per session (for example, one session per website feature), close the session when that feature is done, and start a new session for the next feature to avoid mixing contexts. It also advises renaming sessions immediately after starting so the AI doesn’t generate unhelpful names based on early questions. The /rename command lets users set a clear label (e.g., “intro session”). When meaningful milestones are reached, frequent commits are encouraged to capture progress.
Beyond sessions, the walkthrough highlights /by the way (BTW) for side questions that shouldn’t pollute the main conversation history. This is positioned as a way to ask quick reference questions (like what Flask templating is in Python) while Claude continues the primary task; the side answer can be removed from the visible history using a space interaction.
For larger refactors, /export is recommended to save important past conversations into a Markdown file inside the project directory, so the content can be re-provided as context during code changes.
The guide also covers account and model management. /logout and login flows support switching between Claude Code accounts (including Anthropic console-based access). Model choice is framed as a cost/quality tradeoff: Opus for complex planning, Sonnet as the default balance, and HQ for fast, cheap repetitive tasks. A /model command enables switching models on demand, while /usage shows token consumption for the current session and weekly limits. If limits are reached, /extra usage supports midstream top-ups.
Finally, the walkthrough introduces analytics and control commands: /stats provides usage statistics, /insights generates a detailed HTML report after enough sessions to identify better usage patterns, and /config allows changing settings like thinking mode, verbosity, progress bar behavior, and language. /permissions governs tool access by allowing, asking, or denying tool usage (including adding rules for tools like web search or bash commands). The session ends with UI customization via /theme and hands-free prompting via /voice, plus a reminder that typing / and scrolling reveals the full command list.
Cornell Notes
Slash commands in Claude Code act as quick, reusable shortcuts typed inside a session, triggering predefined actions and workflows without rewriting full prompts. Sessions are the core work unit: each session is one conversation with a unique ID, saved automatically, and resumable after closing the terminal. Key session commands include /exit to end, /resume (and Claude -r) to continue prior work, /rename to prevent vague AI-generated names, and /export to save important conversation context for later refactoring. For context hygiene, /by the way (BTW) supports side questions that shouldn’t contaminate the main conversation history. Model and usage management commands—/model, /usage, and /extra usage—help balance quality, speed, and token limits while /stats and /insights track and improve how Claude Code is used.
What exactly does a slash command do in Claude Code, and why does it matter for programming workflows?
How do sessions work, and what commands control their lifecycle?
Why rename sessions, and how does /rename help?
What is /by the way (BTW), and how does it protect the main context?
When should /export be used, and what does it produce?
How do model choice and token limits interact, and which commands manage that?
Review Questions
- How would you structure a multi-feature project using sessions to avoid context mixing, and which commands support that workflow?
- What’s the difference between asking a question in the main session versus using /by the way (BTW), and what problem does BTW prevent?
- Describe a practical workflow for planning with one model and implementing with another, including how you would verify token usage during development.
Key Points
- 1
Slash commands are typed shortcuts inside Claude Code sessions that trigger predefined workflows without writing full prompts repeatedly.
- 2
Claude Code sessions store complete message history, are automatically saved, and can be resumed later using Claude -r or /resume.
- 3
Use /exit to end a session, /rename to set meaningful session names immediately, and frequent commits to capture milestones.
- 4
Keep the main context clean with /by the way (BTW) for side reference questions that shouldn’t become part of the primary conversation history.
- 5
Before major refactors, use /export to save important conversations into Markdown files inside the project directory for later context.
- 6
Manage cost and performance by switching models with /model (Opus for complex planning, Sonnet for implementation, HQ for simple repetitive tasks) and monitor limits with /usage.
- 7
Control tool behavior with /permissions by allowing, asking, or denying tool usage (including rules for tools like web search and bash commands).