The Complete Claude Code CLI Cheat Sheet and Guide for 2025

Ever feel like you’re juggling a dozen tasks at once? From writing new features and debugging tricky issues to managing deployments and reviewing pull requests, a developer’s work is never done.

Meet Claude Code, the command-line interface (CLI) for Anthropic’s powerful AI models. It’s designed by developers, for developers, to bring state-of-the-art AI directly into the environment you know and love: the terminal.

This guide will take you from a complete beginner to a Claude Code power user.

We’ll walk through everything from installation to advanced integrations, showing you how to make this tool an indispensable part of your daily toolkit. Let’s dive in!

This article also shares more tips about how to use Claude.

Getting Started: Your First Five Minutes

Before we can start working magic, we need to get Claude Code installed on your system. Don’t worry, it’s a straightforward process.

What You’ll Need:

  • Node.js (version 18 or higher)
  • The npm package manager (this comes with Node.js)
  • Access to your terminal

Installation Steps:

Ready? Just open your terminal and run this simple command to install Claude Code globally on your machine.

# Install Claude Code globally
npm install -g @anthropic-ai/claude-code

# Check that it installed correctly
claude --version

The first time you run a command, Claude Code will prompt you to log in with your Anthropic account. It will open a browser window for you to authenticate, securely linking the CLI to your account.

See also: Mastering the Linux Command Line — Your Complete Free Training Guide

Having Your First Conversation

Now for the fun part! You can start interacting with Claude in a few different ways.

The most common way is to start an interactive session, which feels like having a chat.

# Start a new interactive conversation
claude

You can even kick off the conversation with a specific request. This is great for jumping right into a problem.

# Start a new conversation with an initial prompt
claude "Help me set up a Kubernetes deployment"

In a hurry? You can also get a direct answer without entering an interactive session. Claude will process your request, give you the output, and then exit.

# Direct query mode - execute once and exit
claude -p "Analyze the database schema in this project"

Navigating Your Session: Core Commands

Once you’re in an interactive session, you have a handy set of slash commands to manage your workflow. Think of these as your control panel for the conversation.

  • /clear: Wipes the current conversation history. Perfect for when you want to start a fresh topic without any leftover context.
  • /exit: Ends the current session and returns you to your terminal prompt.
  • /help: Displays a list of all available commands.
  • /status: Shows your account info and system details.
  • /cost: Curious about your token usage? This command gives you the stats.

These simple commands give you full control over your interaction, making it easy to keep things organized.

Never Lose Your Train of Thought: Session Management

We’ve all been there—you’re deep into solving a problem, then get pulled away.

Coming back later, you struggle to remember where you left off. Claude Code solves this with powerful session management.

You can easily pick up right where you were.

# See a list of your recent sessions and choose one to resume
claude --resume

# Or continue the most recent session instantly
claude --continue

# You can even resume a specific session if you know its ID
claude -r session-id-here

This feature is a lifesaver. It turns Claude from a simple Q&A tool into a persistent coding partner that remembers the context of your projects across multiple sessions.

Becoming a Power User with CLI Flags

While the interactive mode is fantastic, the real power of a CLI tool comes from its command-line flags. These let you fine-tune Claude’s behavior for specific tasks.

Choosing Your Brain:

You can select different AI models depending on your needs. Sonnet is great for everyday tasks, while Opus is a powerhouse for highly complex problems.

# Use the latest Sonnet model
claude --model sonnet

# Use the latest Opus model
claude --model opus

Working with Your Project:

Need Claude to see files outside your current directory? No problem.

# Give Claude access to your frontend and backend folders
claude --add-dir ../frontend --add-dir ../backend

Formatting the Output:

Sometimes you need a structured response, especially for automation. You can ask Claude to format its output in JSON.

# Generate API documentation in JSON format
claude -p "generate API documentation" --output-format json

Supercharging Claude: Integrating External Tools with MCP

This is where things get really exciting. The Model Context Protocol (MCP) is a system that allows Claude Code to securely interact with other tools and services. Think of it as giving Claude “hands” to work with your local files, your GitHub repositories, or even your databases.

