Claude Code is Anthropic's agentic AI coding assistant that runs directly in your terminal. Unlike browser-based AI tools, Claude Code operates in your actual development environment — it can read files, run commands, execute tests, and make code changes autonomously.
This guide covers everything you need to go from zero to productive with Claude Code.
What is Claude Code?
Claude Code is a command-line interface (CLI) tool that gives you Claude — Anthropic's most capable AI model — with direct access to your codebase and terminal. It's not just a chatbot with code highlighting. It's an agentic system that can:
- Read and modify files across your entire project
- Run terminal commands (tests, builds, installs)
- Search through code with grep and find
- Write new files and create project structures
- Debug errors by reading logs and stack traces
The key difference from tools like GitHub Copilot is autonomy. You can ask Claude Code to "add tests for the auth module" and it will find the auth module, understand its logic, and write comprehensive tests — without you guiding every step.
Installation
Claude Code requires Node.js 18 or later. Install it globally via npm:
npm install -g @anthropic-ai/claude-codeThen authenticate with your Anthropic API key:
claudeOn first run, you'll be prompted to enter your API key. You can get one at console.anthropic.com.
Your First Session
Navigate to any project directory and launch Claude Code:
cd my-project
claudeYou'll see an interactive session. Try starting with a codebase overview:
> Give me a high-level overview of this codebase
Claude will read your project structure and explain what it does, what the main modules are, and how they connect.
Key Commands
Claude Code has a few important slash commands:
| Command | Description |
|---|---|
/help | Show all available commands |
/clear | Clear conversation context |
/compact | Compress context to save tokens |
/cost | Show token usage for this session |
/exit | Exit Claude Code |
The Permission System
Claude Code asks for permission before running potentially impactful commands. You'll see prompts like:
Claude wants to run: npm test
Allow? (y/n/always)
y— allow oncen— deny this actionalways— trust this type of command for the session
For trusted projects, you can use --dangerously-skip-permissions to bypass these prompts, but use this carefully.
Practical Workflows
Workflow 1: Understanding a new codebase
When you join a project or need to understand a legacy codebase:
> Read the main entry point and explain the application architecture
> What are the most complex parts of this codebase?
> How does authentication work in this app?
Workflow 2: Feature development
> I need to add rate limiting to the API routes.
> Start by reading the current route structure, then implement
> express-rate-limit with Redis storage and add tests.
Claude will read your routes, install the necessary packages, implement the feature, and write tests — all in one go.
Workflow 3: Bug fixing
> My tests are failing with this error: [paste error]
> Find the root cause and fix it
Claude can read your test output, trace the error back to its source, and apply the fix.
Workflow 4: Code review
> Review the last 3 commits and tell me if there are any
> potential bugs, security issues, or code quality problems
CLAUDE.md — Your Project's AI Playbook
The most powerful feature of Claude Code is the CLAUDE.md file. Place this in your project root and Claude will read it at the start of every session.
Use it to define:
# My Project
## Tech Stack
- Node.js + Express
- PostgreSQL with Prisma
- Jest for testing
## Code Standards
- Always use TypeScript strict mode
- Tests are required for all new features
- Commit format: feat/fix/chore(scope): description
## Important Context
- The auth module uses JWT + refresh tokens
- Never modify the payment module without running full test suiteThis context saves tokens and ensures Claude always works within your project's conventions.
Token Cost Management
Claude Code uses the Claude API, so each session costs tokens. Tips to keep costs low:
- Use
/compact— compresses the conversation history when context gets long - Be specific — clear requests generate less back-and-forth
- Use CLAUDE.md — prevents Claude from re-exploring the same code
- Use
--model— for simple tasks, useclaude-3-haikuwhich is 10x cheaper
claude --model claude-haiku-4-5-20251001Advanced: Headless Mode
You can run Claude Code non-interactively for scripting:
claude -p "Add JSDoc comments to all functions in src/utils.ts" --output patchThis is useful for CI pipelines, pre-commit hooks, or batch code improvements.
Common Pitfalls
Don't give vague instructions. "Fix the code" is hard. "Fix the TypeScript error in src/auth.ts on line 42" is easy.
Don't skip the CLAUDE.md. Without it, Claude has to rediscover your project conventions every session.
Don't fear permission prompts. They exist to protect you. Always read what Claude is about to run.
Do commit often. Claude can make significant changes quickly. Commit before large operations so you can revert easily.
Conclusion
Claude Code is the closest thing to having a senior developer pair-programming with you 24/7. The key to getting the most out of it is:
- Write a solid
CLAUDE.mdfor your project - Be specific and clear in your requests
- Let it run autonomously on well-defined tasks
- Review its changes like you would a colleague's PR
Start small — use it for one task today. Tomorrow you won't be able to work without it.