anthropic-sdk-ruby CLAUDE.md

anthropic-sdk-ruby CLAUDE.md is an instructions file for coding agents from anthropics/anthropic-sdk-ruby. It costs 5,195 tokens per session, scanned A, original, MIT.

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

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 · 366 stars · on GitHub

Install

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.

agentmods
npx agentmods add instructions/anthropics/anthropic-sdk-ruby/claude-md
Clone the repo
git clone --depth 1 https://github.com/anthropics/anthropic-sdk-ruby

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.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.svg" alt="Measured on agentmods" height="20"></a>
Per session 5,195 This file is loaded in full into every session.
When invoked 5,195 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
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 $0.05195 $0.05195
Opus 5 $0.02597 $0.02597
Sonnet 5 $0.01039 $0.01039
Haiku 4.5 $0.00519 $0.00519

Measured yesterday against content hash 96dda01b042e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 · 84 lines

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 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. (git diff origin/generated origin/next shows 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. main only moves when a release is cut. next moves quickly and its history is occasionally rewritten, so rebase onto the current origin/next before 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 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 · 84 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 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 (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.