9 min to read
Anthropic's Claude Code — the agentic CLI that lives in your terminal, reads your codebase, and drives git workflows through natural language — is now open source. The agent layer is on GitHub at anthropics/claude-code, which means you can read the full TypeScript source, fork it, audit it, and build from it. But before you spin up a self-hosted instance expecting zero API bills, there is one thing to get straight: the source code is open, but the model is not. This guide walks through everything you need to know about Claude Code open source — what it actually contains, how to install it, how to configure it, and how to extend it with BYOK and alternative auth backends.
Claude Code is an agentic coding assistant — a CLI that takes natural-language instructions and executes real actions: editing files, running tests, managing git, scaffolding projects. The open-source release means Anthropic has made the TypeScript agent layer publicly available on GitHub. You can inspect the tool routing logic, the context management pipeline, the permission system, and all the plumbing that ties user commands to model calls.
What you do not get in the repo: model weights. Claude Code is not a self-contained LLM. The repo is the agent shell; every inference request still goes to Anthropic's API (or an alternative backend you configure — more on that in the BYOK section below).
The source code became publicly available on March 31, 2026. The exact circumstances are disputed across sources — some attribute this to an accidental .map file inclusion in the published npm package that exposed unobfuscated TypeScript source, while others describe it as an intentional Anthropic decision. Either way, the code is now at github.com/anthropics/claude-code and Anthropic has continued shipping updates through the public repo. Verify the current license terms in the repo's LICENSE file before forking for commercial use.
Short answer: no, not in the traditional "self-hosted" sense. Claude Code requires a live model backend, and by default that backend is Anthropic's API. To use it you need one of:
However, you can route it through alternative providers — Amazon Bedrock, Google Vertex AI, or a LiteLLM proxy pointing at any OpenAI-compatible model — which may reduce cost or remove the direct Anthropic subscription requirement depending on your setup. That path is covered in the BYOK section.
Anthropic also runs a Claude for Open Source program that gives qualifying OSS maintainers and contributors six months of Claude Max at no cost. If you maintain an active open-source project, that is worth checking before paying out of pocket.
The practical takeaway: if you just want to use Claude Code, install the native binary and authenticate with your Anthropic account. If you want to audit, fork, or extend the agent layer, the open-source repo gives you the full picture.
There are three paths to a running Claude Code installation: the native installer (recommended), the legacy npm package, and building directly from the GitHub source.
The native installer bundles a self-contained runtime, handles background auto-updates, and requires no pre-installed Node.js.
macOS and Linux:
curl -fsSL https://claude.ai/install.sh | shWindows (PowerShell, run as Administrator):
irm https://claude.ai/install.ps1 | iexAfter the script completes, the claude command is available system-wide. Verify with claude --version.
The npm package still works but is deprecated — Anthropic has moved to the native installer as the forward path. Use this only if you have a specific reason to manage Claude Code through your Node package manager:
npm install -g @anthropic-ai/claude-codeYou will see a deprecation notice. It can safely be ignored for now, but plan to migrate to the native installer before the package is eventually removed.
This path is for developers who want to inspect, modify, or contribute to the agent layer itself. Check the repo's package.json for the canonical build scripts — commands may evolve across releases.
git clone https://github.com/anthropics/claude-code.git
cd claude-code
npm install
npm run build
node dist/cli.jsIf the repo has migrated to a Bun build pipeline (check package.json scripts):
bun install
bun run build
bun dist/cli.jsFor development iteration, most TypeScript repos support npm run dev or bun --watch for live-reload without a full rebuild on each change.
The first time you run claude, it opens your default browser and prompts you to sign in to your Anthropic account:
claudeComplete the OAuth flow in the browser. Claude Code stores the resulting token locally and reuses it on subsequent launches. For non-interactive environments — CI/CD, Docker containers, remote servers — use an API key instead:
export ANTHROPIC_API_KEY=sk-ant-api03-...
claudeFor CI/CD pipelines, store the key as a repository secret and inject it into the environment at runtime. Never hardcode it in workflow files or committed configuration.
Two files drive Claude Code's behavior at the project level: CLAUDE.md (project context injected into the model's system prompt) and .claude/settings.json (tool permissions controlling what the agent can do autonomously).
Drop a CLAUDE.md file in your project root. Claude reads it at the start of every session. Use it to declare the project's purpose, conventions, safe commands, and off-limits areas. A global ~/.claude/CLAUDE.md applies across all projects — useful for personal preferences and tool defaults.
# Project: API Gateway Service
## Stack
- Node.js 22 + TypeScript
- PostgreSQL via Prisma
- Deployed on AWS Lambda
## Coding conventions
- snake_case for database columns, camelCase for TypeScript
- Async functions must use explicit error handling — no empty catch blocks
- Tests live in __tests__/ adjacent to source files
## Commands Claude may run without asking
- npm test
- npm run lint
- prisma migrate status
## Do not modify
- infrastructure/ (Terraform-managed, changes break prod)
- .env files (secrets managed separately)The more specific your CLAUDE.md, the less time Claude spends on wrong-framework suggestions or convention mismatches. Treat it as onboarding documentation for an engineer who never attended a sprint planning session.
The .claude/settings.json file controls which tools Claude can invoke autonomously versus which require human approval. The exact schema evolves with Claude Code releases — verify field names against the official docs or the TypeScript types in the source repo. A typical permission structure looks like:
{
"permissions": {
"allow": [
"Read(*)",
"Write(src/**)",
"Bash(npm test)",
"Bash(npm run lint)"
],
"deny": [
"Bash(git push*)",
"Bash(rm -rf*)"
]
}
}In shared team environments, commit a conservative settings.json that requires approval for all shell commands and restricts writes to src/. Individual developers can maintain personal overrides in ~/.claude/settings.json for higher autonomy on their own machines.
Once authenticated and configured, the most useful Claude Code interaction patterns for daily development:
claude and type requests in natural language. Claude maintains context across turns within the session.claude "add error handling to src/api/users.ts" — executes and exits.claude --file src/api/users.ts "refactor this to use the repository pattern"claude "write a commit message for the staged changes" or claude "create a PR for this feature branch"Claude Code is also available as a VS Code extension, a JetBrains plugin, a desktop app, and a web interface — the same commands and CLAUDE.md context apply across all surfaces. For IDE-specific workflow patterns, see the guide on using Claude with Cursor and Windsurf.
Claude Code's default auth points at Anthropic's API, but you can redirect it to any OpenAI-compatible backend. This is useful if you already have Bedrock or Vertex AI credits through an enterprise agreement, want to route through a LiteLLM proxy for centralized logging, or want to experiment with non-Anthropic models through the same CLI interface.
For developers interested in running Claude Code against a locally-hosted model, the walkthrough on pairing Qwen3.5 with Claude Code covers the local inference BYOK path in detail.
LiteLLM acts as an OpenAI-compatible proxy in front of any model provider. Install it, configure your providers in a YAML file, and point Claude Code at your local proxy.
# Install LiteLLM
pip install "litellm[proxy]"
# litellm_config.yaml
model_list:
- model_name: claude-sonnet-4-6
litellm_params:
model: anthropic/claude-sonnet-4-6
api_key: sk-ant-...
- model_name: gpt-4o
litellm_params:
model: openai/gpt-4o
api_key: sk-...
# Start the proxy
litellm --config litellm_config.yaml --port 4000Then configure Claude Code to use the proxy:
export ANTHROPIC_BASE_URL=http://localhost:4000
export ANTHROPIC_API_KEY=anything
claudeClaude Code supports Bedrock and Vertex AI natively via environment variables. Verify the exact variable names against the current repo source, as they may be updated across releases.
Amazon Bedrock:
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1
export AWS_ACCESS_KEY_ID=AKIA...
export AWS_SECRET_ACCESS_KEY=...
claudeGoogle Vertex AI:
export CLAUDE_CODE_USE_VERTEX=1
export ANTHROPIC_VERTEX_PROJECT_ID=my-gcp-project
export CLOUD_ML_REGION=us-east5
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
claudeWhen routing through Bedrock or Vertex, billing flows through your AWS or GCP account rather than Anthropic directly — useful if you have pre-committed cloud spend or need cost allocation at the team level.
claude /logout then claude /login, or re-export ANTHROPIC_API_KEY.curl -fsSL https://claude.ai/install.sh | sh.~/.local/bin (Linux) or /usr/local/bin (macOS) to your shell config, then reload: source ~/.zshrc or source ~/.bashrc./compact to summarize history, or /clear to start fresh.settings.json allow list. Add it explicitly or approve interactively when Claude Code prompts.node --version). Older Node versions may fail to compile the TypeScript source.lsof -i :4000) and that ANTHROPIC_BASE_URL matches the proxy port exactly.Claude Code's capabilities extend well beyond single-session coding tasks once you wire in external tools and automation.
MCP Servers: The Model Context Protocol lets Claude Code call external tools through a standardized interface — databases, APIs, web search, file systems, and more. Attach an MCP server to give Claude persistent memory across sessions or direct access to your production database with appropriate guards. For a curated starting list, see the best free open-source MCP servers. For architectural patterns around building agentic systems with MCP, MCP servers for agentic development platforms is a comprehensive reference.
GitHub Actions Integration: Run /install-github-app inside Claude Code to walk through the GitHub app setup and required secrets. Once active, mention @claude in any PR comment or issue to trigger a Claude Code run that can read context, suggest or implement fixes, and push commits directly to the branch.
Sub-Agents and Multi-Project Setups: Run multiple Claude Code instances with different CLAUDE.md contexts in parallel — useful for monorepos where different packages have different conventions and build systems. Point each instance at a subdirectory with its own CLAUDE.md and settings.json.
Claude for Open Source Program: If you maintain an active open-source project, apply at claude.com/contact-sales/claude-for-oss. Approved maintainers get Claude Max free for six months. Applications are reviewed on a rolling basis until June 30, 2026.
The open-source release of Claude Code is significant not because it makes the tool free to run — it doesn't — but because it makes the agent layer auditable, forkable, and extensible. You can now inspect every tool call, build on the TypeScript source, route inference to any backend you trust via BYOK or cloud provider integration, and contribute improvements back upstream.
For most developers, the native installer plus an Anthropic subscription remains the fastest path to a working setup. For teams with enterprise cloud commitments, Bedrock and Vertex AI integrations keep billing inside your existing AWS or GCP account. And for security-conscious organizations, the open-source code gives your team the visibility needed to approve Claude Code for sensitive production workflows.
Start with the native installer, drop a CLAUDE.md in your project root describing your stack and conventions, and run claude. Once you have a feel for the defaults, explore the LiteLLM BYOK path and MCP server extensions — that is where Claude Code's real leverage as an open, programmable agent starts to show.
Connect with top remote developers instantly. No commitment, no risk.
Tags
Discover our most popular articles and guides
Running Android emulators on low-end PCs—especially those without Virtualization Technology (VT) or a dedicated graphics card—can be a challenge. Many popular emulators rely on hardware acceleration and virtualization to deliver smooth performance.
The demand for Android emulation has soared as users and developers seek flexible ways to run Android apps and games without a physical device. Online Android emulators, accessible directly through a web browser.
Discover the best free iPhone emulators that work online without downloads. Test iOS apps and games directly in your browser.
Top Android emulators optimized for gaming performance. Run mobile games smoothly on PC with these powerful emulators.
The rapid evolution of large language models (LLMs) has brought forth a new generation of open-source AI models that are more powerful, efficient, and versatile than ever.
ApkOnline is a cloud-based Android emulator that allows users to run Android apps and APK files directly from their web browsers, eliminating the need for physical devices or complex software installations.
Choosing the right Android emulator can transform your experience—whether you're a gamer, developer, or just want to run your favorite mobile apps on a bigger screen.
The rapid evolution of large language models (LLMs) has brought forth a new generation of open-source AI models that are more powerful, efficient, and versatile than ever.