ServicesAboutNotesContact Get in touch →
EN FR
Note

Claude Code CLI Basics

Installation, essential CLI flags, built-in slash commands, and how to read Claude Code's output — the practical starting point for new users

Planted
claude codeai

Claude Code is Anthropic’s agentic coding assistant that lives in your terminal. It understands your codebase contextually and executes commands on your behalf, with your permission. This note covers the practical mechanics: installing it, launching it, using its built-in commands, and understanding its output.

For what Claude Code is good and bad at in a data context, see Claude Code Strengths and Limitations for Data Work. For what happens under the hood when it runs, see Claude Code Behind the Scenes.

Installation

Claude Code requires Node.js 18 or later. Install it via npm:

Terminal window
npm install -g @anthropic-ai/claude-code

After installation, navigate to any project and type claude to start. First-time users authenticate via browser — Claude Code opens your default browser to complete the sign-in flow. Once authenticated, the credentials persist across sessions.

To verify the installation is healthy, run claude doctor from your project directory. It checks for common configuration issues and reports what it finds.

CLI Flags

When launching Claude Code from the terminal, several flags control behavior before the interactive session starts:

FlagPurposeExample
--helpShow all available optionsclaude --help
--versionDisplay version numberclaude -v
-cContinue your last conversationclaude -c
-pPrint mode (non-interactive, outputs and exits)claude -p "explain this function"
--modelSwitch modelsclaude --model opus
--verboseEnable detailed loggingclaude --verbose

The -c flag is essential for continuity. When you close a session and come back later, claude -c resumes where you left off — same context, same conversation history. Without it, you start fresh and have to re-explain what you were working on.

The -p flag turns Claude Code into a one-shot tool. It takes your prompt, runs it, prints the result, and exits. No interactive session, no follow-up. This is the flag that makes Claude Code composable with other terminal commands.

Piping Content to Claude Code

The -p flag unlocks powerful workflows when combined with the Unix pipe operator:

Terminal window
cat error.log | claude -p "explain these errors"
git diff | claude -p "review these changes"
cat schema.yml | claude -p "find any missing tests"

This pattern feeds the output of one command directly into Claude Code’s prompt, replacing the manual step of copying error messages or code diffs into a chat window.

Built-in Slash Commands

Once you’ve started an interactive session with claude, slash commands control the experience. These are Claude Code’s built-in commands — separate from the custom slash commands you can create for your project.

Session Management

  • /help — Lists all available commands
  • /clear — Wipes conversation history for a fresh start
  • /compact — Summarizes the conversation to free up context window
  • /exit or /quit — Quit Claude Code

Context and Configuration

  • /init — Generates a CLAUDE.md file describing your project (though starting without one and building it reactively is often better)
  • /config — Opens settings interface
  • /model — Switch between AI models mid-session
  • /permissions — View and adjust permissions

Development Tools

  • /review — Request a code review
  • /doctor — Diagnose installation problems
  • /cost — Show token usage for current session

The /compact Command

/compact deserves special attention because it solves a real problem. As conversations grow long, Claude’s context window fills up. When the context is full, Claude starts losing track of earlier parts of the conversation — it might forget a constraint you mentioned, repeat work it already did, or lose the thread of a complex task.

Running /compact summarizes the conversation history and replaces the full transcript with a condensed version. The result: Claude retains the key decisions and context without the verbatim history consuming window space.

The optional focus parameter makes this even more useful:

/compact focus on the authentication code

This tells Claude what to prioritize when compressing. The summary will keep details about authentication and compress or discard less relevant parts of the conversation. Without the focus parameter, Claude makes its own judgment about what’s important — which is usually fine but not always aligned with what you need next.

Use /compact proactively, not reactively. If you know a session will be long, compact every 30-40 minutes. Don’t wait until Claude starts exhibiting signs of context loss (repetition, forgotten constraints, regressing on earlier decisions).

Reading Claude Code’s Output

When Claude Code runs commands, you’ll see structured output:

⏺ Running: git status
Description: Shows working tree status

Claude Code shows you exactly what it wants to do before doing it. For tool operations, you get a clear description of the action. This transparency is fundamental to the trust model — you’re not blindly approving operations.

The Permission Model

Claude Code requests permission before executing anything that modifies files or runs potentially impactful commands. You have three options:

  • Accept once — approve this specific operation
  • Accept always — approve this type of operation for the rest of the session
  • Deny — block the operation

“Accept always” is a time-saver for operations you trust — like file reads or git status checks. But for anything that writes, deletes, or runs scripts, reviewing each request individually is the safer approach until you understand the patterns.

Always read what Claude Code wants to do before approving. The tool is powerful precisely because it can execute real commands. That power requires your attention.

Keyboard Shortcuts Within Claude Code

ShortcutAction
EscapeStop Claude’s current generation
Ctrl+C twiceForce exit
TabToggle extended thinking display
Shift+TabCycle through modes

The Escape key is the most useful — it stops Claude mid-generation without killing the session. If you see Claude heading in the wrong direction, hit Escape, correct the course, and continue. Ctrl+C twice is the hard exit when you want to leave the session entirely.

Your First Session

Once you’re past installation, a good first session looks like:

  1. Navigate to a project directory: cd ~/projects/your-project
  2. Start Claude Code: claude
  3. Ask it to explain the project: “What does this project do? Describe the structure.”
  4. Make a small change: “Add a comment to the main entry point explaining what it does.”
  5. Check the result: review the proposed changes, approve them, verify the output.
  6. Ask Claude to explain something you don’t understand: “What does this function do?” or “Why is this file structured this way?”

Start with read-only tasks (explanations, code reviews) before moving to modifications. This builds familiarity with the permission model and output format before any risk of unintended changes.

Once you’re comfortable with the basics, building a CLAUDE.md for your project is the single highest-impact next step.