Claude Code
Anthropic's Official AI Coding Assistant CLI
Claude Code is an AI-powered coding assistant that runs directly in your terminal. It supports code writing, debugging, refactoring, documentation, and various development tasks.
๐ Quick Start
npm install -g @anthropic-ai/claude-code claude ๐ป CLI Options
| Command | Description |
|---|---|
claude | Start interactive REPL session |
claude "query" | Start with initial prompt |
claude -p "query" | Non-interactive mode (print and exit) |
claude -c | Continue last conversation |
claude -r "sessionID" | Resume specific session |
claude --model opus | Use specific model (opus, sonnet, haiku) |
claude --verbose | Enable verbose logging |
claude --dangerously-skip-permissions | Skip permission prompts (use with caution) |
/ Slash Commands
Session Management
/clear Clear conversation and start fresh /compact Summarize context to save tokens /memory Edit CLAUDE.md memory file /model Change AI model System & Help
/help Show available commands /config View and modify settings /cost Check token usage and cost /doctor Diagnose installation status Development Tools
/review Review current changes /pr-comments View GitHub PR comments /init Initialize CLAUDE.md in project Configuration
/login Login to Anthropic account /logout Logout from account /vim Toggle Vim keybindings โจ๏ธ Keyboard Shortcuts
๐ง Available Tools
Built-in tools that Claude Code uses automatically.
Read Read file contents. Supports images, PDFs, Jupyter notebooks
Write Create new files or overwrite existing ones
Edit Modify specific parts of existing files (string replacement)
Bash Execute shell commands (git, npm, docker, etc.)
Glob Find files by pattern (e.g., **/*.ts)
Grep Search file contents with regex
WebFetch Fetch web content from URLs
WebSearch Perform web searches
Task Launch sub-agents for complex tasks
TodoWrite Create and track task lists
๐ CLAUDE.md Configuration
Create a CLAUDE.md file in your project root. Claude automatically reads it for context.
# Project Overview
This is a React + TypeScript web application.
# Tech Stack
- React 18
- TypeScript 5
- Tailwind CSS
- Vite
# Coding Conventions
- Use functional components
- Commit messages follow Conventional Commits
- Test files use .test.ts extension
# Important Directories
- src/components: Reusable components
- src/hooks: Custom hooks
- src/utils: Utility functions ๐ฅ Pipe Input Examples
Pass file contents or command output to Claude via standard input.
cat error.log | claude -p "Explain this error and how to fix it" git diff | claude -p "Review these changes" cat package.json | claude -p "Analyze the dependencies in this project" npm test 2>&1 | claude -p "Analyze the failing tests" ๐ก Real-World Use Cases
๐ Bug Fixing
"Fix the TypeError in this function"
โจ Feature Development
"Add user authentication functionality"
๐ Refactoring
"Convert this class to a functional component"
๐ Documentation
"Add JSDoc comments to this API module"
๐งช Testing
"Write unit tests for this utility function"
๐ Code Analysis
"Explain the structure of this codebase"
โญ Pro Tips
- โธ Use @filename to reference files directly in your prompts.
- โธ Drag & drop images or paste from clipboard for visual context.
- โธ Use .claudeignore to exclude specific files/folders.
- โธ Use /compact to summarize context and save tokens in long conversations.
- โธ Use claude -c to continue your last conversation.
- โธ Break large tasks into smaller steps for better results.