Setting Up an MCP Server:

You can add different “servers” that grant Claude new abilities. For example, let’s add the filesystem server to let Claude read and write local files.

# Add the filesystem server to access a specific project path
claude mcp add filesystem -- npx @modelcontextprotocol/server-filesystem /path/to/project

There are many available servers you can add to your toolkit:

  • GitHub: To interact with issues, pull requests, and repos.
  • SQLite: To query and manage databases directly.
  • Puppeteer: For web automation and testing.
  • AWS Serverless: To manage your Lambda and serverless operations.

Once a server is set up, you can talk to it using natural language. It’s incredibly intuitive.

# Ask Claude to perform actions using its new tools
claude "Show me GitHub issue #123"
claude "Take a full-page screenshot of <https://example.com>"
claude "Read the Button.tsx component file for me"

This transforms Claude from a chatbot into an active participant in your development workflow, capable of performing real actions on your behalf.

Teaching Claude to Remember: Project Memory

Tired of re-explaining your project’s architecture or coding standards every time you start a new session? Claude Code has a brilliant solution: Project Memory.

By creating a CLAUDE.md file in your project’s root directory, you can give Claude a persistent “brain” for that specific project.

You can create this file automatically by running:

claude /init

Then, you can open the file (or run claude /memory) and add crucial context.

Example CLAUDE.md:

# Project: E-commerce API

## Architecture
- Node.js with Express framework
- PostgreSQL database with Prisma ORM
- Docker for containerization

## Coding Standards
- Use TypeScript for all new code.
- Write unit tests for all business logic.

Even better, during any interactive session, you can add to this memory on the fly by starting your message with a #.

> # This project uses JWT tokens with a 24-hour expiration.

This line will be automatically saved to your CLAUDE.md file. Now, Claude will always remember this detail in future conversations, saving you tons of time and repetition.

Beyond the Basics: Advanced Integrations

Claude Code isn’t just a standalone tool; it’s designed to be integrated into your broader development and automation workflows.

Git Integration:

This is a developer favorite. You can pipe your Git commands directly into Claude to automate common tasks. For example, want to generate release notes from your latest commits? It’s this easy:

git log --oneline -n 10 | claude -p "Create release notes from these commits"

Claude will analyze the commit messages and generate a clean, formatted set of release notes for you. You can use this for reviewing pull requests, helping with merge conflicts, and more.

CI/CD and Automation:

You can embed Claude Code into your continuous integration and deployment pipelines.

  • Analyze Test Failures: Pipe test logs into Claude and ask it to explain the failures and suggest fixes.
  • Automate Code Reviews: Use a script to have Claude review changes and flag potential issues.
  • Generate Documentation: Ask Claude to create API documentation from your codebase as part of your build process.

Final Tips and Best Practices

To get the most out of Claude Code, keep these guidelines in mind:

  • Be Security-Conscious: Avoid using flags like -dangerously-skip-permissions in production. Always define which tools Claude is and isn’t allowed to use.
  • Keep Context Clean: Use the /clear command between unrelated tasks to prevent confusion and improve performance.
  • Collaborate with Your Team: Share your custom commands and MCP configurations by committing the .claude/ directory to your version control. This ensures everyone on the team has the same superpowers.

Claude Code is more than just a novelty; it’s a powerful, practical tool that can genuinely enhance your productivity and creativity. By bringing AI into the comfort of your terminal, it allows you to stay focused, automate tedious tasks, and solve complex problems faster than ever before.

So go ahead, give it a try, and see how it can transform your workflow. Happy coding

David Cao
David Cao

David is a Cloud & DevOps Enthusiast. He has years of experience as a Linux engineer. He had working experience in AMD, EMC. He likes Linux, Python, bash, and more. He is a technical blogger and a Software Engineer. He enjoys sharing his learning and contributing to open-source.

Articles: 546

Leave a Reply

Your email address will not be published. Required fields are marked *