Install and master the Claude Code CLI — Anthropic's agentic coding tool that operates directly in your terminal with access to your entire filesystem.
Claude Code is Anthropic's agentic coding tool. Unlike IDE plugins, it runs in your terminal and has direct access to your filesystem, shell, and git history — making it one of the most powerful coding agents available.
Claude Code operates in your terminal with permissions to:
The key difference from Cursor or Copilot: Claude Code completes entire tasks, not just code suggestions. You describe the task; it does the work.
# Install globally via npm
npm install -g @anthropic-ai/claude-code
# Verify installation
claude --version
Requirements:
# Authenticate with your API key
claude auth
# Or set via environment variable
export ANTHROPIC_API_KEY=sk-ant-...
# Start an interactive session in your project
cd my-project
claude
# Ask a one-off question
claude "What's the architecture of this project?"
# Give it a task
claude "Add error handling to all API routes and return proper HTTP status codes"
# Run in print mode (no interactive session, just output)
claude -p "List all TODO comments in the codebase"
CLAUDE.md is a special file in your project root that Claude Code reads at the start of every session. Use it to persist context:
# CLAUDE.md
## Project Overview
This is a Next.js SaaS application for tracking AI tool performance metrics.
## Tech Stack
- Next.js 16 with App Router
- PostgreSQL via Prisma ORM
- Tailwind CSS + shadcn/ui components
- NextAuth v5 for authentication
## Conventions
- Use 'use server' directive for all server actions
- Error handling: throw AppError(message, statusCode)
- Tests: use Vitest and React Testing Library
- Never use 'any' TypeScript type
## Important Files
- lib/prisma.ts — database client
- app/actions/ — server actions
- components/ui/ — reusable UI components
## Current Work In Progress
- Adding team collaboration features (branch: feature/teams)
Claude Code reads this file automatically. You never need to re-explain your project structure.
Claude Code asks for permission before taking actions. You can configure what requires approval:
# Set permission mode
claude config set permissions.allowedTools "read,write,execute"
# Or use --dangerously-skip-permissions for trusted workflows
claude --dangerously-skip-permissions "Run all tests and fix any failures"
Permission levels:
Claude Code shines on multi-step tasks:
# Add a complete feature
claude "Add a 'forgot password' flow.
Use the existing email utility in lib/email.ts.
The new pages should match the existing auth page styling.
Write tests for the resetPassword action."
# Debugging session
claude "The payment webhook is failing silently.
Look at the logs in /var/log/app.log (attached),
find the root cause, and fix it."
# Refactoring
claude "Refactor all class components in src/components
to functional components with hooks.
Run the tests after each file to ensure nothing breaks."
Hooks let you run custom code before/after Claude actions:
// .claude/hooks.json
{
"PreToolUse": [
{
"matcher": "execute_command",
"hooks": [{
"type": "command",
"command": "echo 'About to run: $TOOL_INPUT'"
}]
}
],
"PostToolUse": [
{
"matcher": "write_file",
"hooks": [{
"type": "command",
"command": "npx prettier --write $TOOL_OUTPUT_PATH"
}]
}
]
}
Use cases:
Claude Code uses your Anthropic API key directly. Typical costs:
| Task | Estimated Cost |
|---|---|
| Quick question | $0.01–0.05 |
| Add a small feature | $0.10–0.50 |
| Large refactor (50+ files) | $1.00–5.00 |
| Full test suite fix | $0.50–2.00 |
For heavy users, enable Extended Thinking (Claude Code 2.0+) for complex architectural tasks — costs more per call but produces dramatically better results.