← All Posts

How to Set Up Claude Code CLI: 5-Minute Quickstart

From the guide: Claude Code Comprehensive Guide

Over 29,000 developers at ServiceNow now use Claude Code daily1, and Allianz rolled it out company-wide in early 20262. The tool’s adoption curve reflects a pattern: once developers try agentic coding in their own terminal, they do not go back to copy-pasting from chat windows. The following walkthrough takes you from zero to a working Claude Code session in about five minutes, with real configuration you can keep using afterward.

TL;DR: Install Claude Code via npm install -g @anthropic-ai/claude-code, authenticate through your browser, create a CLAUDE.md file with your project context, and configure permissions in .claude/settings.json. Add a Prettier hook to auto-format files after every edit. The whole setup takes under five minutes and the configuration persists across sessions.

Key Takeaways

  • Solo developers: CLAUDE.md and a formatting hook cover 80% of what you need. Start with default permissions and pre-approve tools as you build trust.
  • Team leads: Commit .claude/settings.json to your repo so the entire team shares the same permission allowlists and hooks.
  • Security engineers: The three-tier permission model4 (Ask, Allowlisted, --dangerously-skip-permissions) maps directly to trust levels. Ask mode requires explicit approval for every write and every command.

Prerequisites

You need three things before installing Claude Code:

Node.js 18 or later. Claude Code ships as an npm package3. Check your version:

node --version
# v18.0.0 or higher

If you need to install or upgrade Node.js, use nvm or download directly from nodejs.org.

An Anthropic account with API access. Create an API key at console.anthropic.com under Settings > API Keys. Claude Code bills per token against your API balance, or you can use the Max subscription plan ($100/month individual, $200/month teams as of March 2026)6. Keep the key available for the authentication step.

A terminal. Claude Code runs in any terminal emulator: Terminal.app, iTerm2, Windows Terminal, Alacritty, or the integrated terminal in VS Code. I recommend a terminal with at least 120 columns of width, since Claude Code displays file diffs and tool outputs that benefit from horizontal space.

Installation

Install Claude Code globally via npm:

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

Verify the installation succeeded:

claude --version

You should see a version number printed to stdout. If you get a “command not found” error, your npm global bin directory is not on your PATH. Run npm config get prefix and add the /bin subdirectory to your shell’s PATH. On macOS with Homebrew-installed Node, the prefix is typically /usr/local, so add /usr/local/bin if it is not already there.

Common installation issue: If you run into EACCES permission errors during npm install -g, do not use sudo. Instead, configure npm to use a user-writable directory7:

mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
# Add to your shell profile (~/.zshrc or ~/.bashrc):
export PATH="$HOME/.npm-global/bin:$PATH"

On first launch, Claude Code opens your browser to the Anthropic console for OAuth authentication. You log in, authorize, and Claude Code stores the token locally in ~/.claude/. Alternatively, you can set the ANTHROPIC_API_KEY environment variable before launching. Either way, credentials stay on your machine and authenticate only API requests.

First Session

Navigate to any project directory and run:

cd ~/Projects/my-app
claude

Claude Code starts an interactive REPL session. On first launch in a new project, Claude does several things automatically:

  1. Scans the directory structure to understand the project layout
  2. Reads configuration files like package.json, pyproject.toml, or Cargo.toml to identify the tech stack
  3. Looks for a CLAUDE.md file at the project root for project-specific instructions

Try a simple prompt to confirm everything works:

> Explain the structure of this project

Claude reads your files, synthesizes the architecture, and responds in the terminal. You will see tool calls in real time (each file read, each command executed) along with a request for permission before any write operation.

What to watch for in your first session. Pay attention to two things: the tool calls (shown in real time before each action) and the permission prompts. The tool calls reveal how Claude navigates your codebase. You will notice it reads files you might not have thought to check, which often surfaces useful context. The permission prompts show you exactly what Claude intends to change before anything touches disk. If a proposed edit looks wrong, deny it and provide clarification. Claude adjusts its approach based on your feedback within the session8.

Setting Up CLAUDE.md

CLAUDE.md is the single most important file for effective Claude Code usage. Without it, Claude infers your stack from file contents and makes reasonable guesses. With it, Claude follows your exact conventions from the first prompt. The difference matters because inference-based behavior drifts: Claude might use CommonJS in an ESM project, pick the wrong test runner, or ignore your database migration workflow. CLAUDE.md eliminates that drift.

Create the file at your project root:

touch CLAUDE.md

Here is a practical starting template for a Python project:

# My App

## Project Context
FastAPI backend with HTMX frontend. PostgreSQL database.

## Stack
- Backend: Python 3.11, FastAPI, SQLAlchemy 2.0 (async)
- Frontend: HTMX + Alpine.js, Jinja2 templates
- Database: PostgreSQL 16, Alembic migrations
- Testing: pytest with pytest-asyncio

## Code Standards
- Type hints on all function signatures
- Pydantic v2 models for request/response validation
- Async database operations only (no sync SQLAlchemy)

