D
DevToolsReview

How to Set Up Claude Code and Start Using It in 2026: Complete Guide

Step-by-step guide to installing Claude Code via npm, configuring your API key, setting up CLAUDE.md, managing permissions, and running your first AI-powered coding session.

DR

DevTools Review

· Updated March 17, 2026 · 5 min read
Claude Code

Claude Code is Anthropic’s official command-line tool for AI-assisted coding. Unlike editor-based AI tools, Claude Code runs directly in your terminal and operates on your entire project — reading files, writing code, running commands, and iterating on errors autonomously. Think of it as an AI engineer that sits inside your shell and understands your full codebase.

This guide walks you through everything from installation to your first productive session, including the configuration details that most tutorials skip.

Try Claude Code

Prerequisites

Before you start, make sure you have:

  • Node.js 18 or later installed (check with node --version)
  • npm (comes with Node.js) or another package manager like yarn or pnpm
  • An Anthropic API key — sign up at console.anthropic.com if you don’t have one
  • A terminal you’re comfortable with — Claude Code works in any standard terminal (Terminal.app, iTerm2, Windows Terminal, Alacritty, etc.)
  • macOS, Linux, or Windows with WSL2 — Claude Code runs on all major platforms
  • An internet connection — Claude Code calls the Anthropic API for every interaction

Step 1: Install Claude Code via npm

Open your terminal and run the global install command:

npm install -g @anthropic-ai/claude-code

This installs the claude CLI globally so you can run it from any directory. The package is lightweight — the initial download is under 50 MB.

Verify the installation succeeded:

claude --version

You should see a version number printed. If you get a “command not found” error, make sure your npm global bin directory is in your PATH. You can find it with npm bin -g.

Alternative installation methods:

# Using yarn
yarn global add @anthropic-ai/claude-code

# Using pnpm
pnpm add -g @anthropic-ai/claude-code

To update Claude Code later, run the same install command again — it overwrites the existing version.

Step 2: Configure Your Anthropic API Key

Claude Code needs an API key to communicate with Anthropic’s models. You have two options for providing it.

Option A: Environment variable (recommended)

Add your key to your shell profile so it’s always available:

# For zsh (default on macOS)
echo 'export ANTHROPIC_API_KEY="sk-ant-your-key-here"' >> ~/.zshrc
source ~/.zshrc

# For bash
echo 'export ANTHROPIC_API_KEY="sk-ant-your-key-here"' >> ~/.bashrc
source ~/.bashrc

Option B: Interactive login

Run claude without a key set and it will prompt you to authenticate. Follow the on-screen instructions to enter your key or log in via the browser.

To verify your key is configured correctly:

echo $ANTHROPIC_API_KEY

You should see your key printed (starting with sk-ant-). If it’s empty, double-check your shell profile and make sure you’ve sourced it.

Tip: Never commit your API key to version control. Add .env files to your .gitignore and use environment variables or a secrets manager for team setups.

Step 3: Launch Claude Code in a Project

Navigate to any project directory and start Claude Code:

cd ~/projects/my-app
claude

Claude Code starts an interactive session in your terminal. On first launch in a project, it automatically scans the directory structure to understand your codebase. You’ll see a prompt where you can type natural language instructions.

The initial scan reads file names, directory structure, and key configuration files (like package.json, tsconfig.json, or pyproject.toml) to build context about your project. It does not upload your entire codebase — it reads files on demand as needed.

Step 4: Create Your CLAUDE.md File

The CLAUDE.md file is one of Claude Code’s most powerful features. It’s a markdown file in your project root that gives Claude persistent instructions about your codebase, coding standards, and preferences. Claude reads it automatically every time you start a session.

Create a CLAUDE.md file in your project root:

# Project Context

This is a Next.js 14 application using TypeScript, Tailwind CSS, and Prisma.

## Architecture
- App Router with server components by default
- API routes in /app/api/
- Database models defined in /prisma/schema.prisma
- Shared utilities in /lib/

## Coding Standards
- Use named exports, never default exports
- All functions must have TypeScript return types
- Error handling: use custom AppError class from /lib/errors.ts
- Tests: use Vitest with Testing Library, co-locate test files with source

## Commands
- `npm run dev` — start dev server
- `npm run test` — run tests
- `npm run lint` — run ESLint
- `npm run build` — production build

## Important Notes
- Never modify /lib/legacy/ files — they are deprecated but still in use
- Always run tests before committing
- Database migrations require `npx prisma migrate dev`

Tailor this file to your actual project. The more specific you are, the better Claude Code’s suggestions will be. You can include information about your architecture, naming conventions, testing strategies, deployment process, and anything else a new developer on your team would need to know.

You can also create a ~/.claude/CLAUDE.md file in your home directory for global preferences that apply across all projects.

Step 5: Understand the Permission System

Claude Code uses a permission system to protect your codebase. When Claude wants to perform potentially destructive actions, it asks for your approval first. Understanding this system prevents surprises.

Actions that require approval:

  • Writing or modifying files
  • Running shell commands (like npm install, git commit, etc.)
  • Deleting files
  • Creating new directories

How to respond to permission prompts:

  • y — approve this specific action
  • n — deny this action
  • a — always approve this type of action for the current session

