Claude Code is an agentic coding assistant that operates directly in your terminal. It can read and edit files, run commands, search your codebase, and interact with Git and GitHub -- all through natural language. This guide walks you through installation, authentication, and your first productive session.
Prerequisites
- Node.js 18+: Claude Code requires Node.js version 18 or later. Check with
node --version. - An Anthropic account: You need an active Anthropic account with API access or a Claude Pro/Team subscription.
- A terminal: Works in any Unix-like shell (macOS Terminal, Linux shell, WSL on Windows, or Git Bash).
Installation
Install Claude Code globally via npm:
npm install -g @anthropic-ai/claude-code
To verify the installation:
claude --version
Updating
To update to the latest version:
npm update -g @anthropic-ai/claude-code
Authentication
Run claude for the first time and follow the interactive login flow:
claude
You will be prompted to authenticate through your browser. Once completed, your session credentials are stored locally and persist across sessions.
API Key Authentication
Alternatively, set the ANTHROPIC_API_KEY environment variable:
export ANTHROPIC_API_KEY="sk-ant-..."
claude
First Run
Navigate to your project directory and start Claude Code:
cd your-project
claude
Claude will automatically detect your project structure. Try some basic commands:
"What does this project do?"-- Claude reads your files and gives a summary."Find all TODO comments"-- Searches the codebase."Run the tests"-- Executes your test suite."Fix the bug in auth.js where the token isn't refreshed"-- Reads, edits, and verifies the fix.
Basic CLI Usage
Interactive Mode (default)
claude # Start an interactive session
One-shot Mode
claude -p "explain src/index.ts" # Print answer and exit
claude -p "add error handling to api.js" # Make a change and exit
Piping Input
cat error.log | claude -p "explain this error"
git diff | claude -p "review these changes"
Resuming Conversations
claude --resume # Resume the most recent conversation
claude --continue # Continue the last conversation with a new prompt
Common Flags
| Flag | Description |
|---|---|
-p "prompt" | Run in non-interactive (print) mode |
--resume | Resume the last conversation |
--continue | Continue the last conversation |
--model | Specify a model (e.g., claude-sonnet-4-6) |
--allowedTools | Restrict which tools Claude can use |
--verbose | Show detailed tool usage output |
For more CLI options and shortcuts, see Tips and Tricks.
Generate a CLAUDE.md (Fast Path)
The fastest way to get productive is to generate a CLAUDE.md file for your project. You have two options:
Option A: Interactive script — answers 7 questions, outputs a ready-to-use file:
bash tools/generate-claude-md.sh
Option B: Let Claude do it — paste the Quickstart Prompt into a Claude session and it auto-generates one by reading your project files.
Either way, you go from zero to a working CLAUDE.md in under 60 seconds. See the CLAUDE.md Guide for how to refine it further.
Tips for Your First Session
- Start with exploration: Ask Claude to summarize your project or explain a module before making changes.
- Be specific: Instead of "fix the bug", say "fix the null pointer in
processOrderwhen the cart is empty". - Review changes: Claude shows you diffs before applying them. Take a moment to review.
- Use plan mode for big tasks: Prefix complex requests with "plan:" or use
--planto have Claude outline an approach before executing.
See Also
Now that you are up and running, explore these guides to deepen your usage:
- CLAUDE.md Guide -- Give Claude persistent context about your project
- Prompt Tips -- Write more effective instructions
- Workflow Patterns -- Common development workflows
- Permission Modes -- Control what Claude can do
Fuente y licencia
- Adaptado de MuhammadUsmanGM/claude-code-best-practices / guides/getting-started.md (Muhammad Usman and contributors, Licencia MIT, 8e7d4bf)