โ† Back to Hub Tool Reference
โŒจ๏ธ

Claude Code CLI

The command-line interface that turns Claude into an interactive coding partner โ€” reads your files, runs commands, and builds software alongside you in the terminal.

Interactive File-aware Session-based Cross-platform

๐Ÿ“– What It Is

Claude Code CLI (claude) is a terminal program that opens a conversation with Claude inside your project directory. Unlike the web interface, it can read your files, run shell commands, write code, and remember your project context across an entire session.

You launch it with claude in any folder. From that point Claude can see every file in your project, execute terminal commands with your permission, and build things alongside you โ€” not just describe them.

terminal
# Install
npm install -g @anthropic-ai/claude-code

# Launch in your project folder
cd ~/my-project
claude

# Or launch with an immediate task (non-interactive)
claude --print "List all TODO comments in this codebase"

โšก Essential Slash Commands

CommandWhat it does
/helpShow all available commands and keyboard shortcuts
/statusShow current model, context usage, and session info
/modelSwitch between Opus, Sonnet, or Haiku mid-session
/compactCompress conversation history to free up context window
/clearWipe session history and start fresh (keeps project files)
/reviewAsk Claude to audit the current project for issues
/initGenerate a CLAUDE.md for the current project
/configOpen Claude Code settings

๐Ÿš€ 5 Real Examples

Example 01

Debug a failing test without reading the code yourself

Open Claude in your project and describe the failure. Claude reads the test file, the source file, and the error โ€” then explains and fixes it.

promptMy test suite is failing with "TypeError: Cannot read property 'id' of undefined" in user.test.js. Find the root cause and fix it.
Example 02

Refactor a file while preserving all behavior

Point Claude at a specific file and tell it exactly what to change. The constraint "don't change behavior" keeps the refactor safe.

promptRefactor @utils/auth.js โ€” extract each validation rule into its own named function. Don't change any behavior or return values.
Example 03

Generate a full feature from a one-line spec

Describe the feature clearly โ€” stack, behavior, files. Claude scaffolds everything: route, controller, model, tests.

promptAdd a POST /api/invites endpoint. It accepts an email, creates an invite record in SQLite, sends a confirmation (console.log for now), and returns the invite token. Include a test.
Example 04

Audit the whole codebase for a specific issue

Use the --print flag to run a one-shot audit without opening an interactive session. Great for CI or quick checks.

terminal
claude --print "Audit every JS file for missing error handling on async functions. List file:line for each issue."
Example 05

Document an undocumented codebase in one session

Drop Claude into a legacy project and ask it to read, understand, and document what it finds. Saves hours of archaeology.

promptRead every file in src/ and write a CLAUDE.md that explains what this project does, what each file's role is, and the data flow from entry point to output.
โšก Interactive Sandbox simulated
Try common CLI commands
Claude Code CLI โ€” sandbox
Click a command below or type your own.
 
claude $
Pro tip: Add alias c="claude" to your shell profile. Two keystrokes to launch Claude in any project.