M
MeshWorld.
AI Cheatsheet Claude Code CLI Developer Tools 3 min read

Claude Code CLI Cheatsheet (2026 Edition)

Vishnu
By Vishnu

Anthropic’s claude-code CLI is the definitive tool for developers who hate leaving their terminal. Unlike IDE plugins that fight for sidebar space, Claude Code runs directly in your shell, executing git commands, reading files, and running your test suite natively.

Here is the no-nonsense cheatsheet for surviving and thriving with Claude Code in 2026.

Core Setup & Launch

# Global installation (requires Node 20+)
npm install -g @anthropic-ai/claude-code

# Authenticate (opens browser)
claude login

# Launch the interactive REPL in the current directory
claude

# Run a single command without entering the REPL
claude -p "Find all instances of 'any' in src/ and replace with proper types"

The Interactive REPL Commands

Once you are inside the > claude REPL, you aren’t just typing prompts; you have access to specific slash commands to manage the session.

CommandAction
/helpShows all available slash commands.
/clearWipes the current context window (crucial for long sessions).
/compactSummarizes the current conversation to save token space.
/historyView previous interactions in this project.
/modelSwitch between claude-3-7-sonnet (default coding) and claude-3-opus.
/costView the token usage and estimated cost of the current session.
/exitQuit the CLI.

The Scenario: You’ve been debugging a messy Next.js routing issue for an hour. The REPL is lagging, and Claude is starting to suggest weird, unrelated changes to your database. Your context window is full of garbage. You type /compact. Claude summarizes the 50-message thread into a 500-word state, freeing up 90% of your context window so you can finally fix the bug without restarting entirely.

Context Management (The CLAUDE.md File)

The biggest mistake beginners make is pasting the same rules into the CLI every day.

Create a CLAUDE.md file in the root of your project. The CLI reads this file automatically every time it boots up in that directory.

Example CLAUDE.md:

# Project Context
This is a Next.js 15 App Router project using Tailwind CSS and Drizzle ORM.

## Coding Standards
1. Use Server Components by default.
2. Only use `'use client'` if `useState` or `useEffect` is required.
3. Use Lucide React for all icons.

## Build Commands
- Dev server: `bun run dev`
- Tests: `bun test`
- Lint: `bun run lint`

Flag Overrides (One-Off Executions)

If you use the -p (prompt) flag, you can pass contextual flags to restrict or guide the agent.

# Force the agent to ask for permission before running ANY terminal command
claude -p "Install the stripe SDK and wire it up" --danger-require-approval

# Pass specific files into context before the prompt
claude -f src/api/stripe.ts -p "Add error handling to this webhook"

# Ignore certain directories (overrides .gitignore)
claude --ignore "tests/**/*.ts" -p "Refactor the auth flow"

Agentic Workflows

Claude Code shines when you let it run tasks autonomously.

The “Test-Driven” Loop:

“Write a test for the calculateTax function. Run bun test. If it fails, fix the function until the test passes.”

The “Git Archaeologist”:

“Find the commit that broke the UserAvatar component. Look at the git log, checkout the files, and tell me who changed it and why.”

The “Documentation Writer”:

“Read the entire src/utils/ directory. Generate a Markdown table documenting every exported function, its parameters, and its return type. Save it to UTILS.md.”


Found this useful? Check out our guide on Cursor vs. Claude Code.