๐Ÿค–

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.

CLI Tool AI Assistant Code Generation

๐Ÿš€ Quick Start

# Install
npm install -g @anthropic-ai/claude-code
# Start
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

Cancel operation Ctrl + C
Exit session Ctrl + D
Clear screen Ctrl + L
Previous prompt โ†‘
Next prompt โ†“
Autocomplete path Tab
Cancel input Esc
Multi-line input \

๐Ÿ”ง 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.

# Analyze error logs
cat error.log | claude -p "Explain this error and how to fix it"
# Code review
git diff | claude -p "Review these changes"
# Analyze dependencies
cat package.json | claude -p "Analyze the dependencies in this project"
# Analyze test failures
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.