Back to guides

How Do I Use Claude Code's Slash Commands to Save Hours a Week?

Jake McCluskeyBeginner20 min read
How Do I Use Claude Code's Slash Commands to Save Hours a Week?

Most Claude Code users are running it like ChatGPT — type a question, get an answer, repeat. They're missing 90% of what makes Claude Code different from a chat window. The slash commands are the bridge: small, sharp tools that turn a session from "AI assistant" into "AI workflow." Here are the seven I reach for every day, what each one actually does, and the order to learn them in.

Why this matters

Claude Code's whole pitch is that it works the way a senior engineer does — context-aware, file-aware, runs commands, edits in place. The slash commands are how you get out of the way and let it. Skip them and you end up retyping the same prompt patterns 20 times a day. Learn them and your sessions get shorter, sharper, and cheaper in tokens.

This is a tour, not an exhaustive reference. Once you've used these seven in real work for a week, the rest of the slash command list will make sense.

Before you start

You need:

  • Claude Code installed. Get it via npm install -g @anthropic-ai/claude-code or follow the macOS setup guide.
  • A real project open. Slash commands are most of them codebase-aware — running them in an empty directory teaches you nothing.
  • About 20 minutes to actually run each one as you read.

Open Claude Code in your project root. From here on, everything starts with /.

/init — generate your CLAUDE.md the right way

The first thing you do in a new project. /init reads the codebase, finds the patterns (framework, conventions, scripts, tests), and writes a CLAUDE.md that gets loaded automatically every future session.

text
/init

Claude will scan the repo, ask a couple of clarifying questions ("is this Next.js App Router or Pages Router?"), and produce a draft. Edit it before you commit. The first draft is usually 80% right and 20% generic — strip the generic and the rest is gold. See how to write a CLAUDE.md that actually works for what to keep and cut.

/compact — keep long sessions on the rails

Long sessions slow down and degrade. Around 70k tokens of context, Claude starts forgetting things you said early. /compact tells Claude to summarize the conversation so far into a short context block, then drops the long history.

text
/compact

Use it when:

  • The session has been running an hour and you can feel it getting fuzzy.
  • You've finished one piece of work and are about to start another in the same session.
  • The status bar warns about context usage.

You can also pass a hint — /compact focus on the auth refactor we just finished — and the summary will weight that over older noise.

/clear — start fresh without leaving the session

Different from /compact. /clear wipes the entire context and starts over with just the CLAUDE.md plus your next prompt. Use it when the work pivot is total ("done with the bug, now let's design a new feature") and the old context would actively mislead.

text
/clear

If you /clear and immediately wish you hadn't, the session history is still in your scrollback — read what you need and paste it into the new prompt.

/agents — define and call subagents

Subagents are scoped helpers — a "code-reviewer" agent, a "test-runner" agent, a "researcher" agent — that Claude can delegate to mid-task. /agents opens the editor for the agent definitions in .claude/agents/.

text
/agents

You'll see existing agents and can add new ones. A useful default: a Plan agent with read-only tools that drafts implementation plans before you write code. Once defined, Claude calls them automatically when the task fits, or you can request one explicitly: "use the Plan agent to design this."

The right number of subagents is small (3–6 max). Each one earns its place by doing something the main agent doesn't do well alone.

/hooks — automate the tedious checks

Hooks are scripts that fire on lifecycle events — before a tool runs, after an edit, on session end. The most useful ones run linters, type checkers, or tests automatically so Claude can't ship broken code without you noticing.

text
/hooks

Common starter hook: a PostToolUse hook on Edit that runs pnpm tsc --noEmit after every code change. If TypeScript breaks, Claude sees the error and fixes it before moving on. See the Claude Code hooks guide for a full setup.

/memory — edit what Claude remembers

The /memory command opens your CLAUDE.md (project + user level) for editing without leaving the session. Use it when Claude does something wrong twice — fix the rule in CLAUDE.md immediately so the third time doesn't happen.

text
/memory

The discipline that makes this powerful: every time you correct Claude in chat, ask "is this a one-off or a pattern?" If it's a pattern, /memory and write the rule down. After two weeks of this, your CLAUDE.md is doing 90% of the steering for you.

/resume — pick up an old session exactly where you left it

Sessions are persisted by default. /resume lists recent sessions across all your projects and lets you jump back into one with full context.

text
/resume

The workflow this enables: end the day with one task in progress, close the laptop, come back the next morning and /resume. Claude has the full history — what you tried, what worked, what's left. No re-explaining.

Verify it worked

Run this short loop in your project to confirm everything's wired:

bash
# In a fresh Claude Code session at your project root:
# 1. /init  — confirm a CLAUDE.md gets generated
# 2. Make any small edit so the session has content
# 3. /compact — confirm the context shrinks
# 4. /memory — confirm CLAUDE.md opens
# 5. /resume in a new session — confirm the old session shows up

If any of those fail, your install is incomplete — reinstall before going further.

Where this breaks

  • /init on a huge monorepo can hang or produce a useless 600-line CLAUDE.md. For monorepos, run /init per package, not at the root.
  • /compact loses nuance. If you compact mid-task, important details from earlier (a specific file path, a precise error message) can drop. Compact between tasks, not during one.
  • Hooks that run slow checks block every tool call. Keep hook scripts under 5 seconds. If your test suite takes 2 minutes, don't run it on every edit — run it on session end.
  • Subagents that overlap fight each other. Two agents both claiming to "review code" means Claude has to pick — and picks badly. Define clear, non-overlapping roles.

What to try next

Want this built for you instead?

Let's talk about your AI + SEO stack

If you'd rather skip the how-to and have it shipped for you, that's what I do. Start a conversation and we'll figure out the fastest path to results.

Let's Talk
Questions from readers

Frequently asked

Do these slash commands work outside the project root?

Most do. /init wants the project root because it scans the whole tree. /memory respects whichever CLAUDE.md is closest to your CWD. /resume works from anywhere.

What's the difference between /compact and /clear?

/compact summarizes the current session into a short context block and drops the long history — you keep the gist. /clear wipes everything and starts fresh from CLAUDE.md. Use /compact between related tasks; use /clear when you're pivoting hard.

Can I create my own slash commands?

Yes. Drop a markdown file in .claude/commands/ with the command name as the filename. The body becomes the prompt. Great for repeated workflows like 'review this PR' or 'audit this file's tests'.

Does /init overwrite an existing CLAUDE.md?

It asks first. If you say yes, it backs up the old one to CLAUDE.md.bak before writing. Always review the diff — /init regenerates from scratch and can drop hand-written rules.

Why does /resume not show all my old sessions?

Default is the last 20 sessions per project. Older ones are still on disk under ~/.claude/projects/<slug>/sessions/ — open them manually if needed.