Core commands in Claude Code

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

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. Let's explore 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:

/add src/components/**/*.tsx # Tất cả các file TSX trong components /add tests/*.test.js # Tất cả các file kiểm thử /add **/*.md # Tất cả các file markdown

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/* > Hãy thêm cache vào lớp tìm nạp dữ liệu

Delete all related files or specific tasks.

Refresh the context mid-way.

/compact /add src/new-file-i-need.js > Tiếp tục với việc triển khai cache. Bây giờ hãy tích hợp với file mới này.

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

Explore an unfamiliar codebase.

/add README.md package.json > Dự án này làm gì và công nghệ sử dụng là gì? /add src/index.js src/app.js > Hãy cho tôi biết các điểm truy cập chính

Start with an overview, then narrow it down.

Think before you commit.

/add $(git diff --name-only) > Xem lại những thay đổi này. Có lỗi hoặc vấn đề gì không?

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:

> Tại sao hàm này không hoạt động?

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

Forget what's in context:

# Sau nhiều lệnh /add. > Tại sao bạn lại tham chiếu đến file cũ đó?

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

 

Use /clear when /compact is functional:

/clear # Bây giờ tôi phải thêm lại mọi thứ và giải thích lại nhiệm vụ

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

Quick reference to commands

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.

-- / --

You've just finished reading the article "Core commands in Claude Code" edited by the TipsMake team. We hope this article has provided you with many useful tech tips and tricks. You can search for similar articles on tips and guides. Thank you for reading and for following us regularly.

Related posts
Other Technology articles
Category

System

Windows XP

Windows Server 2012

Windows 8

Windows 7

Windows 10

Wifi tips

Virus Removal - Spyware

Speed ​​up the computer

Server

Security solution

Mail Server

LAN - WAN

Ghost - Install Win

Fix computer error

Configure Router Switch

Computer wallpaper

Computer security

Mac OS X

Mac OS System software

Mac OS Security

Mac OS Office application

Mac OS Email Management

Mac OS Data - File

Mac hardware

Hardware

USB - Flash Drive

Speaker headset

Printer

PC hardware

Network equipment

Laptop hardware

Computer components

Advice Computer

Game

PC game

Online game

Mobile Game

Pokemon GO

information

Technology story

Technology comments

Quiz technology

New technology

British talent technology

Attack the network

Artificial intelligence

Technology

Smart watches

Raspberry Pi

Linux

Camera

Basic knowledge

Banking services

SEO tips

Science

Strange story

Space Science

Scientific invention

Science Story

Science photo

Science and technology

Medicine

Health Care

Fun science

Environment

Discover science

Discover nature

Archeology

Life

Travel Experience

Tips

Raise up child

Make up

Life skills

Home Care

Entertainment

DIY Handmade

Cuisine

Christmas

Application

Web Email

Website - Blog

Web browser

Support Download - Upload

Software conversion

Social Network

Simulator software

Online payment

Office information

Music Software

Map and Positioning

Installation - Uninstall

Graphic design

Free - Discount

Email reader

Edit video

Edit photo

Compress and Decompress

Chat, Text, Call

Archive - Share

Electric

Water heater

Washing machine

Television

Machine tool

Fridge

Fans

Air conditioning

Program

Unix and Linux

SQL Server

SQL

Python

Programming C

PHP

NodeJS

MongoDB

jQuery

JavaScript

HTTP

HTML

Git

Database

Data structure and algorithm

CSS and CSS3

C ++

C #

AngularJS

Mobile

Wallpapers and Ringtones

Tricks application

Take and process photos

Storage - Sync

Security and Virus Removal

Personalized

Online Social Network

Map

Manage and edit Video

Data

Chat - Call - Text

Browser and Add-on

Basic setup