modified
--- a/quickstart.md +++ b/quickstart.md @@ -179,7 +179,7 @@ The `async for` loop keeps running as Claude thinks, calls tools, observes results, and decides what to do next. Each iteration yields a message: Claude’s reasoning, a tool call, a tool result, or the final outcome. The SDK handles the orchestration, tool execution, context management, and retries, so you consume the stream. The loop ends when Claude finishes the task or hits an error. The message handling inside the loop filters for human-readable output. Without filtering, you’d see raw message objects including system initialization and internal state, which is useful for debugging but noisy otherwise. -This example uses streaming to show progress in real-time. If you don’t need live output (for example, for background jobs or CI pipelines), you can collect all messages at once. See [Streaming vs. single-turn mode](</docs/en/agent-sdk/streaming-vs-single-mode>) for details. +This example prints Claude’s text and tool calls as the loop receives them. If you don’t need live output, collect the messages in the loop and read them after the loop ends. To choose between a single-shot `query()` and streaming input, see [Choose single-shot or streaming input](</docs/en/agent-sdk/streaming-vs-single-mode#choose-single-shot-or-streaming-input>). ### Run your agent
modified
--- a/quickstart.md +++ b/quickstart.md @@ -287,7 +287,7 @@ `Read`, `Edit`, `Glob`| Analyze and modify code `Read`, `Edit`, `Bash`, `Glob`, `Grep`| Full automation -**Permission modes** control how much human oversight you want. The SDK evaluates the active mode together with your allow and deny rules in a fixed order, described in [How permissions are evaluated](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>). For the full list of modes, their behavior, and when to use each, see [Permission mode in How the agent loop works](</docs/en/agent-sdk/agent-loop#permission-mode>). +To limit the agent’s built-in tools to one of these sets, pass it as `tools`. If you list a set in `allowedTools` instead, you [pre-approve those tools](</docs/en/agent-sdk/custom-tools#configure-allowed-tools>), and the agent can still call the others, subject to your permission mode. **Permission modes** control how much human oversight you want. The SDK evaluates the active mode together with your allow and deny rules in a fixed order, described in [How permissions are evaluated](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>). For the full list of modes, their behavior, and when to use each, see [Permission mode in How the agent loop works](</docs/en/agent-sdk/agent-loop#permission-mode>). ## Next steps
modified
Show diff (116 lines)
--- a/quickstart.md +++ b/quickstart.md @@ -4,20 +4,12 @@ 2. Create a file with some buggy code 3. Run an agent that finds and fixes the bugs automatically -## - -​ - -Prerequisites +## Prerequisites * **Node.js 18.14+** or **Python 3.10+** * An **Anthropic account**. If you don’t have one, [sign up here](<https://platform.claude.com/>). -## - -​ - -Setup +## Setup 1 @@ -105,11 +97,7 @@ Unless previously approved, Anthropic does not allow third party developers to offer claude.ai login or rate limits for their products, including agents built on the Claude Agent SDK. Use the API key authentication methods described in this document instead. -## - -​ - -Create a buggy file +## Create a buggy file This quickstart walks you through building an agent that can find and fix bugs in code. First, you need a file with some intentional bugs for the agent to fix. Create `utils.py` in the `my-agent` directory and paste the following code: @@ -127,11 +115,7 @@ 1. `calculate_average([])` crashes with division by zero 2. `get_user_name(None)` crashes with a TypeError -## - -​ - -Build an agent that finds and fixes bugs +## Build an agent that finds and fixes bugs Create `agent.py` if you’re using the Python SDK, or `agent.ts` for TypeScript. Use `agent.mts` instead if your existing project uses CommonJS: @@ -197,11 +181,7 @@ This example uses streaming to show progress in real-time. If you don’t need live output (for example, for background jobs or CI pipelines), you can collect all messages at once. See [Streaming vs. single-turn mode](</docs/en/agent-sdk/streaming-vs-single-mode>) for details. -### - -​ - -Run your agent +### Run your agent Your agent is ready. Run it with the following command: @@ -231,11 +211,7 @@ If you see an authentication error such as `Not logged in` or `Invalid API key`, make sure you’ve set the `ANTHROPIC_API_KEY` environment variable in the shell where you run your agent. The SDK doesn’t load `.env` files automatically.For the causes and fixes behind these and other authentication errors, see [Authentication errors](</docs/en/errors#authentication-errors>) in the Error reference. -### - -​ - -Try other prompts +### Try other prompts Now that your agent is set up, try some different prompts: @@ -243,11 +219,7 @@ * `"Add type hints to all functions in utils.py"` * `"Create a README.md documenting the functions in utils.py"` -### - -​ - -Customize your agent +### Customize your agent You can modify your agent’s behavior by changing the options. Here are a few examples: **Add web search capability:** @@ -305,11 +277,7 @@ With `Bash` enabled, try: `"Write unit tests for utils.py, run them, and fix any failures"` Each of these snippets sets fields on the same options object. For more information, see [Configure your agent](</docs/en/agent-sdk/configuration>). -## - -​ - -Key concepts +## Key concepts **Tools** control what your agent can do: @@ -321,11 +289,7 @@ **Permission modes** control how much human oversight you want. The SDK evaluates the active mode together with your allow and deny rules in a fixed order, described in [How permissions are evaluated](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>). For the full list of modes, their behavior, and when to use each, see [Permission mode in How the agent loop works](</docs/en/agent-sdk/agent-loop#permission-mode>). -## - -​ - -Next steps +## Next steps Now that you’ve created your first agent, learn how to extend its capabilities and tailor it to your use case:
modified
--- a/quickstart.md +++ b/quickstart.md @@ -10,7 +10,7 @@ Prerequisites - * **Node.js 18+** or **Python 3.10+** + * **Node.js 18.14+** or **Python 3.10+** * An **Anthropic account**. If you don’t have one, [sign up here](<https://platform.claude.com/>). ##
modified
--- a/quickstart.md +++ b/quickstart.md @@ -103,7 +103,7 @@ See the setup guides for [Amazon Bedrock](</docs/en/amazon-bedrock>), [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), [Google Cloud’s Agent Platform](</docs/en/google-vertex-ai>), or [Microsoft Foundry](</docs/en/microsoft-foundry>) for details. -Unless previously approved, Anthropic does not allow third party developers to offer claude.ai login or rate limits for their products, including agents built on the Claude Agent SDK. Please use the API key authentication methods described in this document instead. +Unless previously approved, Anthropic does not allow third party developers to offer claude.ai login or rate limits for their products, including agents built on the Claude Agent SDK. Use the API key authentication methods described in this document instead. ##
modified
--- a/quickstart.md +++ b/quickstart.md @@ -229,7 +229,7 @@ This is what makes the Agent SDK different: Claude executes tools directly instead of asking you to implement them. -If you see an authentication error such as `Not logged in` or `Invalid API key`, make sure you’ve set the `ANTHROPIC_API_KEY` environment variable in the shell where you run your agent. The SDK doesn’t load `.env` files automatically. See the [full troubleshooting guide](</docs/en/troubleshooting>) for more help. +If you see an authentication error such as `Not logged in` or `Invalid API key`, make sure you’ve set the `ANTHROPIC_API_KEY` environment variable in the shell where you run your agent. The SDK doesn’t load `.env` files automatically.For the causes and fixes behind these and other authentication errors, see [Authentication errors](</docs/en/errors#authentication-errors>) in the Error reference. ### @@ -336,4 +336,4 @@ * **[MCP servers](</docs/en/agent-sdk/mcp>)** : connect to databases, browsers, APIs, and other external systems * **[Hosting](</docs/en/agent-sdk/hosting>)** : deploy agents to Docker, cloud, and CI/CD * **[Example agents](<https://github.com/anthropics/claude-agent-sdk-demos>)** : see complete examples: email assistant, research agent, and more - * **[Troubleshooting](</docs/en/agent-sdk/troubleshooting>)** : fix Agent SDK errors by the exact message you see + * **[Troubleshooting](</docs/en/agent-sdk/troubleshooting>)** : fix errors when the CLI fails to start or exits, or a result arrives without structured output
modified
--- a/quickstart.md +++ b/quickstart.md @@ -195,7 +195,7 @@ The `async for` loop keeps running as Claude thinks, calls tools, observes results, and decides what to do next. Each iteration yields a message: Claude’s reasoning, a tool call, a tool result, or the final outcome. The SDK handles the orchestration, tool execution, context management, and retries, so you consume the stream. The loop ends when Claude finishes the task or hits an error. The message handling inside the loop filters for human-readable output. Without filtering, you’d see raw message objects including system initialization and internal state, which is useful for debugging but noisy otherwise. -This example uses streaming to show progress in real-time. If you don’t need live output (e.g., for background jobs or CI pipelines), you can collect all messages at once. See [Streaming vs. single-turn mode](</docs/en/agent-sdk/streaming-vs-single-mode>) for details. +This example uses streaming to show progress in real-time. If you don’t need live output (for example, for background jobs or CI pipelines), you can collect all messages at once. See [Streaming vs. single-turn mode](</docs/en/agent-sdk/streaming-vs-single-mode>) for details. ###
modified
--- a/quickstart.md +++ b/quickstart.md @@ -56,7 +56,7 @@ [tsx](<https://tsx.hirok.io>) runs TypeScript files directly. If your project uses CommonJS, name your agent script `agent.mts` instead of `agent.ts`. The `.mts` extension makes tsx treat the file as an ES module, so top-level `await` works without converting your whole project to ES modules. Use `agent.mts` in place of `agent.ts` in the create and run steps later in this quickstart. -[uv](<https://docs.astral.sh/uv/>) is a fast Python package manager that handles virtual environments automatically: +[Install uv](<https://docs.astral.sh/uv/>), a fast Python package manager that handles virtual environments automatically. Then initialize a project and add the SDK: uv init uv add claude-agent-sdk @@ -303,7 +303,7 @@ } }; -With `Bash` enabled, try: `"Write unit tests for utils.py, run them, and fix any failures"` +With `Bash` enabled, try: `"Write unit tests for utils.py, run them, and fix any failures"` Each of these snippets sets fields on the same options object. For more information, see [Configure your agent](</docs/en/agent-sdk/configuration>). ## @@ -329,6 +329,7 @@ Now that you’ve created your first agent, learn how to extend its capabilities and tailor it to your use case: + * **[Configure your agent](</docs/en/agent-sdk/configuration>)** : compose the options object and find the page that covers each setting * **[Permissions](</docs/en/agent-sdk/permissions>)** : control what your agent can do and when it needs approval * **[Hooks](</docs/en/agent-sdk/hooks>)** : run custom code before or after tool calls * **[Sessions](</docs/en/agent-sdk/sessions>)** : build multi-turn agents that maintain context
modified
--- a/quickstart.md +++ b/quickstart.md @@ -229,7 +229,7 @@ This is what makes the Agent SDK different: Claude executes tools directly instead of asking you to implement them. -If you see “API key not found”, make sure you’ve set the `ANTHROPIC_API_KEY` environment variable in the shell where you run your agent. The SDK doesn’t load `.env` files automatically. See the [full troubleshooting guide](</docs/en/troubleshooting>) for more help. +If you see an authentication error such as `Not logged in` or `Invalid API key`, make sure you’ve set the `ANTHROPIC_API_KEY` environment variable in the shell where you run your agent. The SDK doesn’t load `.env` files automatically. See the [full troubleshooting guide](</docs/en/troubleshooting>) for more help. ### @@ -335,3 +335,4 @@ * **[MCP servers](</docs/en/agent-sdk/mcp>)** : connect to databases, browsers, APIs, and other external systems * **[Hosting](</docs/en/agent-sdk/hosting>)** : deploy agents to Docker, cloud, and CI/CD * **[Example agents](<https://github.com/anthropics/claude-agent-sdk-demos>)** : see complete examples: email assistant, research agent, and more + * **[Troubleshooting](</docs/en/agent-sdk/troubleshooting>)** : fix Agent SDK errors by the exact message you see
modified
Show diff (647 lines)
--- a/quickstart.md +++ b/quickstart.md @@ -1,307 +1,337 @@ -This quickstart guide will have you using AI-powered coding assistance in a few minutes. By the end, you’ll understand how to use Claude Code for common development tasks. - -## - -​ - -Before you begin - -Make sure you have: - - * A terminal or command prompt open - * If you’ve never used the terminal before, check out the [terminal guide](</docs/en/terminal-guide>) - * A code project to work with - * A [Claude subscription](<https://claude.com/pricing?utm_source=claude_code&utm_medium=docs&utm_content=quickstart_prereq>) (Pro, Max, Team, or Enterprise), [Claude Console](<https://console.anthropic.com/>) account, or access through a [supported cloud provider](</docs/en/third-party-integrations>) - -This guide covers the terminal CLI. Claude Code is also available on the [web](<https://claude.ai/code>), as a [desktop app](</docs/en/desktop>), in [VS Code](</docs/en/vs-code>) and [JetBrains IDEs](</docs/en/jetbrains>), in [Slack](</docs/en/slack>), and in CI/CD with [GitHub Actions](</docs/en/github-actions>) and [GitLab](</docs/en/gitlab-ci-cd>). See [all interfaces](</docs/en/overview#use-claude-code-everywhere>). - -## - -​ - -Step 1: Install Claude Code - -To install Claude Code, use one of the following methods: - - * Native Install (Recommended) - - * Homebrew - - * WinGet - -**macOS, Linux, WSL:** - - curl -fsSL https://claude.ai/install.sh | bash - -**Windows PowerShell:** - - irm https://claude.ai/install.ps1 | iex - -**Windows CMD:** - - curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd - -If you see `The token '&&' is not a valid statement separator`, you’re in PowerShell, not CMD. If you see `'irm' is not recognized as an internal or external command`, you’re in CMD, not PowerShell. Your prompt shows `PS C:\` when you’re in PowerShell and `C:\` without the `PS` when you’re in CMD.If the install command fails with `syntax error near unexpected token '<'`, a `403`, or another curl error, see [Troubleshoot installation](</docs/en/troubleshoot-install#find-your-error>) to match the error to a fix and for alternative install methods.[Git for Windows](<https://git-scm.com/downloads/win>) is recommended on native Windows so Claude Code can use the Bash tool. If Git for Windows is not installed, Claude Code uses PowerShell as the shell tool instead. WSL setups do not need Git for Windows. - -Native installations automatically update in the background to keep you on the latest version. - - brew install --cask claude-code - -Homebrew offers two casks. `claude-code` tracks the stable release channel, which is typically about a week behind and skips releases with major regressions. `claude-code@latest` tracks the latest channel and receives new versions as soon as they ship. - -Homebrew installations do not auto-update. Run `brew upgrade claude-code` or `brew upgrade claude-code@latest`, depending on which cask you installed, to get the latest features and security fixes. - - winget install Anthropic.ClaudeCode - -WinGet installations do not auto-update. Run `winget upgrade Anthropic.ClaudeCode` periodically to get the latest features and security fixes. - -You can also install with [apt, dnf, or apk](</docs/en/setup#install-with-linux-package-managers>) on Debian, Fedora, RHEL, and Alpine. To confirm the installation worked, run: - - claude --version - -The command prints a version number followed by `(Claude Code)`. - -## - -​ - -Step 2: Log in to your account - -Claude Code requires an account to use. Start an interactive session with the `claude` command and you’ll be prompted to log in on first use: - - claude - -For Claude subscription or Console accounts, follow the prompts to complete authentication in your browser. If you’ve set the `ANTHROPIC_API_KEY` environment variable, Claude Code skips the login prompt and asks you to approve the key instead. To switch accounts later or re-authenticate, type `/login` inside the running session: - - /login - -You can log in using any of these account types: - - * [Claude Pro, Max, Team, or Enterprise](<https://claude.com/pricing?utm_source=claude_code&utm_medium=docs&utm_content=quickstart_login>) (recommended) - * [Claude Console](<https://console.anthropic.com/>) (API access with pre-paid credits). On first login, a “Claude Code” workspace is automatically created in the Console for centralized cost tracking. - * [Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry](</docs/en/third-party-integrations>) (enterprise cloud providers) - * A self-hosted [Claude apps gateway](</docs/en/claude-apps-gateway>), if your organization runs one: your admin pre-configures the gateway URL, and `/login` opens directly on the **Cloud gateway** screen for you to sign in with corporate SSO - -Once logged in, your credentials are stored and you won’t need to log in again. - -## - -​ - -Step 3: Start your first session - -Open your terminal in any project directory and start Claude Code: - - cd /path/to/your/project - claude - -Replace `/path/to/your/project` with the path to the project you want to work on. You’ll see the Claude Code prompt with the version, current model, and working directory shown above it. Type `/help` for available commands or `/resume` to continue a previous conversation. - -After logging in (Step 2), your credentials are stored on your system. Learn more in [Credential Management](</docs/en/authentication#credential-management>). - -## - -​ - -Step 4: Ask your first question - -Let’s start with understanding your codebase. Try one of these commands: - - what does this project do? - -Claude will analyze your files and provide a summary. You can also ask more specific questions: - - what technologies does this project use? - - where is the main entry point? - - explain the folder structure - -You can also ask Claude about its own capabilities: - - what can Claude Code do? - - how do I create custom skills in Claude Code? - - can Claude Code work with Docker? - -Claude Code reads your project files as needed. You don’t have to manually add context. - -## - -​ - -Step 5: Make your first code change - -Now let’s make Claude Code do some actual coding. Try a simple task: - - add a hello world function to the main file - -Claude Code will: - - 1. Find the appropriate file - 2. Show you the proposed changes - 3. Ask for your approval before changing files, depending on your permission mode - 4. Make the edit - -Whether Claude Code asks before changing files depends on your [permission mode](</docs/en/permission-modes>). In default mode, Claude asks for approval before each change. Press `Shift+Tab` to cycle through modes: `acceptEdits` auto-approves file edits, and `plan` lets Claude propose changes without editing. Some accounts also have an `auto` mode that runs a background safety check and blocks risky actions, returning to prompts only after repeated blocks. - -## - -​ - -Step 6: Use Git with Claude Code - -Claude Code makes Git operations conversational: - - what files have I changed? - - commit my changes with a descriptive message - -You can also prompt for more complex Git operations: - - create a new branch called feature/quickstart - - show me the last 5 commits - - help me resolve merge conflicts - -## - -​ - -Step 7: Fix a bug or add a feature - -Claude is proficient at debugging and feature implementation. Describe what you want in natural language: - - add input validation to the user registration form - -Or fix existing issues: - - there's a bug where users can submit empty forms - fix it - -Claude Code will: - - * Locate the relevant code - * Understand the context - * Implement a solution - * Run tests if available - -## - -​ - -Step 8: Test out other common workflows - -There are a number of ways to work with Claude: **Refactor code** - - refactor the authentication module to use async/await instead of callbacks - -**Write tests** - - write unit tests for the calculator functions - -**Update documentation** - - update the README with installation instructions - -**Code review** - - review my changes and suggest improvements - -Talk to Claude like you would a helpful colleague. Describe what you want to achieve, and it will help you get there. - -## - -​ - -Essential commands - -Here are the most important commands for daily use. Shell commands run from your terminal to start or resume Claude Code. Session commands run inside Claude Code after it starts. **Shell commands** - -Command| What it does| Example ----|---|--- -`claude`| Start interactive mode| `claude` -`claude "task"`| Run a one-time task| `claude "fix the build error"` -`claude -p "query"`| Run one-off query, then exit| `claude -p "explain this function"` -`claude -c`| Continue most recent conversation in current directory| `claude -c` -`claude -r`| Resume a previous conversation| `claude -r` - -**Session commands** - -Command| What it does| Example ----|---|--- -`/clear`| Clear conversation history| `/clear` -`/help`| Show available commands| `/help` -`/exit` or Ctrl+D twice| Exit Claude Code| `/exit` - -See the [CLI reference](</docs/en/cli-reference>) for the complete list of shell commands and the [commands reference](</docs/en/commands>) for the complete list of session commands. - -## - -​ - -Pro tips for beginners - -For more, see [best practices](</docs/en/best-practices>) and [common workflows](</docs/en/common-workflows>). - -Be specific with your requests - -Instead of: “fix the bug”Try: “fix the login bug where users see a blank screen after entering wrong credentials” - -Use step-by-step instructions - -Break complex tasks into steps: - - 1. create a new database table for user profiles - 2. create an API endpoint to get and update user profiles - 3. build a webpage that allows users to see and edit their information - -Let Claude explore first - -Before making changes, let Claude understand your code: - - analyze the database schema - - build a dashboard showing products that are most frequently returned by our UK customers - -Save time with shortcuts - - * Type `/` to see all commands and skills - * Use Tab for command completion - * Press ↑ for command history - * Press `Shift+Tab` to cycle permission modes - -## - -​ - -What’s next? - -Now that you’ve learned the basics, explore more advanced features: - -## How Claude Code works - -Understand the agentic loop, built-in tools, and how Claude Code interacts with your project - -## Best practices - -Get better results with effective prompting and project setup - -## Common workflows - -Step-by-step guides for common tasks - -## Extend Claude Code - -Customize with CLAUDE.md, skills, hooks, MCP, and more - -## - -​ - -Getting help - - * **In Claude Code** : Type `/help` or ask “how do I…” - * **Documentation** : You’re here! Browse other guides - * **Community** : Join our [Discord](<https://www.anthropic.com/discord>) for tips and support +Use the Agent SDK to build an AI agent that reads your code, finds bugs, and fixes them, all without manual intervention. **What you’ll do:** + + 1. Set up a project with the Agent SDK + 2. Create a file with some buggy code + 3. Run an agent that finds and fixes the bugs automatically + +## + +​ + +Prerequisites + + * **Node.js 18+** or **Python 3.10+** + * An **Anthropic account**. If you don’t have one, [sign up here](<https://platform.claude.com/>). + +## + +​ + +Setup + +1 + +Create a project folder + +Create a new directory for this quickstart: + + mkdir my-agent + cd my-agent + +For your own projects, you can run the SDK from any folder; it will have access to files in that directory and its subdirectories by default. + +2 + +Install the SDK + +Install the Agent SDK package for your language: + + * TypeScript (new project) + + * TypeScript (existing project) + + * Python (uv) + + * Python (pip) + + npm init -y + npm pkg set type=module + npm install @anthropic-ai/claude-agent-sdk + npm install --save-dev tsx + +Setting `"type": "module"` in `package.json` lets your agent script use top-level `await`, and [tsx](<https://tsx.hirok.io>) runs TypeScript files directly. npm prints `added N packages` when the install succeeds. + + npm install @anthropic-ai/claude-agent-sdk + npm install --save-dev tsx + +[tsx](<https://tsx.hirok.io>) runs TypeScript files directly. If your project uses CommonJS, name your agent script `agent.mts` instead of `agent.ts`. The `.mts` extension makes tsx treat the file as an ES module, so top-level `await` works without converting your whole project to ES modules. Use `agent.mts` in place of `agent.ts` in the create and run steps later in this quickstart. + +[uv](<https://docs.astral.sh/uv/>) is a fast Python package manager that handles virtual environments automatically: + + uv init + uv add claude-agent-sdk + +Create and activate a virtual environment, then install the package.On macOS or Linux: + + python3 -m venv .venv + source .venv/bin/activate + pip install claude-agent-sdk + +On Windows: + + py -m venv .venv + .venv\Scripts\Activate.ps1 + pip install claude-agent-sdk + +If PowerShell blocks `Activate.ps1` with an execution policy error, run `Set-ExecutionPolicy -Scope Process RemoteSigned` first. + +Both the TypeScript and Python SDKs bundle a native Claude Code binary, so most installs need no separate Claude Code install. Some installs have no bundled binary: + + * If pip installs the Python SDK’s source distribution instead of a platform wheel, for example on ARM64 Windows, no binary is bundled. [Install Claude Code natively](</docs/en/setup#install-claude-code>). The Python SDK finds it on your `PATH`. + * The TypeScript SDK installs its binary through npm optional dependencies, so an install that skips them, for example `npm ci --omit=optional`, gets no binary even on a supported platform. Reinstall without skipping optional dependencies, or [install Claude Code natively](</docs/en/setup#install-claude-code>) and set `pathToClaudeCodeExecutable` to its path. + +3 + +Set your API key + +Get an API key from the [Claude Console](<https://platform.claude.com/>), then set it as an environment variable in the shell where you’ll run your agent: + + * macOS / Linux + + * Windows (PowerShell) + + export ANTHROPIC_API_KEY=your-api-key + + $env:ANTHROPIC_API_KEY = "your-api-key" + +The SDK reads the key from the environment of the process that runs your agent; it doesn’t load `.env` files automatically. If you keep the key in a `.env` file, load it yourself, for example with the `dotenv` package, before calling the SDK.The SDK also supports authentication via third-party API providers: + + * **Amazon Bedrock** : set `CLAUDE_CODE_USE_BEDROCK=1` environment variable and configure AWS credentials + * **Claude Platform on AWS** : set `CLAUDE_CODE_USE_ANTHROPIC_AWS=1` and `ANTHROPIC_AWS_WORKSPACE_ID`, then configure AWS credentials + * **Google Cloud’s Agent Platform** : set `CLAUDE_CODE_USE_VERTEX=1` environment variable and configure Google Cloud credentials + * **Microsoft Foundry** : set `CLAUDE_CODE_USE_FOUNDRY=1` environment variable and configure Azure credentials + +See the setup guides for [Amazon Bedrock](</docs/en/amazon-bedrock>), [Claude Platform on AWS](</docs/en/claude-platform-on-aws>), [Google Cloud’s Agent Platform](</docs/en/google-vertex-ai>), or [Microsoft Foundry](</docs/en/microsoft-foundry>) for details. + +Unless previously approved, Anthropic does not allow third party developers to offer claude.ai login or rate limits for their products, including agents built on the Claude Agent SDK. Please use the API key authentication methods described in this document instead. + +## + +​ + +Create a buggy file + +This quickstart walks you through building an agent that can find and fix bugs in code. First, you need a file with some intentional bugs for the agent to fix. Create `utils.py` in the `my-agent` directory and paste the following code: + + def calculate_average(numbers): + total = 0 + for num in numbers: + total += num + return total / len(numbers) + + def get_user_name(user): + return user["name"].upper() + +This code has two bugs: + + 1. `calculate_average([])` crashes with division by zero + 2. `get_user_name(None)` crashes with a TypeError + +## + +​ + +Build an agent that finds and fixes bugs + +Create `agent.py` if you’re using the Python SDK, or `agent.ts` for TypeScript. Use `agent.mts` instead if your existing project uses CommonJS: + +Python + +TypeScript + + import asyncio + from claude_agent_sdk import query, ClaudeAgentOptions, AssistantMessage, ResultMessage + + async def main(): + # Agentic loop: streams messages as Claude works + async for message in query( + prompt="Review utils.py for bugs that would cause crashes. Fix any issues you find.", + options=ClaudeAgentOptions( + allowed_tools=["Read", "Edit", "Glob"], # Auto-approve these tools + permission_mode="acceptEdits", # Auto-approve file edits + ), + ): + # Print human-readable output + if isinstance(message, AssistantMessage): + for block in message.content: + if hasattr(block, "text"): + print(block.text) # Claude's reasoning + elif hasattr(block, "name"): + print(f"Tool: {block.name}") # Tool being called + elif isinstance(message, ResultMessage): + print(f"Done: {message.subtype}") # Final result + + asyncio.run(main()) + + import { query } from "@anthropic-ai/claude-agent-sdk"; + + // Agentic loop: streams messages as Claude works + for await (const message of query({ + prompt: "Review utils.py for bugs that would cause crashes. Fix any issues you find.", + options: { + allowedTools: ["Read", "Edit", "Glob"], // Auto-approve these tools + permissionMode: "acceptEdits" // Auto-approve file edits + } + })) { + // Print human-readable output + if (message.type === "assistant" && message.message?.content) { + for (const block of message.message.content) { + if ("text" in block) { + console.log(block.text); // Claude's reasoning + } else if ("name" in block) { + console.log(`Tool: ${block.name}`); // Tool being called + } + } + } else if (message.type === "result") { + console.log(`Done: ${message.subtype}`); // Final result + } + } + +This code has three main parts: + + 1. **`query`** : the main entry point that creates the agentic loop. It returns an async iterator, so you use `async for` to stream messages as Claude works. See the full API in the [Python](</docs/en/agent-sdk/python#query>) or [TypeScript](</docs/en/agent-sdk/typescript#query>) SDK reference. + 2. **`prompt`** : what you want Claude to do. Claude figures out which tools to use based on the task. + 3. **`options`** : configuration for the agent. This example uses `allowedTools` to pre-approve `Read`, `Edit`, and `Glob`, and `permissionMode: "acceptEdits"` to auto-approve file changes. Other options include `systemPrompt`, `mcpServers`, and more. See all options for [Python](</docs/en/agent-sdk/python#claudeagentoptions>) or [TypeScript](</docs/en/agent-sdk/typescript#options>). + +The `async for` loop keeps running as Claude thinks, calls tools, observes results, and decides what to do next. Each iteration yields a message: Claude’s reasoning, a tool call, a tool result, or the final outcome. The SDK handles the orchestration, tool execution, context management, and retries, so you consume the stream. The loop ends when Claude finishes the task or hits an error. The message handling inside the loop filters for human-readable output. Without filtering, you’d see raw message objects including system initialization and internal state, which is useful for debugging but noisy otherwise. + +This example uses streaming to show progress in real-time. If you don’t need live output (e.g., for background jobs or CI pipelines), you can collect all messages at once. See [Streaming vs. single-turn mode](</docs/en/agent-sdk/streaming-vs-single-mode>) for details. + +### + +​ + +Run your agent + +Your agent is ready. Run it with the following command: + + * TypeScript + + * Python (uv) + + * Python (pip) + + npx tsx agent.ts + +If you named your script `agent.mts`, run `npx tsx agent.mts` instead. + + uv run agent.py + +With your virtual environment still activated: + + python agent.py + +As it works, the agent prints its reasoning and each tool it calls, ending with `Done: success`. After running, check `utils.py`. You’ll see defensive code handling empty lists and null users. Your agent autonomously: + + 1. **Read** `utils.py` to understand the code + 2. **Analyzed** the logic and identified edge cases that would crash + 3. **Edited** the file to add proper error handling + +This is what makes the Agent SDK different: Claude executes tools directly instead of asking you to implement them. + +If you see “API key not found”, make sure you’ve set the `ANTHROPIC_API_KEY` environment variable in the shell where you run your agent. The SDK doesn’t load `.env` files automatically. See the [full troubleshooting guide](</docs/en/troubleshooting>) for more help. + +### + +​ + +Try other prompts + +Now that your agent is set up, try some different prompts: + + * `"Add docstrings to all functions in utils.py"` + * `"Add type hints to all functions in utils.py"` + * `"Create a README.md documenting the functions in utils.py"` + +### + +​ + +Customize your agent + +You can modify your agent’s behavior by changing the options. Here are a few examples: **Add web search capability:** + +Python + +TypeScript + + options = ClaudeAgentOptions( + allowed_tools=["Read", "Edit", "Glob", "WebSearch"], permission_mode="acceptEdits" + ) + + const _ = { + options: { + allowedTools: ["Read", "Edit", "Glob", "WebSearch"], + permissionMode: "acceptEdits" + } + }; + +**Give Claude a custom system prompt:** + +Python + +TypeScript + + options = ClaudeAgentOptions( + allowed_tools=["Read", "Edit", "Glob"], + permission_mode="acceptEdits", + system_prompt="You are a senior Python developer. Always follow PEP 8 style guidelines.", + ) + + const _ = { + options: { + allowedTools: ["Read", "Edit", "Glob"], + permissionMode: "acceptEdits", + systemPrompt: "You are a senior Python developer. Always follow PEP 8 style guidelines." + } + }; + +**Run commands in the terminal:** + +Python + +TypeScript + + options = ClaudeAgentOptions( + allowed_tools=["Read", "Edit", "Glob", "Bash"], permission_mode="acceptEdits" + ) + + const _ = { + options: { + allowedTools: ["Read", "Edit", "Glob", "Bash"], + permissionMode: "acceptEdits" + } + }; + +With `Bash` enabled, try: `"Write unit tests for utils.py, run them, and fix any failures"` + +## + +​ + +Key concepts + +**Tools** control what your agent can do: + +Tools| What the agent can do +---|--- +`Read`, `Glob`, `Grep`| Read-only analysis +`Read`, `Edit`, `Glob`| Analyze and modify code +`Read`, `Edit`, `Bash`, `Glob`, `Grep`| Full automation + +**Permission modes** control how much human oversight you want. The SDK evaluates the active mode together with your allow and deny rules in a fixed order, described in [How permissions are evaluated](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>). For the full list of modes, their behavior, and when to use each, see [Permission mode in How the agent loop works](</docs/en/agent-sdk/agent-loop#permission-mode>). + +## + +​ + +Next steps + +Now that you’ve created your first agent, learn how to extend its capabilities and tailor it to your use case: + + * **[Permissions](</docs/en/agent-sdk/permissions>)** : control what your agent can do and when it needs approval + * **[Hooks](</docs/en/agent-sdk/hooks>)** : run custom code before or after tool calls + * **[Sessions](</docs/en/agent-sdk/sessions>)** : build multi-turn agents that maintain context + * **[MCP servers](</docs/en/agent-sdk/mcp>)** : connect to databases, browsers, APIs, and other external systems + * **[Hosting](</docs/en/agent-sdk/hosting>)** : deploy agents to Docker, cloud, and CI/CD + * **[Example agents](<https://github.com/anthropics/claude-agent-sdk-demos>)** : see complete examples: email assistant, research agent, and more
modified
--- a/quickstart.md +++ b/quickstart.md @@ -71,7 +71,7 @@ claude -For Claude subscription or Console accounts, follow the prompts to complete authentication in your browser. To switch accounts later or re-authenticate, type `/login` inside the running session: +For Claude subscription or Console accounts, follow the prompts to complete authentication in your browser. If you’ve set the `ANTHROPIC_API_KEY` environment variable, Claude Code skips the login prompt and asks you to approve the key instead. To switch accounts later or re-authenticate, type `/login` inside the running session: /login
modified
--- a/quickstart.md +++ b/quickstart.md @@ -55,7 +55,11 @@ WinGet installations do not auto-update. Run `winget upgrade Anthropic.ClaudeCode` periodically to get the latest features and security fixes. -You can also install with [apt, dnf, or apk](</docs/en/setup#install-with-linux-package-managers>) on Debian, Fedora, RHEL, and Alpine. +You can also install with [apt, dnf, or apk](</docs/en/setup#install-with-linux-package-managers>) on Debian, Fedora, RHEL, and Alpine. To confirm the installation worked, run: + + claude --version + +The command prints a version number followed by `(Claude Code)`. ## @@ -91,7 +95,7 @@ cd /path/to/your/project claude -You’ll see the Claude Code prompt with the version, current model, and working directory shown above it. Type `/help` for available commands or `/resume` to continue a previous conversation. +Replace `/path/to/your/project` with the path to the project you want to work on. You’ll see the Claude Code prompt with the version, current model, and working directory shown above it. Type `/help` for available commands or `/resume` to continue a previous conversation. After logging in (Step 2), your credentials are stored on your system. Learn more in [Credential Management](</docs/en/authentication#credential-management>). @@ -137,10 +141,10 @@ 1. Find the appropriate file 2. Show you the proposed changes - 3. Ask for your approval + 3. Ask for your approval before changing files, depending on your permission mode 4. Make the edit -Claude Code always asks for permission before modifying files. You can approve individual changes or enable “Accept all” mode for a session. +Whether Claude Code asks before changing files depends on your [permission mode](</docs/en/permission-modes>). In default mode, Claude asks for approval before each change. Press `Shift+Tab` to cycle through modes: `acceptEdits` auto-approves file edits, and `plan` lets Claude propose changes without editing. Some accounts also have an `auto` mode that runs a background safety check and blocks risky actions, returning to prompts only after repeated blocks. ## @@ -229,7 +233,7 @@ ---|---|--- `/clear`| Clear conversation history| `/clear` `/help`| Show available commands| `/help` -`/exit` or Ctrl+D| Exit Claude Code| `/exit` +`/exit` or Ctrl+D twice| Exit Claude Code| `/exit` See the [CLI reference](</docs/en/cli-reference>) for the complete list of shell commands and the [commands reference](</docs/en/commands>) for the complete list of session commands.
modified
--- a/quickstart.md +++ b/quickstart.md @@ -75,7 +75,7 @@ * [Claude Pro, Max, Team, or Enterprise](<https://claude.com/pricing?utm_source=claude_code&utm_medium=docs&utm_content=quickstart_login>) (recommended) * [Claude Console](<https://console.anthropic.com/>) (API access with pre-paid credits). On first login, a “Claude Code” workspace is automatically created in the Console for centralized cost tracking. - * [Amazon Bedrock, Google Vertex AI, or Microsoft Foundry](</docs/en/third-party-integrations>) (enterprise cloud providers) + * [Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry](</docs/en/third-party-integrations>) (enterprise cloud providers) * A self-hosted [Claude apps gateway](</docs/en/claude-apps-gateway>), if your organization runs one: your admin pre-configures the gateway URL, and `/login` opens directly on the **Cloud gateway** screen for you to sign in with corporate SSO Once logged in, your credentials are stored and you won’t need to log in again.
modified
--- a/quickstart.md +++ b/quickstart.md @@ -76,6 +76,7 @@ * [Claude Pro, Max, Team, or Enterprise](<https://claude.com/pricing?utm_source=claude_code&utm_medium=docs&utm_content=quickstart_login>) (recommended) * [Claude Console](<https://console.anthropic.com/>) (API access with pre-paid credits). On first login, a “Claude Code” workspace is automatically created in the Console for centralized cost tracking. * [Amazon Bedrock, Google Vertex AI, or Microsoft Foundry](</docs/en/third-party-integrations>) (enterprise cloud providers) + * A self-hosted [Claude apps gateway](</docs/en/claude-apps-gateway>), if your organization runs one: your admin pre-configures the gateway URL, and `/login` opens directly on the **Cloud gateway** screen for you to sign in with corporate SSO Once logged in, your credentials are stored and you won’t need to log in again.
modified
--- a/quickstart.md +++ b/quickstart.md @@ -41,7 +41,7 @@ curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd -If you see `The token '&&' is not a valid statement separator`, you’re in PowerShell, not CMD. If you see `'irm' is not recognized as an internal or external command`, you’re in CMD, not PowerShell. Your prompt shows `PS C:\` when you’re in PowerShell and `C:\` without the `PS` when you’re in CMD.[Git for Windows](<https://git-scm.com/downloads/win>) is recommended on native Windows so Claude Code can use the Bash tool. If Git for Windows is not installed, Claude Code uses PowerShell as the shell tool instead. WSL setups do not need Git for Windows. +If you see `The token '&&' is not a valid statement separator`, you’re in PowerShell, not CMD. If you see `'irm' is not recognized as an internal or external command`, you’re in CMD, not PowerShell. Your prompt shows `PS C:\` when you’re in PowerShell and `C:\` without the `PS` when you’re in CMD.If the install command fails with `syntax error near unexpected token '<'`, a `403`, or another curl error, see [Troubleshoot installation](</docs/en/troubleshoot-install#find-your-error>) to match the error to a fix and for alternative install methods.[Git for Windows](<https://git-scm.com/downloads/win>) is recommended on native Windows so Claude Code can use the Bash tool. If Git for Windows is not installed, Claude Code uses PowerShell as the shell tool instead. WSL setups do not need Git for Windows. Native installations automatically update in the background to keep you on the latest version.
modified
--- a/quickstart.md +++ b/quickstart.md @@ -212,7 +212,7 @@ Essential commands -Here are the most important commands for daily use: +Here are the most important commands for daily use. Shell commands run from your terminal to start or resume Claude Code. Session commands run inside Claude Code after it starts. **Shell commands** Command| What it does| Example ---|---|--- @@ -221,11 +221,16 @@ `claude -p "query"`| Run one-off query, then exit| `claude -p "explain this function"` `claude -c`| Continue most recent conversation in current directory| `claude -c` `claude -r`| Resume a previous conversation| `claude -r` + +**Session commands** + +Command| What it does| Example +---|---|--- `/clear`| Clear conversation history| `/clear` `/help`| Show available commands| `/help` -`exit` or Ctrl+D| Exit Claude Code| `exit` - -See the [CLI reference](</docs/en/cli-reference>) for a complete list of commands. +`/exit` or Ctrl+D| Exit Claude Code| `/exit` + +See the [CLI reference](</docs/en/cli-reference>) for the complete list of shell commands and the [commands reference](</docs/en/commands>) for the complete list of session commands. ##
modified
--- a/quickstart.md +++ b/quickstart.md @@ -90,7 +90,7 @@ cd /path/to/your/project claude -You’ll see the Claude Code welcome screen with your session information, recent conversations, and latest updates. Type `/help` for available commands or `/resume` to continue a previous conversation. +You’ll see the Claude Code prompt with the version, current model, and working directory shown above it. Type `/help` for available commands or `/resume` to continue a previous conversation. After logging in (Step 2), your credentials are stored on your system. Learn more in [Credential Management](</docs/en/authentication#credential-management>).
modified
--- a/quickstart.md +++ b/quickstart.md @@ -1,9 +1,3 @@ -> ## Documentation Index -> -> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> -> -> Use this file to discover all available pages before exploring further. - This quickstart guide will have you using AI-powered coding assistance in a few minutes. By the end, you’ll understand how to use Claude Code for common development tasks. ##
modified
--- a/quickstart.md +++ b/quickstart.md @@ -69,13 +69,13 @@ Step 2: Log in to your account -Claude Code requires an account to use. When you start an interactive session with the `claude` command, you’ll need to log in: +Claude Code requires an account to use. Start an interactive session with the `claude` command and you’ll be prompted to log in on first use: claude - # You'll be prompted to log in on first use + +For Claude subscription or Console accounts, follow the prompts to complete authentication in your browser. To switch accounts later or re-authenticate, type `/login` inside the running session: /login - # Follow the prompts to log in with your account You can log in using any of these account types: @@ -83,7 +83,7 @@ * [Claude Console](<https://console.anthropic.com/>) (API access with pre-paid credits). On first login, a “Claude Code” workspace is automatically created in the Console for centralized cost tracking. * [Amazon Bedrock, Google Vertex AI, or Microsoft Foundry](</docs/en/third-party-integrations>) (enterprise cloud providers) -Once logged in, your credentials are stored and you won’t need to log in again. To switch accounts later, use the `/login` command. +Once logged in, your credentials are stored and you won’t need to log in again. ##
modified
--- a/quickstart.md +++ b/quickstart.md @@ -263,10 +263,10 @@ Save time with shortcuts - * Press `?` to see all available keyboard shortcuts + * Type `/` to see all commands and skills * Use Tab for command completion * Press ↑ for command history - * Type `/` to see all commands and skills + * Press `Shift+Tab` to cycle permission modes ##
modified
--- a/quickstart.md +++ b/quickstart.md @@ -1,3 +1,9 @@ +> ## Documentation Index +> +> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> +> +> Use this file to discover all available pages before exploring further. + This quickstart guide will have you using AI-powered coding assistance in a few minutes. By the end, you’ll understand how to use Claude Code for common development tasks. ##
modified
--- a/quickstart.md +++ b/quickstart.md @@ -41,7 +41,7 @@ curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd -If you see `The token '&&' is not a valid statement separator`, you’re in PowerShell, not CMD. If you see `'irm' is not recognized as an internal or external command`, you’re in CMD, not PowerShell. Your prompt shows `PS C:\` when you’re in PowerShell and `C:\` without the `PS` when you’re in CMD.**Native Windows setups require[Git for Windows](<https://git-scm.com/downloads/win>).** Install it first if you don’t have it. WSL setups do not need it. +If you see `The token '&&' is not a valid statement separator`, you’re in PowerShell, not CMD. If you see `'irm' is not recognized as an internal or external command`, you’re in CMD, not PowerShell. Your prompt shows `PS C:\` when you’re in PowerShell and `C:\` without the `PS` when you’re in CMD.[Git for Windows](<https://git-scm.com/downloads/win>) is recommended on native Windows so Claude Code can use the Bash tool. If Git for Windows is not installed, Claude Code uses PowerShell as the shell tool instead. WSL setups do not need Git for Windows. Native installations automatically update in the background to keep you on the latest version.
modified
--- a/quickstart.md +++ b/quickstart.md @@ -54,6 +54,8 @@ winget install Anthropic.ClaudeCode WinGet installations do not auto-update. Run `winget upgrade Anthropic.ClaudeCode` periodically to get the latest features and security fixes. + +You can also install with [apt, dnf, or apk](</docs/en/setup#install-with-linux-package-managers>) on Debian, Fedora, RHEL, and Alpine. ##
modified
--- a/quickstart.md +++ b/quickstart.md @@ -41,7 +41,7 @@ curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd -If you see `The token '&&' is not a valid statement separator`, you’re in PowerShell, not CMD. Use the PowerShell command above instead. Your prompt shows `PS C:\` when you’re in PowerShell.**Native Windows setups require[Git for Windows](<https://git-scm.com/downloads/win>).** Install it first if you don’t have it. WSL setups do not need it. +If you see `The token '&&' is not a valid statement separator`, you’re in PowerShell, not CMD. If you see `'irm' is not recognized as an internal or external command`, you’re in CMD, not PowerShell. Your prompt shows `PS C:\` when you’re in PowerShell and `C:\` without the `PS` when you’re in CMD.**Native Windows setups require[Git for Windows](<https://git-scm.com/downloads/win>).** Install it first if you don’t have it. WSL setups do not need it. Native installations automatically update in the background to keep you on the latest version.
modified
--- a/quickstart.md +++ b/quickstart.md @@ -41,7 +41,7 @@ curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd -If you see `The token '&&' is not a valid statement separator`, you’re in PowerShell, not CMD. Use the PowerShell command above instead. Your prompt shows `PS C:\` when you’re in PowerShell.**Windows requires[Git for Windows](<https://git-scm.com/downloads/win>).** Install it first if you don’t have it. +If you see `The token '&&' is not a valid statement separator`, you’re in PowerShell, not CMD. Use the PowerShell command above instead. Your prompt shows `PS C:\` when you’re in PowerShell.**Native Windows setups require[Git for Windows](<https://git-scm.com/downloads/win>).** Install it first if you don’t have it. WSL setups do not need it. Native installations automatically update in the background to keep you on the latest version.
modified
--- a/quickstart.md +++ b/quickstart.md @@ -47,7 +47,9 @@ brew install --cask claude-code -Homebrew installations do not auto-update. Run `brew upgrade claude-code` periodically to get the latest features and security fixes. +Homebrew offers two casks. `claude-code` tracks the stable release channel, which is typically about a week behind and skips releases with major regressions. `claude-code@latest` tracks the latest channel and receives new versions as soon as they ship. + +Homebrew installations do not auto-update. Run `brew upgrade claude-code` or `brew upgrade claude-code@latest`, depending on which cask you installed, to get the latest features and security fixes. winget install Anthropic.ClaudeCode
modified
--- a/quickstart.md +++ b/quickstart.md @@ -11,7 +11,7 @@ * A terminal or command prompt open * If you’ve never used the terminal before, check out the [terminal guide](</docs/en/terminal-guide>) * A code project to work with - * A [Claude subscription](<https://claude.com/pricing?utm_source=claude_code&utm_medium=docs&utm_content=quickstart_prereq>) (Pro, Max, Teams, or Enterprise), [Claude Console](<https://console.anthropic.com/>) account, or access through a [supported cloud provider](</docs/en/third-party-integrations>) + * A [Claude subscription](<https://claude.com/pricing?utm_source=claude_code&utm_medium=docs&utm_content=quickstart_prereq>) (Pro, Max, Team, or Enterprise), [Claude Console](<https://console.anthropic.com/>) account, or access through a [supported cloud provider](</docs/en/third-party-integrations>) This guide covers the terminal CLI. Claude Code is also available on the [web](<https://claude.ai/code>), as a [desktop app](</docs/en/desktop>), in [VS Code](</docs/en/vs-code>) and [JetBrains IDEs](</docs/en/jetbrains>), in [Slack](</docs/en/slack>), and in CI/CD with [GitHub Actions](</docs/en/github-actions>) and [GitLab](</docs/en/gitlab-ci-cd>). See [all interfaces](</docs/en/overview#use-claude-code-everywhere>). @@ -69,7 +69,7 @@ You can log in using any of these account types: - * [Claude Pro, Max, Teams, or Enterprise](<https://claude.com/pricing?utm_source=claude_code&utm_medium=docs&utm_content=quickstart_login>) (recommended) + * [Claude Pro, Max, Team, or Enterprise](<https://claude.com/pricing?utm_source=claude_code&utm_medium=docs&utm_content=quickstart_login>) (recommended) * [Claude Console](<https://console.anthropic.com/>) (API access with pre-paid credits). On first login, a “Claude Code” workspace is automatically created in the Console for centralized cost tracking. * [Amazon Bedrock, Google Vertex AI, or Microsoft Foundry](</docs/en/third-party-integrations>) (enterprise cloud providers) @@ -217,10 +217,9 @@ `claude -p "query"`| Run one-off query, then exit| `claude -p "explain this function"` `claude -c`| Continue most recent conversation in current directory| `claude -c` `claude -r`| Resume a previous conversation| `claude -r` -`claude commit`| Create a Git commit| `claude commit` `/clear`| Clear conversation history| `/clear` `/help`| Show available commands| `/help` -`exit` or Ctrl+C| Exit Claude Code| `exit` +`exit` or Ctrl+D| Exit Claude Code| `exit` See the [CLI reference](</docs/en/cli-reference>) for a complete list of commands.
modified
--- a/quickstart.md +++ b/quickstart.md @@ -41,7 +41,7 @@ curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd -**Windows requires[Git for Windows](<https://git-scm.com/downloads/win>).** Install it first if you don’t have it. +If you see `The token '&&' is not a valid statement separator`, you’re in PowerShell, not CMD. Use the PowerShell command above instead. Your prompt shows `PS C:\` when you’re in PowerShell.**Windows requires[Git for Windows](<https://git-scm.com/downloads/win>).** Install it first if you don’t have it. Native installations automatically update in the background to keep you on the latest version.
modified
Show diff (317 lines)
--- a/quickstart.md +++ b/quickstart.md @@ -31,54 +31,24 @@ **macOS, Linux, WSL:** -Report incorrect code - -Copy - -Ask AI - - curl -fsSL https://claude.ai/install.sh | bash + curl -fsSL https://claude.ai/install.sh | bash **Windows PowerShell:** -Report incorrect code - -Copy - -Ask AI - - irm https://claude.ai/install.ps1 | iex + irm https://claude.ai/install.ps1 | iex **Windows CMD:** -Report incorrect code - -Copy - -Ask AI - - curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd + curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd **Windows requires[Git for Windows](<https://git-scm.com/downloads/win>).** Install it first if you don’t have it. Native installations automatically update in the background to keep you on the latest version. -Report incorrect code - -Copy - -Ask AI - brew install --cask claude-code Homebrew installations do not auto-update. Run `brew upgrade claude-code` periodically to get the latest features and security fixes. -Report incorrect code - -Copy - -Ask AI - winget install Anthropic.ClaudeCode WinGet installations do not auto-update. Run `winget upgrade Anthropic.ClaudeCode` periodically to get the latest features and security fixes. @@ -90,21 +60,9 @@ Step 2: Log in to your account Claude Code requires an account to use. When you start an interactive session with the `claude` command, you’ll need to log in: - -Report incorrect code - -Copy - -Ask AI claude # You'll be prompted to log in on first use - -Report incorrect code - -Copy - -Ask AI /login # Follow the prompts to log in with your account @@ -125,12 +83,6 @@ Open your terminal in any project directory and start Claude Code: -Report incorrect code - -Copy - -Ask AI - cd /path/to/your/project claude @@ -146,64 +98,22 @@ Let’s start with understanding your codebase. Try one of these commands: -Report incorrect code - -Copy - -Ask AI - what does this project do? Claude will analyze your files and provide a summary. You can also ask more specific questions: -Report incorrect code - -Copy - -Ask AI - what technologies does this project use? -Report incorrect code - -Copy - -Ask AI - where is the main entry point? -Report incorrect code - -Copy - -Ask AI - explain the folder structure You can also ask Claude about its own capabilities: -Report incorrect code - -Copy - -Ask AI - what can Claude Code do? -Report incorrect code - -Copy - -Ask AI - how do I create custom skills in Claude Code? -Report incorrect code - -Copy - -Ask AI - can Claude Code work with Docker? Claude Code reads your project files as needed. You don’t have to manually add context. @@ -215,12 +125,6 @@ Step 5: Make your first code change Now let’s make Claude Code do some actual coding. Try a simple task: - -Report incorrect code - -Copy - -Ask AI add a hello world function to the main file @@ -241,46 +145,16 @@ Claude Code makes Git operations conversational: -Report incorrect code - -Copy - -Ask AI - what files have I changed? -Report incorrect code - -Copy - -Ask AI - commit my changes with a descriptive message You can also prompt for more complex Git operations: -Report incorrect code - -Copy - -Ask AI - create a new branch called feature/quickstart -Report incorrect code - -Copy - -Ask AI - show me the last 5 commits -Report incorrect code - -Copy - -Ask AI - help me resolve merge conflicts ## @@ -291,21 +165,9 @@ Claude is proficient at debugging and feature implementation. Describe what you want in natural language: -Report incorrect code - -Copy - -Ask AI - add input validation to the user registration form Or fix existing issues: - -Report incorrect code - -Copy - -Ask AI there's a bug where users can submit empty forms - fix it @@ -324,41 +186,17 @@ There are a number of ways to work with Claude: **Refactor code** -Report incorrect code - -Copy - -Ask AI - refactor the authentication module to use async/await instead of callbacks **Write tests** -Report incorrect code - -Copy - -Ask AI - write unit tests for the calculator functions **Update documentation** -Report incorrect code - -Copy - -Ask AI - update the README with installation instructions **Code review** - -Report incorrect code - -Copy - -Ask AI review my changes and suggest improvements @@ -402,12 +240,6 @@ Break complex tasks into steps: -Report incorrect code - -Copy - -Ask AI - 1. create a new database table for user profiles 2. create an API endpoint to get and update user profiles 3. build a webpage that allows users to see and edit their information @@ -416,19 +248,7 @@ Before making changes, let Claude understand your code: -Report incorrect code - -Copy - -Ask AI - analyze the database schema - -Report incorrect code - -Copy - -Ask AI build a dashboard showing products that are most frequently returned by our UK customers
added
Show diff (477 lines)
--- a/quickstart.md +++ b/quickstart.md @@ -0,0 +1,474 @@ +This quickstart guide will have you using AI-powered coding assistance in a few minutes. By the end, you’ll understand how to use Claude Code for common development tasks. + +## + +​ + +Before you begin + +Make sure you have: + + * A terminal or command prompt open + * If you’ve never used the terminal before, check out the [terminal guide](</docs/en/terminal-guide>) + * A code project to work with + * A [Claude subscription](<https://claude.com/pricing?utm_source=claude_code&utm_medium=docs&utm_content=quickstart_prereq>) (Pro, Max, Teams, or Enterprise), [Claude Console](<https://console.anthropic.com/>) account, or access through a [supported cloud provider](</docs/en/third-party-integrations>) + +This guide covers the terminal CLI. Claude Code is also available on the [web](<https://claude.ai/code>), as a [desktop app](</docs/en/desktop>), in [VS Code](</docs/en/vs-code>) and [JetBrains IDEs](</docs/en/jetbrains>), in [Slack](</docs/en/slack>), and in CI/CD with [GitHub Actions](</docs/en/github-actions>) and [GitLab](</docs/en/gitlab-ci-cd>). See [all interfaces](</docs/en/overview#use-claude-code-everywhere>). + +## + +​ + +Step 1: Install Claude Code + +To install Claude Code, use one of the following methods: + + * Native Install (Recommended) + + * Homebrew + + * WinGet + +**macOS, Linux, WSL:** + +Report incorrect code + +Copy + +Ask AI + + curl -fsSL https://claude.ai/install.sh | bash + +**Windows PowerShell:** + +Report incorrect code + +Copy + +Ask AI + + irm https://claude.ai/install.ps1 | iex + +**Windows CMD:** + +Report incorrect code + +Copy + +Ask AI + + curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd + +**Windows requires[Git for Windows](<https://git-scm.com/downloads/win>).** Install it first if you don’t have it. + +Native installations automatically update in the background to keep you on the latest version. + +Report incorrect code + +Copy + +Ask AI + + brew install --cask claude-code + +Homebrew installations do not auto-update. Run `brew upgrade claude-code` periodically to get the latest features and security fixes. + +Report incorrect code + +Copy + +Ask AI + + winget install Anthropic.ClaudeCode + +WinGet installations do not auto-update. Run `winget upgrade Anthropic.ClaudeCode` periodically to get the latest features and security fixes. + +## + +​ + +Step 2: Log in to your account + +Claude Code requires an account to use. When you start an interactive session with the `claude` command, you’ll need to log in: + +Report incorrect code + +Copy + +Ask AI + + claude + # You'll be prompted to log in on first use + +Report incorrect code + +Copy + +Ask AI + + /login + # Follow the prompts to log in with your account + +You can log in using any of these account types: + + * [Claude Pro, Max, Teams, or Enterprise](<https://claude.com/pricing?utm_source=claude_code&utm_medium=docs&utm_content=quickstart_login>) (recommended) + * [Claude Console](<https://console.anthropic.com/>) (API access with pre-paid credits). On first login, a “Claude Code” workspace is automatically created in the Console for centralized cost tracking. + * [Amazon Bedrock, Google Vertex AI, or Microsoft Foundry](</docs/en/third-party-integrations>) (enterprise cloud providers) + +Once logged in, your credentials are stored and you won’t need to log in again. To switch accounts later, use the `/login` command. + +## + +​ + +Step 3: Start your first session + +Open your terminal in any project directory and start Claude Code: + +Report incorrect code + +Copy + +Ask AI + + cd /path/to/your/project + claude + +You’ll see the Claude Code welcome screen with your session information, recent conversations, and latest updates. Type `/help` for available commands or `/resume` to continue a previous conversation. + +After logging in (Step 2), your credentials are stored on your system. Learn more in [Credential Management](</docs/en/authentication#credential-management>). + +## + +​ + +Step 4: Ask your first question + +Let’s start with understanding your codebase. Try one of these commands: + +Report incorrect code + +Copy + +Ask AI + + what does this project do? + +Claude will analyze your files and provide a summary. You can also ask more specific questions: + +Report incorrect code + +Copy + +Ask AI + + what technologies does this project use? + +Report incorrect code + +Copy + +Ask AI + + where is the main entry point? + +Report incorrect code + +Copy + +Ask AI + + explain the folder structure + +You can also ask Claude about its own capabilities: + +Report incorrect code + +Copy + +Ask AI + + what can Claude Code do? + +Report incorrect code + +Copy + +Ask AI + + how do I create custom skills in Claude Code? + +Report incorrect code + +Copy + +Ask AI + + can Claude Code work with Docker? + +Claude Code reads your project files as needed. You don’t have to manually add context. + +## + +​ + +Step 5: Make your first code change + +Now let’s make Claude Code do some actual coding. Try a simple task: + +Report incorrect code + +Copy + +Ask AI + + add a hello world function to the main file + +Claude Code will: + + 1. Find the appropriate file + 2. Show you the proposed changes + 3. Ask for your approval + 4. Make the edit + +Claude Code always asks for permission before modifying files. You can approve individual changes or enable “Accept all” mode for a session. + +## + +​ + +Step 6: Use Git with Claude Code + +Claude Code makes Git operations conversational: + +Report incorrect code + +Copy + +Ask AI + + what files have I changed? + +Report incorrect code + +Copy + +Ask AI + + commit my changes with a descriptive message + +You can also prompt for more complex Git operations: + +Report incorrect code + +Copy + +Ask AI + + create a new branch called feature/quickstart + +Report incorrect code + +Copy + +Ask AI + + show me the last 5 commits + +Report incorrect code + +Copy + +Ask AI + + help me resolve merge conflicts + +## + +​ + +Step 7: Fix a bug or add a feature + +Claude is proficient at debugging and feature implementation. Describe what you want in natural language: + +Report incorrect code + +Copy + +Ask AI + + add input validation to the user registration form + +Or fix existing issues: + +Report incorrect code + +Copy + +Ask AI + + there's a bug where users can submit empty forms - fix it + +Claude Code will: + + * Locate the relevant code + * Understand the context + * Implement a solution + * Run tests if available + +## + +​ + +Step 8: Test out other common workflows + +There are a number of ways to work with Claude: **Refactor code** + +Report incorrect code + +Copy + +Ask AI + + refactor the authentication module to use async/await instead of callbacks + +**Write tests** + +Report incorrect code + +Copy + +Ask AI + + write unit tests for the calculator functions + +**Update documentation** + +Report incorrect code + +Copy + +Ask AI + + update the README with installation instructions + +**Code review** + +Report incorrect code + +Copy + +Ask AI + + review my changes and suggest improvements + +Talk to Claude like you would a helpful colleague. Describe what you want to achieve, and it will help you get there. + +## + +​ + +Essential commands + +Here are the most important commands for daily use: + +Command| What it does| Example +---|---|--- +`claude`| Start interactive mode| `claude` +`claude "task"`| Run a one-time task| `claude "fix the build error"` +`claude -p "query"`| Run one-off query, then exit| `claude -p "explain this function"` +`claude -c`| Continue most recent conversation in current directory| `claude -c` +`claude -r`| Resume a previous conversation| `claude -r` +`claude commit`| Create a Git commit| `claude commit` +`/clear`| Clear conversation history| `/clear` +`/help`| Show available commands| `/help` +`exit` or Ctrl+C| Exit Claude Code| `exit` + +See the [CLI reference](</docs/en/cli-reference>) for a complete list of commands. + +## + +​ + +Pro tips for beginners + +For more, see [best practices](</docs/en/best-practices>) and [common workflows](</docs/en/common-workflows>). + +Be specific with your requests + +Instead of: “fix the bug”Try: “fix the login bug where users see a blank screen after entering wrong credentials” + +Use step-by-step instructions + +Break complex tasks into steps: + +Report incorrect code + +Copy + +Ask AI + + 1. create a new database table for user profiles + 2. create an API endpoint to get and update user profiles + 3. build a webpage that allows users to see and edit their information + +Let Claude explore first + +Before making changes, let Claude understand your code: + +Report incorrect code + +Copy + +Ask AI + + analyze the database schema + +Report incorrect code + +Copy + +Ask AI + + build a dashboard showing products that are most frequently returned by our UK customers + +Save time with shortcuts + + * Press `?` to see all available keyboard shortcuts + * Use Tab for command completion + * Press ↑ for command history + * Type `/` to see all commands and skills + +## + +​ + +What’s next? + +Now that you’ve learned the basics, explore more advanced features: + +## How Claude Code works + +Understand the agentic loop, built-in tools, and how Claude Code interacts with your project + +## Best practices + +Get better results with effective prompting and project setup + +## Common workflows + +Step-by-step guides for common tasks + +## Extend Claude Code + +Customize with CLAUDE.md, skills, hooks, MCP, and more + +## + +​ + +Getting help + + * **In Claude Code** : Type `/help` or ask “how do I…” + * **Documentation** : You’re here! Browse other guides + * **Community** : Join our [Discord](<https://www.anthropic.com/discord>) for tips and support