Claude Code is a terminal-based AI coding assistant that integrates directly with your codebase to help with tasks like refactoring, debugging, and documentation. Here's how to use it with practical examples:
Installation and Setup
- Install globally via npm:
npm install -g @anthropic-ai/claude-code
- Authenticate with your Anthropic account:
claude login
- Navigate to your project directory:
cd your-project
Basic Commands
Explain code (one-off query):
claude -p "Explain this Dockerfile" < Dockerfile
Interactive REPL session:
claude "Help me refactor the authentication middleware"
> /review
> Could you make these functions more TypeScript-safe?
Git integration:
claude -p "Summarize recent changes" --git
Practical Example: Supabase Client Refactor
- Start an interactive session with context:
claude "I'm working on supabase-py/client.py"
- Request specific changes:
> Make these async methods more Pythonic
> Add error handling for network timeouts
> Generate docstrings in Google format
- Use slash commands to manage workflow:
> /compact focus=error-handling
> /memory save best-practices
Advanced Features
Model configuration (switch to Haiku for faster responses):
claude config set env '{"ANTHROPIC_MODEL":"claude-3-5-haiku-20241022"}'
Batch processing:
find . -name '*.ts' | xargs -I {} claude -p "Add JSDoc comments" {}
Pull request automation:
claude /pr_comments --generate > review.md
Key capabilities include:
- Real-time code analysis through
claude -p "Find race conditions"
- Documentation generation via
> /memory generate docs
- Test suite maintenance with
claude "Fix failing tests" --test
For complex tasks, use extended sessions with claude (no -p flag) to maintain conversation context across multiple file edits[1][3].