write-rbs

Enforces dd-trace-rb conventions when writing and reviewing RBS type signatures and Steep checks.

417|417|Updated Aug 24, 2016
One-click install
npx skills add https://github.com/DataDog/dd-trace-rb --skill write-rbs-datadog
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: write-rbs
Source: https://github.com/DataDog/dd-trace-rb/tree/main/.claude/skills/write-rbs
Command: npx skills add https://github.com/DataDog/dd-trace-rb --skill write-rbs-datadog

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing RBS type signatures for Ruby code involves many subtle conventions—namespace handling, nilable syntax, generics, interfaces, and Steep checker behavior—that are easy to get wrong and produce signatures that either fail checks or paper over real type contracts. ## Core Features & Use Cases - Convention Enforcement: Applies dd-trace-rb rules for RBS files, such as writing Hash instead of ::Hash, using Type? for nilables, and never loosening signatures just to satisfy Steep. - Advanced Typing Techniques: Provides on-demand references for interfaces, type aliases, generics, procs, class definitions, Steep annotations, and inline RBS with worked good/bad examples. - Vendored Stub Guidance: Requires reading a gem's real source before writing vendor/rbs stubs, preventing incorrect inference from calling code. - Use Case: When adding type signatures to a new Ruby class in dd-trace-rb, the Skill checks for an existing .rbs file, generates a prototype via bundle exec rake "rbs:prototype[...]", cleans it against the conventions, and verifies it with scoped and full steep check runs. ## Quick Start Write RBS type signatures for lib/datadog/core/configuration.rb following the project conventions and then run a Steep check to verify them.

Frequently Asked Questions about write-rbs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write RBS type signatures for a Ruby class?▼

RBS signatures live in sig/ mirroring lib/, one .rbs file per .rb file. Check for an existing signature first, generate a prototype with bundle exec rake "rbs:prototype[lib/<path>.rb]", then clean up over-emitted untyped and leading :: namespaces against the project conventions.

How do I run Steep type checks on RBS signatures?▼

Run bundle exec steep check lib/datadog/<path>.rb to scope the check to the edited file's Ruby source, since a sig/ path silently passes even on broken signatures. Always run the full bundle exec steep check before considering types done, as scoped checks miss breaks in referencing signatures.

When should I use an interface versus a concrete type in RBS?▼

Use an interface when a parameter or return is duck-typed and you depend on methods rather than a concrete class. Name it with a leading underscore, list only the domain methods you actually call, and never pad it with predicates like nil? just to satisfy the checker.

Can I write vendor/rbs stubs based on how my code uses a gem?▼

No, never write a vendored signature from how calling code uses the gem, since inference from usage can be wrong. Always read the gem's real source first, and use untyped rather than any for genuinely open values in vendored stubs.

What is the difference between untyped and any in RBS signatures?▼

Use any only when every possible type is intentionally valid and the code does not depend on the concrete type. Use untyped when the type is merely not-yet-modeled, and never use untyped when the type is inferable from the code.

Why does my Steep check pass but signatures are still broken?▼

Scoping steep check to a sig/ path silently passes even on broken signatures, and checking one Ruby file will not catch breaks in other signatures that reference it. Always run the full bundle exec steep check before treating types as done.