## Commands
- `source venv/bin/activate` before any Python command
- `uvicorn app.main:app --reload` starts the dev server
- `python -m pytest -v` runs the test suite
- `alembic upgrade head` applies database migrations

For a JavaScript/TypeScript project, the structure looks similar:

# My App

## Stack
- Backend: Node.js 20, Express 4, TypeScript
- Frontend: React 18, Vite
- Database: PostgreSQL 16, Prisma ORM
- Testing: Vitest for unit, Playwright for e2e

## Code Standards
- ESM imports only (no require())
- All API endpoints need input validation with Zod
- Tests required for new endpoints before merging

## Commands
- `npm run dev` starts the dev server on port 3000
- `npm test` runs the test suite
- `npx prisma migrate dev` runs database migrations

The most valuable CLAUDE.md sections are the ones that prevent repeated mistakes. If Claude keeps importing with require() instead of import, add “ESM imports only” to Code Standards. If your test command requires activating a virtualenv first, document that sequence. Claude reads CLAUDE.md at the start of every session, so each line becomes a persistent instruction that compounds across hundreds of interactions. The AGENTS.md open specification9 follows a similar pattern for other agentic tools, but CLAUDE.md supports richer features like skills and rules directories.

The hierarchy matters. You can place a CLAUDE.md in three locations, and Claude merges them in order of specificity:

  1. ~/.claude/CLAUDE.md: global instructions for all projects (your personal coding preferences)
  2. ./CLAUDE.md: project-level instructions (committed to your repo, shared with your team)
  3. ./src/CLAUDE.md: directory-level instructions (scoped to a monorepo module or subsystem)

Project-level CLAUDE.md is the one you commit to version control. Team members who use Claude Code inherit your conventions automatically.

Permission Basics

Claude Code operates in three permission tiers4 that determine how much autonomy the agent has. The tier you choose controls a fundamental tradeoff: more autonomy means faster sessions but less visibility into what changes.

Ask mode (the default) requires approval before every file write, command execution, or destructive action. You see exactly what Claude intends to do and approve or reject each step. I recommend starting here because the approval prompts teach you how Claude Code works. After a few sessions, you develop intuition for which operations are safe to pre-approve and which deserve scrutiny every time.

Allowlisted permissions let you pre-approve specific tools and patterns so Claude does not ask every time. You configure these in your project’s .claude/settings.json:

{
  "permissions": {
    "allow": [
      "Read",
      "Glob",
      "Grep",
      "Bash(python -m pytest*)",
      "Bash(alembic upgrade head)"
    ]
  }
}

The configuration above allows Claude to read files, search the codebase, and run your test and migration commands without asking. It still asks before writing files or running any other bash commands. Notice the pattern: read operations and known-safe commands get allowlisted. Write operations stay in Ask mode because you want to review what Claude writes before it hits disk.

Dangerously skip permissions (--dangerously-skip-permissions) disables all confirmation prompts. The flag exists exclusively for CI/CD pipelines and automated workflows where no human is present to approve. Never use it in interactive sessions on a codebase you care about.

The permission system makes Claude Code safe to use on real projects. The progression is deliberate: start in Ask mode to build understanding, allowlist the operations that become repetitive, and leave write operations gated so you always review changes before they land.

Your First Hook

Hooks are shell commands that execute at specific points in Claude Code’s lifecycle5. They solve a fundamental problem with LLM-based tools: the model follows your formatting rules most of the time, but “most of the time” means every tenth file edit introduces a style inconsistency. Hooks provide deterministic guarantees where the model provides probabilistic ones. A formatting hook runs your formatter after every file write, every time, regardless of what the model decided to do. Here is a practical first hook: auto-formatting files after Claude edits them.

Create or edit .claude/settings.json in your project:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "hooks": [
          {
            "type": "command",
            "command": "npx prettier --write \"$FILE_PATH\" 2>/dev/null || true"
          }
        ]
      }
    ]
  }
}

The PostToolUse hook5 fires after every Edit or Write tool call. Claude Code sets $FILE_PATH to the modified file’s path. Prettier formats it in place, and || true ensures a non-zero exit code does not block Claude if Prettier is not installed or the file type is unsupported5.

Other practical starter hooks I recommend:

  • PreToolUse on Bash: Block dangerous commands like rm -rf / or git push --force
  • SessionStart: Inject the current date, active git branch, or environment variables into context (stdout from SessionStart hooks feeds into Claude’s context)
  • Stop: Run your test suite automatically when Claude finishes a task

Hooks transform Claude Code from a conversational tool into a governed development environment. Even one or two well-chosen hooks eliminate entire categories of mistakes.

When Things Go Wrong

Three situations come up repeatedly in the first week of Claude Code usage. Knowing about them upfront saves debugging time.

Claude ignores your CLAUDE.md instructions. The most common cause: Claude has already read the file and cached its understanding before you edited it. Run /clear to reset the context, or start a new session. Claude re-reads CLAUDE.md at session start, not on every prompt. If Claude still ignores the instructions after a fresh session, check whether a higher-priority CLAUDE.md (user-level at ~/.claude/CLAUDE.md) conflicts with your project-level file.

