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.
Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add instructions/anthropics/anthropic-sdk-ruby/claude-mdgit clone --depth 1 https://github.com/anthropics/anthropic-sdk-rubyWrote 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.
[](https://agentmods.dev/instructions/anthropics/anthropic-sdk-ruby/claude-md)<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="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.05195 | $0.05195 |
| Opus 5 | $0.02597 | $0.02597 |
| Sonnet 5 | $0.01039 | $0.01039 |
| Haiku 4.5 | $0.00519 | $0.00519 |
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.
How it starts
The opening of the file, as written. The whole thing — 84 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
anthropicgem). 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. (
git diff origin/generated origin/nextshows everything custom if you ever need to know which is which.) - 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
next.mainonly moves when a release is cut.nextmoves quickly and its history is occasionally rewritten, so rebase onto the currentorigin/nextbefore asking for review — a stale base shows up as unrelated "changed" files (git rebase --onto origin/next <old-base>sorts out a base that was rewritten underneath you). lib/anthropic/version.rb,.release-please-manifest.json, the gem's own entry inGemfile.lock, theREADME.mdversion block andCHANGELOG.mdare written by release automation.
Build, test, lint
./scripts/bootstrapinstalls the bundle;./scripts/teststarts the mock API server (./scripts/mock, needs Node) and runs the suite; run./scripts/lintbefore 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/formatalso reflows long lines and restylesrbi//sig/files you never opened, since CI doesn't check formatting. A single file runs withbundle exec rake test TEST=test/anthropic/…_test.rb.- Lint is rubocop plus
steep check(RBS) plus Sorbet, and the Sorbet step issrb typecheck --dir examples— the examples are type-checked in CI on top ofrbi/. A barebundle exec srb tcnever looks atexamples/, which is how "green locally, red in CI" has happened; use the--dir examplesform after touching examples or any signature they use. Rubocop runs withLayout/LineLengthexcluded, 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
ResourceTestsuites undertest/anthropic/resources/**need the mock server (port 4010, orTEST_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-writtenresources/messages/streaming_test.rbandresources/beta/messages/streaming_test.rbthat sit inside that directory. Live tests against real cloud providers only run withANTHROPIC_LIVE=1, and the Bedrock/AWS unit tests read ambient AWS state (AWS_*variables and~/.awsprofiles), so if they fail locally on region, profile or credential lookup, run them withAWS_*unset andAWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null. - CI's
./scripts/detect-breaking-changesrestores the release base's generated tests andclient_test.rband re-runs./scripts/lintover them, but nothing in lint type-checkstest/, 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 pluswarn(…, 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 aretyped: strong, while theBaseModel/BaseToolDSL examples (tools, tool runner, structured output, input schemas) can't type-check today and staytyped: falseor unsigilled, where Sorbet checks little beyond syntax and constant names. New user-facing helpers usually come with an example and ahelpers.mdsection, using a current public model id like the neighbouring examples; user documentation beyondhelpers.mdlives outside this repo (see CONTRIBUTING.md), so say in the PR what needs documenting.
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.
- yesterday First seen · 84 lines · 5,195 tokens per session scan A 96dda01b042e
anthropic-sdk-ruby CLAUDE.md is an instructions file published in the GitHub repository anthropics/anthropic-sdk-ruby (366 stars, last pushed today), licensed MIT. It adds 5,195 tokens to every session, about $0.0260 per session on Opus 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.
Other instructions, from other repositories
comma copilot-instructions.md
Copilot instructions for comma-csv/comma, covering copilot instructions for comma, build, test, and lint commands, install dependencies for the base gemfile, install all appraisal gemfiles used by ci and build the gem.
nosia AGENTS.md
AGENTS.md instructions for dilolabs/nosia, covering 37signals rails configuration, tech stack, architecture, core philosophy and key commands.
metasploit-framework tests.instructions.md
Instructions for rapid7/metasploit-framework, covering rspec test instructions, conventions, running tests, test data and module specs.
rails_api_base CLAUDE.md
Instructions for rootstrap/rails_api_base, covering claude.md, what this repo is, common commands, testing notes and architecture.
ruby2d AGENTS.md
Instructions for ruby2d/ruby2d, covering ruby 2d guide for ai coding agents, testing, architecture, multi-ruby support and documentation.
concerns_on_rails CLAUDE.md
Claude Code instructions for VSN2015/concerns_on_rails, covering claude.md, commands, run a single spec file, run a single example by line number and build the gem.