AI for Automation
⌨️ Slash Commands Mastery

Step 20 / 22

⌨️ Slash Commands Mastery

Terminal shortcuts — /copy, /compact, /init and more

Slash Commands = Claude Code’s Shortcuts

When you tell Siri “commute,” it turns off the alarm, starts navigation, and plays music all at once. One word triggers multiple automatic actions.

Claude Code’s slash commands work the same way. A short command starting with / handles complex tasks in one go. Think of them as keyboard shortcuts for the chat interface.

Smartphone ShortcutsClaude Code Slash Commands
"Commute" → alarm off + navigation + music/init → auto-generate CLAUDE.md
"Good night" → alarm set + silent + lights off/compact → summarize conversation + save memory
"Meeting" → start recording + open notes/status → view current state at a glance
Ctrl+C (copy)/copy (copy conversation content)
Ctrl+Z (undo)Esc (cancel input)

One-line summary

Slash commands = keyboard shortcuts for the Claude Code terminal. Type / and the list of available commands appears — no memorization needed.

9 Essential Commands — All You Need

Claude Code has many slash commands, but 9 are the ones worth knowing from the start. Sorted by frequency of use.

/help

Shows help. Lists available commands, shortcuts, and usage. When in doubt, start with /help.

/copy

Copies Claude’s last response to clipboard. Handy for pasting results elsewhere. You can specify a number to copy a specific response.

/clear

Wipes conversation history clean. Use when starting a new topic. No carryover from previous context.

/compact

Summarizes conversation to save memory. Essential when conversations get long. Saves tokens while keeping context.

/init

Auto-generates a CLAUDE.md file. Best to run first when starting a new project. Analyzes project structure automatically.

/config

Changes Claude Code settings. Adjust model, theme, allowed tools, etc.

/status

Shows current state at a glance. Check model, MCP connections, settings, and usage.

/model

Switches the AI model. Toggle between available models like Sonnet, Opus, etc.

/fast

Switches to fast mode (Haiku). The quick model is efficient for simple questions. Switch back with /model.

Type / to see the list

Type / in the Claude Code chat and available commands automatically appear. No memorization needed — just type / and pick from the list.

Slash Commands = Power User’s Secret Weapon

Control everything from the keyboard, no mouse needed

/copy — Instantly Copy Results

When Claude generates code or writes a report, you often want to paste it somewhere else — into an email, document, or send to a colleague.

Dragging to select with a mouse is tedious, especially for long code where getting the selection range right is tricky./copy does it in one word.

Basic Usage

Copy last response
/copy

This copies Claude’s last response to your clipboard. Just Ctrl+V to paste.

Copy a Specific Response

Copy specific response
/copy 3

Adding a number copies only the 3rd response. Useful in long conversations for grabbing a specific result.

Great for these situations

After code generation

Paste generated code into another file or editor

After report writing

Send analysis results directly to email or Slack

After command suggestions

Run Claude’s suggested command in another terminal

Sharing with colleagues

Forward Claude’s explanation to chat or Slack

Copies in Markdown format

Content copied via /copy is in Markdown format. Paste it into Notion, GitHub, Slack, or any Markdown-supporting platform and the formatting is preserved.

/compact — The Key to Saving Memory

Long Claude Code conversations consume more tokens, make Claude slower, cost more, and in the worst case exceed the context limit, making it impossible to continue.

/compact solves this by summarizing to just the essentials, drastically reducing memory usage.

MetricBefore /compactAfter /compact
Conversation lengthFull 200-line conversation20-line key summary
Response speedSlower (long context analysis)Faster (short context)
Token usageHigh consumptionSignificantly reduced
Context maintainedEverything keptOnly essentials kept

Basic Usage

Summarize conversation
/compact

One word and done. Claude analyzes the conversation and keeps only key decisions, file changes, and progress — summarizing the rest.

Custom Summary Instructions

Focus summary on specific content
/compact Only remember the API integration part. Forget the rest.

Adding instructions lets you tell Claude what to prioritize. Especially useful when the work direction has changed.