Claude makes a change you did not approve. If you allowlisted a pattern too broadly (e.g., Bash(*) instead of Bash(python -m pytest*)), Claude can run commands without asking. Narrow your allowlist patterns. The safest approach: allowlist only read operations and specific named commands. If Claude already made an unwanted change, git diff shows exactly what changed, and git checkout -- <file> reverts it.

Context window fills up during a long session. Claude Code compresses earlier messages when the 200K context window fills, but compression can drop important details from early in the conversation. For sessions longer than 30 minutes, commit working changes periodically and start a new session with /clear. The fresh context re-reads CLAUDE.md and starts clean. I commit after every completed subtask, which gives me both a rollback point and a natural session boundary.

Claude edits the wrong file or makes unnecessary changes. When Claude starts “improving” code you did not ask it to touch, the issue is usually prompt ambiguity. Instead of “clean up the auth module,” say “in app/auth/handlers.py, rename verify_user to verify_user_credentials and update all callers.” Specificity reduces unwanted side effects. If Claude has already made unwanted edits, git diff shows exactly what changed and git checkout -- <file> reverts individual files without losing other work.

Next Steps

The walkthrough above covers the essentials: installation, your first session, project configuration, permissions, and a starter hook. For the complete reference covering all 5 core systems (CLAUDE.md hierarchy, the full permission model, hooks architecture, custom slash commands, and multi-agent workflows) read The Complete Guide to Claude Code.

The guide covers context window management, subagent delegation, skill auto-activation, and the patterns that emerge after months of daily Claude Code usage. If you found this quickstart useful, the full guide is the natural next step.

References

FAQ

How much does Claude Code cost?

Claude Code supports two billing models. The API pay-as-you-go model charges per token at standard Anthropic API rates6. A typical 30-60 minute session costs $0.50-$3.00 depending on codebase size and generation volume. Alternatively, Anthropic’s Max plan6 ($100/month individual, $200/month teams as of March 2026) includes Claude Code usage with higher rate limits. You can monitor API usage at console.anthropic.com.

Can I use Claude Code with VS Code?

Yes. Claude Code works in any terminal, including VS Code’s integrated terminal. Open the terminal panel in VS Code, navigate to your project directory, and run claude exactly as you would in a standalone terminal. Claude Code reads and edits files on disk, so changes appear immediately in your VS Code editor tabs. There is no separate VS Code extension required. Some developers keep a dedicated terminal split for Claude Code alongside their editor, which works well for reviewing changes as they happen.

Is Claude Code safe to use on production codebases?

Claude Code’s Ask mode requires explicit approval before every file write and every command execution. Nothing changes on disk without your confirmation. The permission system, combined with hooks that can block dangerous operations like force pushes or destructive shell commands, makes Claude Code practical for production work. I use Claude Code daily on projects that serve real users. The key is starting in Ask mode, understanding what each tool call does before approving it, and gradually allowlisting only the operations you trust. Version control provides the final safety net: commit before starting any significant Claude Code session so you can always revert.

What is the most common mistake new users make?

Giving Claude too much context in the prompt instead of putting it in CLAUDE.md. New users tend to paste their entire coding standards into each prompt, which wastes context window space and produces inconsistent results between sessions. Move recurring instructions to CLAUDE.md once, and use prompts for session-specific requests. The second most common mistake: allowlisting Bash(*) instead of specific commands. A wildcard Bash allowlist lets Claude run any shell command without asking, which defeats the purpose of the permission system.


  1. Anthropic, “ServiceNow Customer Story.” anthropic.com/customers/servicenow 

  2. Anthropic, “Allianz Customer Story.” anthropic.com/customers/allianz 

  3. Anthropic, “Claude Code Overview.” docs.anthropic.com/en/docs/claude-code/overview. Source: github.com/anthropics/claude-code 

  4. Anthropic, “Claude Code Permissions.” docs.anthropic.com/en/docs/claude-code/security 

  5. Anthropic, “Claude Code Hooks.” docs.anthropic.com/en/docs/claude-code/hooks 

  6. Anthropic, “Pricing.” anthropic.com/pricing 

  7. npm Documentation, “Resolving EACCES permissions errors when installing packages globally.” docs.npmjs.com/resolving-eacces-permissions-errors 

  8. Anthropic, “Effective usage of Claude Code.” docs.anthropic.com/en/docs/claude-code/best-practices 

  9. Linux Foundation Agentic AI Foundation, “AGENTS.md Specification.” github.com/anthropics/agent-instructions 

Related Posts

Claude Code Hooks Tutorial: 5 Production Hooks From Scratch

Build 5 production Claude Code hooks from scratch with full JSON configs: auto-formatting, security gates, test runners,…

12 min read

Codex CLI vs Claude Code in 2026: Architecture Deep Dive

Kernel-level sandboxing vs application-layer hooks, AGENTS.md vs CLAUDE.md, cloud tasks vs subagents. A technical compar…

13 min read

Building Custom Skills for Claude Code: A Complete Tutorial

Build a code review skill from scratch. Covers directory structure, frontmatter fields, LLM-based matching, context budg…

10 min read