For experienced users who want a faster workflow, you can configure auto-approval for specific command patterns. Claude Code will remember your choices within a session, so you don’t have to approve the same type of action repeatedly.

Important: Be cautious with broad auto-approvals, especially for shell commands. Always review what Claude is about to execute, particularly commands involving rm, git push --force, or anything that modifies production resources.

Step 6: Run Your First Tasks

Now that everything is configured, try these starter tasks to get a feel for Claude Code’s capabilities.

Ask a question about your codebase:

> How is authentication handled in this project?

Claude reads relevant files and gives you an explanation grounded in your actual code, not generic advice.

Generate new code:

> Create a new API endpoint at /api/users/[id]/preferences that supports GET and PUT

Claude creates the file, writes the handler, adds proper TypeScript types, and follows patterns from your existing endpoints.

Fix a bug:

> The /api/orders endpoint returns a 500 error when the user has no orders. Fix it.

Claude reads the endpoint code, identifies the issue, applies a fix, and can run your tests to verify.

Refactor existing code:

> Refactor the UserService class to use dependency injection instead of direct imports

Claude modifies the class, updates all call sites, and adjusts tests if needed.

Key Commands and Shortcuts

Once you’re inside a Claude Code session, these commands help you work efficiently:

CommandWhat It Does
/helpShow all available commands
/clearClear conversation history and start fresh
/compactSummarize the conversation to reduce context usage
/costShow token usage and estimated cost for this session
/doctorDiagnose configuration issues
/initGenerate a CLAUDE.md file based on your project
/reviewAsk Claude to review your recent changes
/vimToggle vim keybindings in the input
Ctrl+CCancel the current operation
Ctrl+DExit Claude Code
EscInterrupt Claude’s current response

Running Claude Code non-interactively:

You can also use Claude Code for one-off commands without entering the interactive session:

# Ask a question and get a response
claude -p "What does the main function in src/index.ts do?"

# Pipe input to Claude
cat error.log | claude -p "Explain this error and suggest a fix"

# Use in scripts
claude -p "Generate a migration to add an email column to users table" --output-file migration.sql

Pro Tips for a Better Setup

Use /init to bootstrap your CLAUDE.md. If you don’t want to write your CLAUDE.md from scratch, run /init inside a Claude Code session. Claude analyzes your project structure, dependencies, and existing configuration files, then generates a tailored CLAUDE.md for you. Review and edit it afterward.

Pair Claude Code with your editor. Claude Code is not a replacement for your editor — it complements it. Keep your editor open for browsing and reading code, and use Claude Code in a side terminal for generation, refactoring, and complex multi-file changes. Many developers run Cursor or VS Code alongside Claude Code.

Use Git checkpoints. Before asking Claude to make large changes, commit your current state. If the changes don’t go the way you want, you can easily revert with git checkout . or git stash. Claude Code is aware of Git and can commit changes for you when asked.

Keep sessions focused. Claude Code works best when you give it one clear task at a time. If you need to do multiple unrelated things, use /clear between tasks to reset the context and avoid confusion.

Monitor your costs. See our Claude Code pricing guide for details on each plan. Use the /cost command periodically to track your API usage. Claude Code uses Claude’s latest models, which charge per token. Complex tasks on large codebases can consume significant tokens. The /compact command helps reduce token usage by summarizing earlier conversation turns.

Troubleshooting Common Issues

“Command not found: claude” Your npm global bin directory is not in your PATH. Run npm bin -g to find the directory, then add it to your PATH in your shell profile. On macOS with Homebrew-installed Node, this is typically /usr/local/bin or ~/.npm-global/bin.

“Invalid API key” or authentication errors Double-check that your ANTHROPIC_API_KEY environment variable is set correctly. Run echo $ANTHROPIC_API_KEY to verify. Make sure the key starts with sk-ant- and hasn’t been revoked in the Anthropic console.

Claude Code seems slow or hangs This is usually a network issue or API rate limiting. Check your internet connection. If you’re on a free tier or have hit rate limits, you may experience throttling. Check your usage at console.anthropic.com.

Claude makes incorrect changes Improve your CLAUDE.md file with more specific instructions. The more context Claude has about your project’s conventions and architecture, the better its output. Also ensure you’re giving clear, specific instructions rather than vague requests.

High token usage on large projects Use /compact regularly to compress conversation history. Be specific in your requests — instead of “fix all the bugs,” point Claude to a specific file or error. Use /clear between unrelated tasks.

Permission prompts are annoying If you trust the current task, use the “a” (always) option when prompted. For shell commands you run frequently (like npm test), auto-approval keeps the workflow smooth. But always read the command before approving.

Claude Code doesn’t understand my project Make sure you’re running claude from the project root directory, not a subdirectory. Create a comprehensive CLAUDE.md file. If your project uses an unusual structure, describe it explicitly in your CLAUDE.md.

Next Steps

You’re set up and ready to go. Here are some resources to keep leveling up:

Try Claude Code
DR

Written by DevTools Review

We're developers who use AI coding tools every day. Our reviews are based on real-world experience, not press releases. We test with real projects and share what we actually find.

Newsletter

Stay ahead of AI coding tools

Weekly roundup of new features, pricing changes, and honest takes. No spam, unsubscribe anytime.

Join 2,000+ developers. Free forever.