When to Use It

1
When conversations get long

If you've been chatting 30+ minutes or exchanged 20+ messages, use it

2
When Claude gets slow

If responses take longer than usual, the context has gotten too long

3
When the topic changes

When starting a new task unrelated to the previous one, clean up

4
When you see a "context limit" warning

This is urgent. Use /compact immediately

/compact vs /clear

/compact summarizes the conversation./clear completely deletes it. /compact keeps context, /clear starts from zero. Usually try /compact first; only use /clear when you truly need a fresh start.

/init — Auto-Generate CLAUDE.md

Starting a new project? The first thing to do is create a CLAUDE.md file. This tells Claude Code what the project is and how to work on it.

Writing it from scratch is tedious. Type /init and Claude analyzes your project structure to automatically create CLAUDE.md.

Auto-generate CLAUDE.md
/init

What /init Does

1
Analyzes project structure

Automatically reads folder structure, package.json, config files, etc.

2
Identifies tech stack

Figures out what technologies are used: React, Next.js, Python, etc.

3
Writes CLAUDE.md

Auto-records project description, structure, build commands, etc.

4
Suggests a commit

Asks if you want to add CLAUDE.md to git

Example CLAUDE.md generated by /init
# CLAUDE.md

## Project Overview
Next.js 14 App Router + Tailwind CSS + TypeScript website.

## Development Commands
- npm run dev — Start dev server
- npm run build — Production build
- npm run lint — Run linter

## Directory Structure
- app/ — Page routes
- components/ — Reusable components
- lib/ — Utility functions
- public/ — Static files

Edit after auto-generating

The CLAUDE.md from /init is a starting framework. Add your own rules like “API keys read from .env” or “write commit messages in English” to make it even better.

/model & /fast — Switch Models

Claude Code supports multiple AI models. Choose the right one per task to optimize speed and cost.

Switching Models

View available models + switch
/model

Type /model to see the list of available models and pick one.

Quick Mode Switch

Switch to fast mode (Haiku)
/fast

/fast is a shortcut to switch to the fastest model (Haiku) instantly. Good enough for simple questions and minor fixes.

ModelCharacteristicsBest For
OpusSmartest but slowestComplex design, long code, tough bugs
SonnetBalanced (default)Most everyday tasks
Haiku (/fast)Fastest but for simple tasksTypo fixes, simple questions, file renames

Switching strategy

Usually work in Sonnet (default), switch to /fast for quick tasks, and to Opus via /model for hard problems. Switch freely within the same session.

Create Custom Commands (Skills)

The built-in slash commands are great, but for repetitive tasks, you can create your own slash commands called Skills.

Instead of typing “write the commit message in English with conventional format” every time, just type /commit and it’s done.

How to Create — .claude/commands/ Folder

1
Create .claude/commands/ folder

Create this folder in your project root

2
Create command-name.md file

E.g.: commit.md, review.md, deploy.md

3
Write the prompt inside the file

Detail what you want Claude to do

4
Run with /command-name

Type /commit in Claude Code and it executes

.claude/commands/commit.md — Commit automation example
# Commit Automation

1. Check changes with git diff --staged
2. Analyze changes and write a commit message
3. Commit message rules:
   - Write in English
   - Convention: feat: / fix: / content: / chore:
   - Title under 50 chars + body
4. Show the commit message to the user for approval
5. If approved, run git commit
Use in Claude Code
/commit

Real-World Custom Command Examples

/review

Automatically run a code review

.claude/commands/review.md
Analyze changes in the current branch and do a code review.
Check for potential bugs, performance issues, and code style.
Mark severity (High/Medium/Low).

/daily

Generate a daily work summary report

.claude/commands/daily.md
Analyze files I modified and commits today.
Create a daily work report:
- Completed tasks
- Number of files changed
- Remaining TODOs (based on TODO comments)
Format as clean Markdown.

/test

Auto-generate test code

.claude/commands/test.md
Write tests for the $ARGUMENTS file.
- Include both success and error cases
- Test framework: vitest
- Filename: originalname.test.ts

