Claude Code logo
10 minute setup

How to Set Up Claude Code

Install Anthropic's terminal-based AI coding agent, configure your API key, and start building from the command line. No IDE required.

Prerequisites

  • Node.js 18 or later installed (check with node --version)
  • A terminal you are comfortable with (Terminal, iTerm2, Warp, Windows Terminal, etc.)
  • An Anthropic API key (get one at console.anthropic.com)
  • Git installed (Claude Code is git-native and uses it for safe edits)
1

Install via npm

Open your terminal and run:

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

This installs Claude Code globally so you can run it from any directory. The installation takes about 30 seconds.

Verify the installation:

claude --version

Alternative: use npx

If you do not want to install globally, you can run Claude Code directly with npx @anthropic-ai/claude-code. This downloads and runs it in one command.
2

Add Your Anthropic API Key

Claude Code needs an Anthropic API key to work. If you do not have one yet, go to console.anthropic.com and create one.

Set the environment variable in your shell profile:

# Add to ~/.zshrc or ~/.bashrc
export ANTHROPIC_API_KEY="sk-ant-your-key-here"

# Then reload your shell
source ~/.zshrc

Alternatively, Claude Code will prompt you for the key on first run if it is not set.

Never commit your API key to git. Add .env to your .gitignore if you store it there. The environment variable approach above keeps it in your shell config, outside your project.
3

Run Your First Command

Navigate to a project folder and start Claude Code:

cd ~/projects/my-app
claude

Claude Code launches an interactive terminal session. You will see a prompt where you can type natural language instructions. Try something simple:

> What files are in this project and what do they do?

Claude reads your project structure and gives you a summary. It has full access to read files, run commands, and make changes — but always asks for your approval before modifying anything.

4

Understand the Interface

The Claude Code interface is text-based. Here is what you need to know:

  • Type naturally — describe what you want in plain English. No special syntax required.
  • File diffs — when Claude wants to edit a file, it shows you the exact diff. You approve or reject each change.
  • Tool usage — Claude can read files, search codebases, run terminal commands, and write files. It tells you what it is doing at each step.
  • Approval flow — by default, Claude asks before making changes. You can adjust permission levels if you want it to be more autonomous.

Permission modes

Use claude --dangerously-skip-permissions only in disposable environments (containers, CI). For normal development, the default approval flow keeps you in control.
5

Create a CLAUDE.md

This is the most important step for getting great results. Create a CLAUDE.md file in your project root. Claude reads this at the start of every session.

# CLAUDE.md

## Project Overview
This is a Next.js 15 app with TypeScript, Tailwind CSS, and Supabase.

## Tech Stack
- Next.js 15 (App Router)
- TypeScript (strict mode)
- Tailwind CSS for styling
- Supabase for database and auth
- Vercel for deployment

## Conventions
- Use server components by default
- Only add 'use client' when you need interactivity
- Use absolute imports from @/ prefix
- All API routes go in app/api/
- Database queries go through lib/db.ts

## Common Commands
- npm run dev — start dev server
- npm run build — production build
- npm test — run tests
- npx supabase db push — push migrations

## Known Quirks
- The auth middleware is in middleware.ts at the root
- We use a custom useUser hook, not Supabase's built-in one
- Image uploads go to Supabase Storage, not the filesystem
CLAUDE.md is your leverage. Spend 10 minutes writing a good one and every future conversation with Claude Code starts with shared context. Update it when your project evolves.

Get the Vibe Coding Cheat Sheet

Best tool for every use case + pricing + pro tips. One page, zero fluff. Plus weekly updates on new tools.

6

Try a Multi-File Edit

This is where Claude Code shines. Ask it to make a change that touches multiple files:

> Add a /api/users endpoint that returns a list of users
from the database. Include the route handler, a TypeScript
type for the response, and update the frontend to fetch
and display the users in a table component.

Claude Code will:

  1. Read your existing code to understand patterns
  2. Plan which files to create or modify
  3. Show you the diff for each file
  4. Wait for your approval before applying changes

This is fundamentally different from copy-pasting code from a chatbot. Claude Code sees your entire project and writes code that fits in.

7

Set Up Git Integration

Claude Code is git-native. Every change it makes is tracked by git, which means you can always undo. Here are common git workflows:

> Create a commit with a good message for the changes we just made

> Review the diff of my staged changes and suggest improvements

> Create a new branch called feat/user-profiles and move our changes there

You can also ask Claude Code to create pull request descriptions, review code, or resolve merge conflicts. It reads the git history and understands your branch structure.

Safe by default

Claude Code uses git to protect your work. If you do not like a change, you can always git checkout . to revert. It will never force-push or delete branches without asking.
8

Build Something Real

You are ready. Here is a real-world prompt to test Claude Code's capabilities:

> I want to add a blog system to this project. It should:
- Use MDX files in a /content/blog directory
- Generate static pages at /blog/[slug]
- Include a blog index page with cards for each post
- Support frontmatter for title, date, description, and tags
- Have good SEO with meta tags and JSON-LD

Read the codebase first to understand our patterns,
then implement this step by step.

Claude Code will explore your project, build a plan, and implement it file by file with your approval at each step.

What to Build First

CLI Tool with Argument Parsing

Beginner15 min

Build a command-line tool that accepts flags and arguments. Try: "Create a Node.js CLI that converts CSV files to JSON. Support --input, --output, and --pretty flags."

Refactor an Existing Codebase

Intermediate30 min

Point Claude Code at a messy project and ask it to refactor. It will read every file, propose a plan, and execute changes across the entire repo with git tracking.

Full-Stack Feature with Tests

Advanced45 min

Ask Claude to add a complete feature — API route, database migration, frontend component, and tests. It handles the whole stack in one conversation.

Claude Code Tips from Power Users

Write a good CLAUDE.md

Put your project context, tech stack, conventions, and quirks in CLAUDE.md at the project root. Claude reads this every session. It is the single most impactful thing you can do.

Let it read before it writes

Start conversations with "Read the codebase and understand how X works before making changes." Claude Code is thorough when you give it permission to explore first.

Use headless mode for automation

Run claude -p "your prompt" for non-interactive, scriptable usage. Great for CI/CD pipelines, code reviews, or batch operations across repos.

Trust the diff review

Claude Code shows you every change before applying it. Read the diffs carefully on your first few sessions. You will quickly learn to trust its judgment — or catch patterns you want to redirect.

Chain tasks in one session

Claude Code remembers your whole conversation. Build incrementally: "Add the API route" then "Now add tests for it" then "Now add the frontend form that calls it." Each step has full context.

Use /compact when context grows

If your conversation gets long, type /compact to summarize the history and free up context window. This keeps Claude Code fast without losing important information.

Useful Commands

CommandWhat it does
claudeStart an interactive session in the current directory
claude -p "prompt"Run a one-shot prompt (non-interactive)
claude --model opusUse a specific model (opus, sonnet, haiku)
/compactCompress conversation history to free up context
/clearClear the conversation and start fresh
/costShow token usage and cost for the current session
EscCancel the current operation
Ctrl+CExit Claude Code

You are set up. Now explore.

Compare Claude Code against other tools, or submit what you build to the showcase.

We use cookies for analytics. Learn more