Master Claude Code: From Installation to Advanced CLI Commands

This article examines Claude Code's market dominance, core design philosophies, step‑by‑step installation, extensive CLI and slash commands, shortcut keys, work modes, strengths and weaknesses, and a complete Spring Boot authentication module workflow, providing concrete examples and performance data.

Su San Talks Tech
Su San Talks Tech
Su San Talks Tech
Master Claude Code: From Installation to Advanced CLI Commands

Introduction

In the 2026 AI programming‑tool market, Claude Code leads with 46% user preference according to The Pragmatic Engineer’s March 2026 survey of 906 developers, far ahead of Cursor (19%) and GitHub Copilot (9%). Adoption in small‑ and medium‑size companies reaches 75%, with developers noting that “OpenClaw does the junior work, Hermes is the senior.”

Core Value of Claude Code

Claude Code, launched by Anthropic in 2025, differs from traditional VS Code plugins and web chat windows by operating directly in the terminal, reading project files, executing shell commands, and manipulating Git repositories.

Its advantage over competitors stems from three design philosophies:

Multi‑Agent Parallel Architecture : ~40 built‑in tools and a 46,000‑line query engine enable sub‑agents to collaborate on complex tasks.

Progressive Context Management : Layered memory and smart compression maintain context quality while dramatically reducing token consumption.

Deep Repository Operations : Native support for cross‑file edits, Git workflow integration, and fine‑grained permission control.

The following architecture diagram (illustrated in the images) shows the full command hierarchy.

Installation and Environment Configuration

Claude Code requires Node.js 18+. Verify with:

node --version
# If not installed, download from https://nodejs.org

macOS/Linux/WSL

# Install stable version
curl -fsSL https://claude.ai/install.sh | bash

# Install latest version
curl -fsSL https://claude.ai/install.sh | bash -s latest

# Homebrew alternative
brew install --cask claude-code

Windows (requires Git for Windows or WSL)

# Run in CMD or PowerShell
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

NPM (all platforms)

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

Verify installation:

claude --version
# If a version number appears, the install succeeded

First launch guides you through authentication and workspace trust. Chinese users on Alibaba Cloud Baidu Coding Plan must set environment variables, e.g.:

mkdir -p ~/.claude
nano ~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_Key",
    "ANTHROPIC_BASE_URL": "https://coding.dashscope.aliyuncs.com/apps/anthropic",
    "ANTHROPIC_MODEL": "qwen3.6-plus"
  }
}

CLI Command Quick Reference

claude

– Start an interactive REPL in the current directory (daily multi‑turn development). claude "task description" – Launch with a question and begin analysis immediately (quick query). claude -p "query" – Execute once, exit, and print the result (scripted/automation). claude -c – Continue the most recent conversation in the current directory (morning startup).

Example usage:

# 1. Interactive mode – daily development favorite
claude
> Please analyze the project’s code structure

# 2. Question‑driven start – fast ask
claude "Explain the authentication flow of this project"

# 3. One‑off execution – CI/CD scripts
claude -p "Check code style issues" >> review.log

# 4. Resume session – continue yesterday’s bug fix
claude -c

Advanced CLI Parameters

--add-dir

– Add extra work directories (essential for monorepos). Example:

claude --add-dir ../lib ../apps
--model sonnet/opus

– Choose the model for the current session. Example:

claude --model opus
--verbose

– Enable detailed logs showing tool execution. --dangerously-skip-permissions – Skip all permission confirmations (use only in sandbox experiments). --system-prompt – Replace the default system prompt entirely. --append-system-prompt – Append custom content to the default prompt.

Real‑world scenario – Monorepo cross‑directory access :

# When handling a microservice or multi‑package project, let Claude see multiple codebases
claude --add-dir ../shared-lib ../api-gateway
# Claude can now understand cross‑package call logic

Real‑world scenario – Pipe input :

# Feed a log file directly to Claude for analysis
cat logs/error.log | claude -p "Analyze these errors and identify the most likely root cause"