$ARGUMENTS captures arguments after the command. Typing /test src/utils/calculator.ts replaces$ARGUMENTS with src/utils/calculator.ts.

Personal vs project commands

.claude/commands/ are project-wide commands. For personal commands, create them in ~/.claude/commands/ (home folder). They work anywhere, regardless of project.

Keyboard Shortcuts

Beyond slash commands, Claude Code has useful keyboard shortcuts for fast mouse-free work.

ShortcutActionWhen to use
EscCancel current inputChanged your mind while typing
Ctrl+CStop current taskClaude is taking too long
TabAccept suggestionAccept Claude's proposed action immediately
Shift+TabReject suggestionProposal isn't what you want
Up/DownNavigate previous/next inputReuse a previous command
Ctrl+LClear screenTerminal screen is too cluttered

Frequently Used Combos

1. Esc — Most-used key

When you think “wait, that’s not right” while typing, press Esc. Input disappears and you start fresh. If it hasn’t been sent to Claude yet, nothing happens — safe to press anytime.

2. Ctrl+C — Emergency stop button

If Claude is working but heading in the wrong direction, Ctrl+C stops it. Then say “cancel that and do this instead” with new instructions.

3. Tab — Accept suggestions

When Claude suggests a file edit or command, pressing Tab accepts immediately. No need to type “sure, go ahead.”

The secret to speed

Power users barely touch the mouse, using slash commands + keyboard shortcuts./compact → give instructions → Tab (accept) →/copy (copy result) → paste. Master this flow and your speed doubles or triples.

Try It Yourself

Reading alone won’t click. Open Claude Code and follow these exercises.

Exercise 1: Basic Commands (5 min)

Open Claude Code and enter these commands in order.

Try in order
/help
# → Check if help appears

/status
# → Check current model and settings

Hello! Nice weather today.
# → Get a response from Claude

/copy
# → Check if the response copies to clipboard (test with Ctrl+V)

Exercise 2: Experience /compact (5 min)

Have a longer conversation, then try /compact.

Have a longer conversation
# Chat several times first
Explain this project's structure.
# (after response)
Analyze the package.json.
# (after response)
Summarize the README.
# (after response)

# Then run compact
/compact

Verify the conversation gets condensed into a short summary. Test that context is maintained in subsequent messages.

Exercise 3: Create a Custom Slash Command (10 min)

The most fun exercise. Create your own command.

Ask Claude Code directly
Create a .claude/commands/hello.md file.
Content: "Hello! Show me the current time and today's to-do list."

Then test that the /hello command works.

Verification Checklist

Can’t remember a slash command? Just type /. The autocomplete list appears so you can pick from there. No memorization needed.

Tips + Sources

Practical tips for more effective slash command usage.

1. Make /compact a habit

If you’ve been chatting 30+ minutes, always /compact. Clean up before Claude gets slow. Don’t worry about doing it too early — key context is preserved.

2. Share custom commands with your team

Commit .claude/commands/ to Git and the whole team gets the same commands. Standardize /commit, /review, /deploy as team conventions.

3. Use /model to manage costs

No need for the top model on every task. Simple edits with /fast, complex design with Opus. Switching models at the right time saves both speed and tokens.

4. Use /clear carefully

/clear permanently deletes the conversation. Can’t be undone. /compact is usually sufficient, so save /clear for when you truly need a fresh start.

5. Turn frequent tasks into commands

If you think “I’m typing this prompt again,” make it a custom command immediately. Takes 5 minutes to create, saves time every time after. Tell Claude “turn this task into a slash command” and it creates the file in .claude/commands/ automatically.

Slash Commands = Compound Interest on Time

Use /compact to protect memory,/copy for instant results, and custom commands to eliminate repetitive work. Small habits compound into 2-3x productivity.

Start with just /

Remember one thing today: type / in the Claude Code chat. All available commands appear as a list. Pick one and try it — you’ll learn naturally. No memorization needed.

References