anthropic-sdk-python: Instructions file for Claude Code

CLAUDE.md

anthropic-sdk-python CLAUDE.md is an instructions file for Claude Code from anthropics/anthropic-sdk-python. It costs 7,537 tokens per session, scanned A, original, Apache-2.0.

A contributor guide for the Python SDK for the Claude API. It explains the repository structure, generated and hand-written code, ownership of files, and common build, test, and lint work.

In plain words
What is it for?
Use it when changing the Python SDK, deciding where code belongs, reviewing generated files, or preparing changes for tests and linting.
Why use it?
It helps developers avoid editing files that are regenerated or owned by another part of the project, and points them to the right setup and workflow guidance.

Instructions file for Claude Code ✓ vendor

Written for Claude Code: the file is CLAUDE.md.

This is anthropics/anthropic-sdk-python's own configuration. It tells Claude Code how to work on anthropic-sdk-python itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything anthropic-sdk-python configures →

About the project

anthropics/anthropic-sdk-python is a Python library that lets applications communicate with the Claude API. It is for Python developers building software that uses Claude.

anthropics/anthropic-sdk-python · 4,047 stars · on GitHub

Reuse

Borrowing it

Nothing to install: this file belongs to anthropics/anthropic-sdk-python. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/anthropics/anthropic-sdk-python/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/anthropics/anthropic-sdk-python

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for anthropic-sdk-python CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/anthropics/anthropic-sdk-python/claude-md/github.svg)](https://agentmods.dev/instructions/anthropics/anthropic-sdk-python/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/anthropics/anthropic-sdk-python/claude-md"><img src="https://agentmods.dev/badge/instructions/anthropics/anthropic-sdk-python/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for anthropic-sdk-python CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/anthropics/anthropic-sdk-python/claude-md"><img src="https://agentmods.dev/badge/instructions/anthropics/anthropic-sdk-python/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 7,537 This file is loaded in full into every session.
When invoked 7,537 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.07537 $0.07537
Opus 5.5 $0.03015 $0.03015
Sonnet 5.5 $0.01507 $0.01507
Haiku 4.5 $0.00754 $0.00754

Measured yesterday against content hash 410752be2f4c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

anthropic-sdk-python CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 370 lines

How it starts

The opening of the file, as written. The whole thing — 370 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Working in this repository

Context for contributors (human or AI) on how this SDK is put together, plus the things reviews most often come back to. Setup instructions live in CONTRIBUTING.md.

Overview

The official Python SDK for the Claude API (anthropic on PyPI). This is the v1 line: it is built on httpx2 and needs Python 3.10 or later (requires-python in pyproject.toml).

Most of it is generated from the OpenAPI spec. Hand-written helpers, tool runners, credentials, middleware, and platform clients sit on top.

Who owns which files

  • src/anthropic/lib/, examples/, and tests/lib/ are hand-written. The generator never touches them.
  • Everything else comes from the generator, with custom code mixed in. Generated files carry no marker comment. Hand-written methods, imports, and whole blocks sit inside many of them, including core modules such as _client.py and _base_client.py. So a file's location doesn't tell you who owns a given line. The next section says how to tell.
  • .stats.yml and .github/workflows are generator-owned too. Avoid editing them, because the next codegen push rewrites them and a change tends to conflict.
  • src/anthropic/_vendor/ is vendored. Re-copy it from upstream rather than editing it.
  • Release-please writes src/anthropic/_version.py, .release-please-manifest.json, and CHANGELOG.md. It rewrites them in each release PR, so a manual edit is overwritten or conflicts with it.

Editing generated files

  • Check whether a line is generated before you change it. Every commit the generator produced carries a Stainless-Generated-From: <sha> trailer, and a hand-written commit has none. The SHA is the generator's own output for that commit, with no custom code in it.
    • Find the latest one with git log -1 --grep='Stainless-Generated-From' --format='%(trailers:key=Stainless-Generated-From,valueonly)'.
    • Fetch it with git fetch origin <sha>, then diff a file against it: git diff <sha> -- src/anthropic/resources/messages/messages.py.
    • Lines that appear only on your side are custom code. If the line you want to change is in the generated commit, the fix probably belongs in the generator (see below).
  • Where the lines go matters, not how many. Edits to generated files survive regeneration, because new generator output is merged with them, but the merge can conflict.
    • Changing lines the generator writes, such as a method's parameters or the way it builds the request, is likely to conflict the next time the spec changes.
    • Adding lines of your own, such as a new method or a block inside a method body, is usually fine, even a large one. AsyncWork.poller and AsyncWork.worker in resources/beta/environments/work.py are whole methods added after the generated ones, with their lib/ imports inside the method body.
  • No provenance comments. Don't add a comment that marks code as hand-written or mentions Stainless, and remove one from a block you are already editing.
  • Fix generator-owned behaviour upstream.
    • Broken generated plumbing (retries, SSE parsing, serialization) is a generator bug.
    • A real response the generated types can't parse is a spec bug.
    • The model name in tests/api_resources/ comes from the spec's example.

Read the full file on GitHub · 370 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday Changed · +1 tokens per session 410752be2f4c
  2. 3d ago Changed · +1 lines · +62 tokens per session 8330c7ec1c02
  3. 1mo ago Changed · +27 lines · +319 tokens per session e72fafbc304f
  4. 1mo ago First seen · 342 lines · 7,155 tokens per session scan A 14903d9e29b0

Subscribe to this mod's changes

anthropic-sdk-python CLAUDE.md is an instructions file published in the GitHub repository anthropics/anthropic-sdk-python (4,047 stars, last pushed yesterday), licensed Apache-2.0. It adds 7,537 tokens to every session, about $0.0301 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-23.

Related

anthropic-sdk-python CLAUDE.md compared with instructions from other repositories

anthropic-sdk-python CLAUDE.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
anthropic-sdk-python CLAUDE.mdanthropics/anthropic-sdk-pythonInstructions file4.0kyesterdayApache-2.0A7,537Claude Code
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode