Claude Code (CLI Agent)
The terminal-based AI agent that reads your codebase, writes files, runs tests, and commits to Git.
What is Claude Code?
Claude Code is Anthropic's agentic coding CLI — a terminal-based AI coding assistant that reads your actual codebase, writes files, runs commands, and iterates on solutions. Unlike pasting code into Claude.ai, Claude Code operates inside your project directory with full context of every file.
It's not just autocomplete. Claude Code can:
- Read your entire codebase and understand how it fits together
- Write new files, edit existing ones, and create tests
- Run shell commands (builds, tests, linters) and react to the output
- Browse documentation via the web or MCP servers
- Commit to Git, open PRs, and update issues
- Work autonomously on multi-step tasks for minutes without supervision
Installation
Prerequisites
- Node.js 18 or later — check with
node --version - An Anthropic API key with credits (from console.anthropic.com)
- macOS, Linux, or Windows (WSL2 recommended on Windows)
Step 1: Install globally
npm install -g @anthropic-ai/claude-code
Step 2: Set your API key
export ANTHROPIC_API_KEY="sk-ant-api03-..." source ~/.zshrc # reload
Step 3: Launch inside your project
cd ~/my-project claude # starts interactive session claude "fix the failing tests in test_orders.py" # one-shot task claude --model claude-opus-4-5 "refactor auth module" # specify model
The Claude Code interface
After running claude, you see an interactive prompt:
✓ Authenticated | claude-sonnet-4-5 | /my-project
Context: 23 files, 4,821 tokens
> Add input validation to the /api/orders POST endpoint.
Validate: customer_id is integer, amount is positive decimal,
items is non-empty list. Return 422 with error detail on failure.
✦ Reading: src/api/orders.py, src/models/order.py, tests/test_orders.py
✦ Writing: src/api/orders.py
✦ Writing: tests/test_orders.py
✦ Running: python -m pytest tests/test_orders.py -v
✓ All 8 tests pass. Changes made:
- Added Pydantic model OrderRequest with validators
- Added 422 error handler returning field-level error details
- Added 4 new test cases for validation edge cases
Key commands inside a Claude Code session
| Command | What it does |
|---|---|
/help | Show all slash commands |
/clear | Clear context and start fresh |
/compact | Summarize history to save tokens |
/memory | View and edit Claude's memory about your project |
/mcp | List connected MCP servers and their tools |
/cost | Show token usage and cost for this session |
/model | Switch model mid-session |
/exit or Ctrl+C | End session |
The CLAUDE.md file — your project memory
Create a CLAUDE.md file in your project root. Claude Code reads this automatically at the start of every session. It's your project's "onboarding doc for AI":
# Project: Orders API
## Stack
- Python 3.12, FastAPI 0.110, PostgreSQL 15
- Testing: pytest + httpx for async tests
- Linting: ruff, black (line length 88)
## Conventions
- snake_case for all names
- BIGINT for all IDs, NUMERIC(12,2) for money — never FLOAT
- Every endpoint must have a corresponding test
- Error responses: {"error": "message", "field": "field_name"}
## Commands
- Run tests: `pytest tests/ -v`
- Start dev server: `uvicorn src.main:app --reload`
- Lint: `ruff check . && black --check .`
## Important files
- src/main.py — FastAPI app setup and router registration
- src/models/ — SQLAlchemy models
- src/api/ — route handlers (one file per resource)
- tests/ — mirrors src/api/ structure
Agentic mode — let Claude work autonomously
Use --dangerously-skip-permissions flag (only in safe environments like Docker) to let Claude make all file changes without confirming each one:
claude --dangerously-skip-permissions "Add comprehensive docstrings to all functions in src/api/"
Claude Code with VS Code and JetBrains
Claude Code has extensions for both major IDEs:
- VS Code — install "Claude Code" extension from the marketplace. Claude Code sessions appear in a terminal panel inside VS Code.
- JetBrains — install "Claude Code" plugin from JetBrains Marketplace. Supports IntelliJ, PyCharm, WebStorm, DataGrip.
Both extensions let you open a Claude Code session with the current file or selection in context, and show diffs of proposed changes before applying.
Real-world use cases for data engineers
- Generate dbt models — "Read the raw_orders table schema and create a dbt staging model with the right data types and column documentation"
- Write Airflow DAGs — "Create an Airflow DAG that runs daily, extracts from our Postgres source, transforms with pandas, and loads to BigQuery"
- Refactor SQL — "Rewrite all the correlated subqueries in src/sql/ as CTEs. Run the test suite after each change."
- Add data validation — "Add Great Expectations checks to the nightly pipeline for row count, null rate, and primary key uniqueness"
- Generate documentation — "Read every Python module and create a MODULES.md with purpose, inputs, outputs for each one"
/compact frequently to summarize context and reduce token usage. For exploration and design discussions, use Claude.ai (flat subscription) instead of Claude Code (pay per token).