Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Core Commands in Claude Code

These are the essential slash commands you will use in every Claude Code session. Read the key facts, context, and practical takeaways.

Table of Contents

These are the essential slash commands you will use in every Claude Code session. Read the key facts, context, and practical takeaways.

These are the essential slash commands you will use in every Claude Code session.

The Commands You Will Use Daily

Claude Code has many commands. Most sessions use a few familiar commands. We will examine those commands first.

File Context Commands

/add

Add the file to Claude's context. This is probably the command you'll use most often.

Basic usage instructions:

/add src/auth.js

Add more files:

/add src/auth.js src/user.js src/session.js

Add more glob patterns:

English example text

When to use:

  • Before asking questions about specific code.
  • Before requesting changes to a file
  • When Claude needed to understand how the files worked together.

Helpful tip : Add the file BEFORE asking the question. Claude will give a better answer once he's seen the actual code.

/ls

List the files in context.

/ls

This displays what Claude currently knows. Use this command to verify that your /add commands worked or to see what has accumulated in the context.

Conversation Management

/clear

Completely delete your conversation history.

/clear

When to use:

  • Start a completely new task.
  • The context becomes muddled with irrelevant history.
  • Claude was confused or gave inconsistent feedback.
  • You want to start over without restarting Claude Code.

Warning : This action is irreversible. Everything from the current session will be deleted.

/compact

Summarize the context to reduce the file size while retaining key information.

/compact

When to use:

  • The context is getting bigger, but you want to keep working.
  • Claude refers to the possibility of reaching the contextual limit.
  • Responses are slowing down.

The difference compared to /clear: Compact retains the essence of what you discussed. Clear deletes everything.

/undo

Restore Claude's final actions.

/undo

When to use:

  • Claude has made changes that you didn't want.
  • You want to try a different approach.
  • Something is wrong.

Faster than undoing changes manually.

Help and Explore

/help

Display available commands.

/help

The commands change with updates. /help always displays what is currently available.

/status

Display the current session status.

/status

Displays contextual usage levels, active files, and other session information.

Actual Samples

Start a New Mission

/clear /add src/feature-im-working-on/* >English example text

Delete all related files or specific tasks.

Refresh the Context Mid-way

/compact /add src/new-file-i-need.js >English example text

Compact helps preserve history. Add new context. Continue from where you left off.

Explore an Unfamiliar Codebase

/add README.md package.json > Du an nay lam gi va cong nghe su dung la gi? /add src/index.js src/app.js >English example text

Start with an overview, then narrow it down.

Think Before You Commit

/add $(git diff --name-only) >English example text

Only add the changed files. Consider focusing on them.

Common Mistakes

Adding too much:

/add src/**/*

Don't include your entire source code. The context is limited. Be selective.

Not enough added:

>English example text

Claude can't see the function. Please add the file first.

Forget what's in context:

# Sau nhieu lenh /add. >English example text

Use /ls to see what's actually in the context. Use /clear if it's too cluttered.

Use /clear when /compact is functional:

English example text

If you want to preserve the session context but reduce its size, use /compact instead of /clear.

Quick Reference to Commands

Command Its function When should it be used?
/add Add files to the context. Before performing any specific tasks related to files
/ls List the context files. To check what Claude saw.
/clear Delete the conversation A new beginning with a new mission.
/compact Context summary Reduce in size, retain the essence.
/undo Undo the last action Claude made an unwanted change.
/help Display commands Discover or verify commands
/status Display session status Check the usage in context.

Exercise

Open Claude Code in a project and practice:

  1. Add some source files using the /add command.
  2. Use the /ls command to verify if they are in context.
  3. Ask questions about the code.
  4. Use the /compact command to see how it's summarized.
  5. Use the /clear command and notice the difference.

Familiarize yourself with these commands before proceeding. They are fundamental to everything else.

Key Points to Remember

  • /add is your most important command - provide Claude with the appropriate files.
  • /clear to start over, /compact to reduce the size while retaining context.
  • Check what's in the context using the /ls command when confused.
  • /undo is faster than manually undoing.
  • Less is more: Being selective about context is better than dumping everything in.
  • Question 1:

    What should you do when Claude's feedback starts to become confusing or inconsistent?

    EXPLAIN:

    A cluttered context often leads to confusing responses. Clearing or simplifying the context will provide Claude with a cleaner platform to work on.

  • Question 2:

    When should you use '/add' with a glob template like 'src/**/*.ts'?

    EXPLAIN:

    The glob template allows you to add multiple related files at once, which is useful when Claude needs to understand how the files work together.

  • Question 3:

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

    EXPLAIN:

    /clear completely deletes the conversation history. /compact summarizes the context to retain important information while minimizing token usage.

Training Results

You have completed 0 questions.

-- / --

FAQ

What is the main point of core commands in claude code?

These are the essential slash commands you will use in every Claude Code session. Read the key facts, context, and practical takeaways.

Why is this development important?

Key takeaway: These are the essential slash commands you will use in every Claude Code session.

What are the key takeaways?

These are the essential slash commands you will use in every Claude Code session.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.