How to install and use Claude Code

Claude Code is Anthropic's agentic coding tool that runs in your terminal. It reads your entire codebase, writes and edits files, runs tests, and executes shell commands. This guide covers installation, configuration, and practical workflows.

What Claude Code is

Claude Code is a command-line tool that gives Claude access to your local filesystem. Unlike a chat interface, it can read every file in your project, write and overwrite code, execute shell commands, run your test suite, and iterate until a task is complete — all with minimal manual intervention.

It is not a VS Code extension or IDE plugin. It is a pure terminal tool, which makes it portable across any editor and suitable for CI pipelines and headless server environments. This also means it has broader filesystem access than most code assistants.

Prerequisites

You need Node.js 18 or later. Check your version with `node -v`. You also need an Anthropic API key — create one at console.anthropic.com. Claude Code uses Claude Sonnet and Opus under the hood; costs vary depending on which model handles your request.

On macOS, ensure you have the Xcode command-line tools installed (`xcode-select --install`) since Claude Code may need them to compile native dependencies.

Install Claude Code

Install the package globally via npm: `npm install -g @anthropic-ai/claude-code`. Verify the installation with `claude --version`.

On first run, Claude Code will promptPromptThe input text sent to a language model — the question, instruction, or context that triggers a response.Learn more → you to authenticate. Run `claude` in any directory to start — it will open a browser window to complete OAuth authentication with your Anthropic account. Alternatively, set the `ANTHROPIC_API_KEY` environment variable before running.

Basic usage

Navigate to your project directory and run `claude`. You will see an interactive prompt. Describe what you want: 'Add a dark mode toggle to the navbar', 'Fix the failing tests in src/auth', 'Refactor the database module to use async/await throughout'.

Claude Code will read relevant files, explain its plan, ask for confirmation before making changes, and then execute. It shows each file edit as a diff before applying it. You can approve individual changes or tell it to proceed automatically with `--yes` flag.

For larger tasks, use `claude -p 'task description'` to pass a task as a command-line argument and run non-interactively. This is useful in CI/CD pipelines or when scripting multi-step workflows.

Practical tips

Give Claude Code a CLAUDE.md file in your project root. This is a Markdown file that Claude Code reads on every invocation — use it to describe your codebase architecture, coding conventions, which files to avoid touching, and any project-specific context that would help an engineer onboarding.

Use `/compact` in the interactive session if you are deep in a long conversation and want to compress the context without losing the thread. Claude Code summarises what has been done and continues.

Trust levels matter: Claude Code will ask for permission before running shell commands by default. Once you trust the session, use `--dangerously-skip-permissions` for fully autonomous operation — only do this in isolated environments or containers, not on your main development machine.