Slash Commands (Core Operations)

Claude Code provides over 70 slash commands (including aliases and bundled skills). They are grouped into seven modules.

Conversation & Context Management

/help

– Show all available commands and shortcuts (when you can’t recall a command). /clear – Completely erase conversation history for a brand‑new task. /compact – Compress history while retaining core summaries (use when token usage approaches limits). /context – Visualize current token usage; monitor and compress at 70‑80% usage. /resume – Restore a previous conversation (useful for parallel tasks). /rewind – Undo the last AI modification (press ESC twice).

/compact vs /clear : /compact – Compresses and keeps key context (e.g., design decisions) for continuing the same task. /clear – Hard reset, removes all history for a completely different task.

# Scenario: after an hour of dialogue Claude starts forgetting earlier decisions
/context   # check usage; if >80% then compress
/compact retain the authentication patterns and API design decisions

# Scenario: start a brand‑new task
/clear   # hard reset

Git & Code Operations

/commit

– Analyze staged changes and auto‑generate a commit message (e.g., "feat: add user authentication module"). /review – Review current changes, flag bugs and style issues before a PR. /diff – Show the current git diff. /branch – Create or switch git branches. /pr_comments – Fetch and display open PR review comments.

# 1. Auto‑generate commit message
git add .
/commit   # Claude suggests "feat: add user authentication module"

# 2. Pre‑PR code review
/review   # Claude points out naming, missing exception handling, potential null pointers

Memory & Configuration Management

/init

– Generate an initial CLAUDE.md project knowledge base. /memory – Edit the persistent CLAUDE.md file (e.g., update project rules). /model – Switch models within a session (Sonnet, Opus, Haiku). /config – View or modify runtime parameters. /cost – Show current token usage and cost. /stats – Display session statistics.

Core tip – Power of CLAUDE.md :

/init   # creates CLAUDE.md with project description, tech stack, code style, patterns
# Example CLAUDE.md snippet
## Tech Stack
- Java 17 + Spring Boot 3.x
- JWT Token authentication stored in httpOnly cookies
- JUnit 5 + Mockito
## Code Conventions
- Use async/await instead of promises
- All API endpoints must have tests
- Errors returned as { error: string, code: number }
## Project Structure
- src/main/java/com/example/controller
- src/main/java/com/example/service
- src/main/java/com/example/repository

With CLAUDE.md, Claude reads the file on every interaction, eliminating ~80% of repetitive context setup.

Diagnostics & Authentication

/doctor

– Check environment, authentication, and network connectivity. /version – Show installed version. /login – Log in to an Anthropic account. /logout – Log out (switch accounts). /upgrade – Upgrade to the latest version.

Integration & Extension

/mcp

– Manage MCP server connections (external tools like GitHub, databases). /skills – List and manage reusable skill packages. /hooks – Configure automation hooks (e.g., auto‑format with Prettier after file writes).

Shortcut Keys – Efficiency Magic

Conversation Control

Ctrl+C

– Interrupt current generation or command (when AI goes off‑track). Ctrl+D – Safely exit Claude Code. Ctrl+L – Clear screen while preserving context. Ctrl+T – Switch task list, view background tasks. Ctrl+R – Reverse‑search command history.

Operation Acceleration

Shift+Tab

– Cycle through three work modes (Plan, Default, Auto‑Accept). Esc (twice) – Undo the last AI action. Ctrl+B – Send current task to background while continuing discussion. Alt+V – Paste an image (Windows) for Claude to analyze UI or error screenshots.

Input Box Shortcuts

Shift+Enter

– Insert a newline without sending. Ctrl+W – Delete the previous word. Ctrl+U – Delete the entire line. Ctrl+K – Clear the current input field.

Advanced Trick – Bash Prefix

Prefix a command with ! to execute it directly in the shell, bypassing the AI and saving tokens.

# Direct Bash execution
! git status
! npm run test
! ls -la

Three Work Modes Explained

Default – Every file edit or command requires confirmation (ideal for production projects where you need control).

Auto‑Accept – File modifications are applied automatically; shell commands still need confirmation (fast iteration, trust AI for routine ops).

Plan – Read‑only mode; Claude only analyses and proposes plans without making changes (use to review designs before execution).

Best practice : generate a detailed plan in Plan mode, confirm it, then switch to Auto‑Accept for execution.

Advanced Features: Skills, Agents, and MCP

Skills (Reusable Skill Packs)

Skills are packaged capabilities akin to plugins. For example, a “Run Tests” skill can detect project structure, run tests, parse output, and summarize failures. Create a custom skill by placing a SKILL.md file in ~/.claude/skills/.

Agents (Autonomous AI Entities)

Agents can plan, execute, reflect, and iterate toward a goal without constant prompts. Example: tell an Agent to “fix this GitHub issue”; it reads the issue, runs tests, locates the bug, generates a fix, and opens a PR with an explanation.

MCP (Model Context Protocol)

MCP lets Claude Code connect to external services (GitHub, databases, etc.) via the /mcp command. However, the author notes that using CLI + Skills often replaces MCP, saving token space.

Pros and Cons

Advantages

Strong Agent Capability : 67% win rate over Cursor in code quality, correctness, and completeness tests.

Cross‑File Refactoring : Understands tens of thousands of lines and performs consistent multi‑file refactors.

Low Memory Footprint : Hierarchical memory compression keeps token usage efficient.

Deep Git Integration : Auto‑generates commit messages, conducts code reviews, manages PRs.

Model Flexibility : Sonnet for everyday coding, Opus for complex architecture, Haiku for rapid exploration.

Disadvantages

Steep Learning Curve : Mastering the myriad commands and shortcuts is required for full productivity.

Terminal‑Only : No graphical UI, which may deter developers unfamiliar with CLI.

Token Cost : Heavy usage can consume many tokens; careful planning is needed.

Limited Windows Support : Requires WSL or Git Bash; native support is incomplete.

Applicable Scenarios

Large‑scale project development (cross‑file refactoring, architecture understanding, complex bug fixing).

Automation workflows (CI/CD integration, code review, PR management).

Parallel multitasking (background task handling).

Monorepo or microservice environments (use --add-dir to access multiple modules).

Practical Workflow Example: Building a Spring Boot Authentication Module

Assume you want to create a JWT‑based authentication feature. The end‑to‑end flow is:

Start Claude Code and initialize the project knowledge base.

# Enter project directory
cd my-spring-boot-project

# Launch Claude
claude

# Initialize project knowledge
/init

# Add authentication rules to memory
/memory
# (Claude now knows the coding standards for the auth module)

Switch to Plan mode and request a design document.

Shift+Tab   # Switch to Plan mode
> Please design a JWT authentication module with registration, login, and token refresh, and output a design doc for review.

After reviewing, switch to Auto‑Accept and let Claude implement the design.

Shift+Tab   # Switch to Auto‑Accept
> Implement the design as described.

Review changes, generate a commit, and push.

/diff      # View changes
/review    # Claude points out naming and error‑handling issues
/commit    # Auto‑generated message like "feat: add user authentication module"

Run background compilation while continuing discussion. Ctrl+B # Send compilation to background When the conversation grows long, check token usage and compress or clear as needed.

/context   # Show token usage
/compact retain the authentication module design and API specs
/clear     # Start a completely new task if needed

The accompanying diagram (image) visualizes this workflow.

Conclusion

Claude Code’s command set is extensive, but mastering roughly 30% of the commands covers over 80% of everyday development scenarios. Prioritize session management commands ( /init, /compact, /clear, claude -c), Git‑related commands ( /commit, /review), model switching ( /model, /memory), and advanced extensions ( /mcp, /skills) to unlock its full potential as a “all‑purpose development partner.”

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLIDevelopmentAIProductivityTooling
Su San Talks Tech
Written by

Su San Talks Tech

Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.