anthropic-sdk-ruby: Instructions file for Claude Code

CLAUDE.md

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

Repository instructions for contributors to the official Ruby software library for the Claude API.

In plain words
What is it for?
They help developers build, test, review, and extend the Ruby SDK.
Why use it?
They explain how the code is organized and where to fix generated code, handwritten helpers, tests, lint, and type-related issues.

Instructions file for Claude Code ✓ vendor

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

This is anthropics/anthropic-sdk-ruby's own configuration. It tells Claude Code how to work on anthropic-sdk-ruby 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-ruby configures →

About the project

anthropics/anthropic-sdk-ruby is a Ruby library that lets Ruby applications communicate with the Claude API. Ruby developers use it to add Claude API access to their applications. The catalogue entries provide its instruction and skill resources.

anthropics/anthropic-sdk-ruby · 377 stars · on GitHub

Reuse

Borrowing it

Nothing to install: this file belongs to anthropics/anthropic-sdk-ruby. 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-ruby/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/anthropics/anthropic-sdk-ruby

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-ruby CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/anthropics/anthropic-sdk-ruby/claude-md/github.svg)](https://agentmods.dev/instructions/anthropics/anthropic-sdk-ruby/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/anthropics/anthropic-sdk-ruby/claude-md"><img src="https://agentmods.dev/badge/instructions/anthropics/anthropic-sdk-ruby/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-ruby CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/anthropics/anthropic-sdk-ruby/claude-md"><img src="https://agentmods.dev/badge/instructions/anthropics/anthropic-sdk-ruby/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 5,239 This file is loaded in full into every session.
When invoked 5,239 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.05239 $0.05239
Opus 5.5 $0.02096 $0.02096
Sonnet 5.5 $0.01048 $0.01048
Haiku 4.5 $0.00524 $0.00524

Measured yesterday against content hash ccbc857f2320, 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-ruby 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 · 85 lines

How it starts

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

Working in this repository

Context for contributors 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 Ruby SDK for the Claude API (the anthropic gem). Much of it is produced via code generation from the OpenAPI spec, with hand-written helpers (lib/anthropic/helpers/**: streaming, tools, input schemas, platform clients), credentials, middleware and examples layered on top.
  • Generated files are safe to edit. New generator output is git-merged with custom changes rather than overwriting them, so fix things where they live; a collision is just a merge conflict.
  • Fix things upstream first wherever you can, before reaching for custom code: a missing parameter, an out-of-date doc string, or a response the models can't represent (a missing required field, an unknown enum member, a nullability mismatch) belongs in the OpenAPI spec, and broken generated infrastructure (lib/anthropic/internal/**: transport, retries, SSE and multipart handling, coercion) belongs in the generator — fixing it there is preferred over a local patch.
  • PRs target the default branch (main on the public repo). next belongs to release automation — don't open PRs against it or push to it; a commit that lands there outside the release flow breaks the sync. Rebase onto the current default branch before asking for review — a stale base shows up as unrelated "changed" files.
  • lib/anthropic/version.rb, .release-please-manifest.json, the gem's own entry in Gemfile.lock, the README.md version block and CHANGELOG.md are written by release automation.

Build, test, lint

  • ./scripts/bootstrap installs the bundle; ./scripts/test starts the mock API server (./scripts/mock, needs Node) and runs the suite; run ./scripts/lint before pushing (it is exactly what CI runs) and format only the files you touched, e.g. bundle exec rubocop -a <files> — a whole-tree ./scripts/format also reflows long lines and restyles rbi//sig/ files you never opened, since CI doesn't check formatting. A single file runs with bundle exec rake test TEST=test/anthropic/…_test.rb.
  • Lint is rubocop plus steep check (RBS) plus Sorbet, and the Sorbet step is srb typecheck --dir examples — the examples are type-checked in CI on top of rbi/. A bare bundle exec srb tc never looks at examples/, which is how "green locally, red in CI" has happened; use the --dir examples form after touching examples or any signature they use. Rubocop runs with Layout/LineLength excluded, so line length is never what fails CI; trailing whitespace (easy to pick up while resolving a sync conflict) and missing parentheses are.
  • Only the generated ResourceTest suites under test/anthropic/resources/** need the mock server (port 4010, or TEST_API_BASE_URL); APIConnectionErrors there mean the mock isn't running. Everything else runs offline against WebMock — helper, credentials, middleware and client tests, plus the hand-written resources/messages/streaming_test.rb and resources/beta/messages/streaming_test.rb that sit inside that directory. Live tests against real cloud providers only run with ANTHROPIC_LIVE=1, and the Bedrock/AWS unit tests read ambient AWS state (AWS_* variables and ~/.aws profiles), so if they fail locally on region, profile or credential lookup, run them with AWS_* unset and AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null.
  • CI's ./scripts/detect-breaking-changes restores the release base's generated tests and client_test.rb and re-runs ./scripts/lint over them, but nothing in lint type-checks test/, so it will not notice a removed or renamed method or keyword — treat public-surface removals as a review item: deprecate first (a forwarding alias plus warn(…, category: :deprecated)) and remove later, in step with the other SDKs.
  • The gem supports Ruby 3.2+, and users also run it on Ruby 4 (Prism) and JRuby, which CI doesn't cover; both have broken on load-time edge cases before (bytecode precompilation of unusual syntax, constant resolution during require), so keep load-time code boring and take reports from those runtimes seriously.
  • Examples are executable scripts (#!/usr/bin/env ruby, # frozen_string_literal: true, a # typed: sigil, require_relative "../lib/anthropic"), linted and type-checked with everything else. Match the sigil of neighbouring examples of the same kind: client and streaming examples are typed: strong, while the BaseModel/BaseTool DSL examples (tools, tool runner, structured output, input schemas) can't type-check today and stay typed: false or unsigilled, where Sorbet checks little beyond syntax and constant names. New user-facing helpers usually come with an example and a helpers.md section, using a current public model id like the neighbouring examples; user documentation beyond helpers.md lives outside this repo (see CONTRIBUTING.md), so say in the PR what needs documenting.

Read the full file on GitHub · 85 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 · +8 tokens per session ccbc857f2320
  2. 3d ago Changed · +1 lines · +68 tokens per session 38430338a808
  3. 15d ago Changed · -2 tokens per session 9c23a73c0e50
  4. 1mo ago Changed · -30 tokens per session 8007185a364a
  5. 2mo ago First seen · 84 lines · 5,195 tokens per session scan A 96dda01b042e

Subscribe to this mod's changes

anthropic-sdk-ruby CLAUDE.md is an instructions file published in the GitHub repository anthropics/anthropic-sdk-ruby (377 stars, last pushed yesterday), licensed Apache-2.0. It adds 5,239 tokens to every session, about $0.0210 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-03.

Related

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

anthropic-sdk-ruby CLAUDE.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
anthropic-sdk-ruby CLAUDE.mdanthropics/anthropic-sdk-rubyInstructions file377yesterdayApache-2.0A5,239Claude Code
graftcode graftcode-ruby.instructions.mdgrft-dev/graftcodeInstructions file9671mo agononeA4,609GitHub Copilot
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