/ruby-rails:generating-sorbetfrom ruby-rails
This skill should be used when the user asks to "generate RBI files", "add Sorbet types without touching the source", "write .rbi shims", "type a gem for Sorbet", or "add signatures for generated code". Writes standalone .rbi files and never edits the Ruby source — the right choice for gems, generated code, and legacy files. In a Rails app it sends ActiveRecord and other DSL methods to `tapioca dsl` and writes only the remaining shims, under sorbet/rbi/shims/. For `sig { }` blocks written in the source itself, use generating-sorbet-inline; for RBS rather than Sorbet, use generating-rbs or generating-rbs-inline.
Ships in ruby-rails. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Assume mise-managed Ruby and Rails with bin/* binstubs — not rbenv, rvm, or
asdf. Read ${CLAUDE_PLUGIN_ROOT}/references/conventions.md for versions,
command forms, and type-system pairing before running project commands.
Generate or update Sorbet type signatures in separate .rbi files. Supports both full generation from scratch and partial updates for individual changed files. RBI files are used when you cannot or should not modify the original Ruby source - such as for gems, generated code, or legacy codebases.
When generating Sorbet RBI signatures, always follow these steps.
Copy this checklist and track your progress:
Sorbet RBI Generation Progress:
- [ ] Step 0: Detect the project layout
- [ ] Step 1: Analyze the Ruby source
- [ ] Step 2: Generate RBI files
- [ ] Step 3: Eliminate `T.untyped` in signatures
- [ ] Step 4: Review and refine signatures
- [ ] Step 5: Validate signatures with Sorbet
srb tc and the
Tapioca generators in Step 0. Ask the user before running tapioca dsl,
because it boots the app and needs its database.sorbet/rbi/gems/, sorbet/rbi/dsl/, or
sorbet/rbi/annotations/. Tapioca rewrites them; regenerate instead.T.untyped in a hand-written signature unless the type
cannot be determined (see Step 3). Generated RBIs may contain it; leave them.T.unsafe - it bypasses type checking entirely.T.cast - it forces types without verification.mise exec -- bundle exec <command> when the project has a Gemfile (see conventions).sig { } block syntax for method signatures.extend T::Sig to classes/modules before using sig.sorbet/rbi/shims/
in an application, rbi/ at the root of a gem.When processing multiple Ruby files, create a tracking file to ensure all files are covered:
.sorbet-rbi-generation-todo.tmp: [ ] lib/legacy/billing.rb
[ ] lib/legacy/invoice.rb
[ ] app/services/auth_service.rb
Process files one by one:
[ ] entry[x]Cleanup: Remove the tracking file after all files are processed:
rm .sorbet-rbi-generation-todo.tmp
If interrupted, the tracking file allows resuming from where you left off.
Always perform this step. Where an RBI belongs depends on whether the project is an application using Tapioca or a gem shipping its own RBIs.
| Signal | Layout |
|---|---|
sorbet/ directory, or tapioca in Gemfile.lock | Application with Tapioca |
A *.gemspec at the root and no sorbet/ directory | Gem |
| Neither | Ask the user; offer tapioca init for an application |
Application with Tapioca. Sorbet's RBIs live under sorbet/rbi/, split by
who writes them:
| Directory | Written by | Regenerate with |
|---|---|---|
sorbet/rbi/gems/ | Tapioca, from installed gems | tapioca gem |
sorbet/rbi/dsl/ | Tapioca, from Rails and other DSLs | tapioca dsl |
sorbet/rbi/annotations/ | Tapioca, from the community repository | tapioca annotations |
sorbet/rbi/shims/ | You | — |
Run Tapioca on the project toolchain, preferring the binstub when it exists:
mise exec -- bin/tapioca dsl # all DSL RBIs
mise exec -- bin/tapioca dsl User Post # only these constants
mise exec -- bundle exec tapioca gem # without a binstub
Methods generated by ActiveRecord (columns, associations, scopes, enums),
ActiveSupport concerns, URL helpers, and other compilers Tapioca ships belong
to tapioca dsl. When the user asks to type them, run it (after asking, per
the Rules) instead of writing them by hand. Write a shim in sorbet/rbi/shims/
only for what Tapioca does not cover: a gem method its RBI gets wrong, or
metaprogramming in the app no compiler understands. tapioca check-shims
reports shims that duplicate generated RBIs.
Gem. Put hand-written RBIs in rbi/ at the gem root. Tapioca reads that
directory from installed gems, so apps that depend on the gem get the
signatures without generating them.
Always perform this step.
Read and understand the Ruby source file:
public, private, protected.Always perform this step.
Determine the correct RBI directory from Step 0: sorbet/rbi/shims/ in an
application, rbi/ in a gem. Mirror the source path, so
lib/legacy/billing.rb becomes sorbet/rbi/shims/legacy/billing.rbi.
RBI files are needed to describe code Sorbet cannot understand statically:
tapioca gem)define_method or method_missingconst_get/const_setextendtapioca dsl)Create the RBI file with typed sigil:
# typed: strict
Add extend T::Sig to each class/module:
class MyClass
extend T::Sig
end
Add method stubs with signatures (no method bodies):
Example - Ruby Source:
class User
attr_reader :name, :age
def initialize(name, age)
@name = name
@age = age
end
def greet(greeting)
"#{greeting}, #{@name}!"
end
end
Example - RBI File (sorbet/rbi/shims/user.rbi, or rbi/user.rbi in a gem):
# typed: strict
class User
extend T::Sig
sig { returns(String) }
attr_reader :name
sig { returns(Integer) }
attr_reader :age
sig { params(name: String, age: Integer).void }
def initialize(name, age); end
sig { params(greeting: String).returns(String) }
def greet(greeting); end
end
T.untyped in SignaturesAlways perform this step.
T.untyped with proper types.T.untyped only as a last resort when the type cannot be determined,
and tell the user which signatures still have it.Always perform this step.
T.untyped types.Always perform this step.
Run Sorbet type checker to validate signatures:
mise exec -- bundle exec srb tc
This checks:
Fix any errors reported and repeat until validation passes.
gem, dsl, and shim workflowssig { } blocks in the sourcesig/**/*.rbs files instead of Sorbetsorbet/tapioca and running them on the project Rubyreferences/stripe-ruby/LICENSE (opens in a new tab)references/stripe-ruby/STRUCTURE.md (opens in a new tab)references/stripe-ruby/rbi/stripe/params/billing/meter_create_params.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/params/checkout/session_list_params.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/params/customer_create_params.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/params/customer_list_params.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/params/mandate_retrieve_params.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/resources/application.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/resources/billing/meter.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/resources/customer.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/resources/v2/billing/meter_event.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/services/billing/meter_service.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/services/checkout/session_service.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/services/customer_service.rbi (opens in a new tab)references/stripe-ruby/rbi/stripe/services/mandate_service.rbi (opens in a new tab)references/syntax.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub meaganewaller/marketplace --plugin ruby-rails28 skills in this plugin
/generating-rbsThis skill should be used when the user asks to "add RBS signatures", "generate RBS for this file", "write .rbs files", "set up Steep", "type-check this Ruby with RBS", or "update sig/ after these changes". Writes standalone RBS signatures under sig/**/*.rbs and never edits the Ruby source. For RBS written as inline `# @rbs` comments in the source instead, use generating-rbs-inline; for Sorbet rather than RBS, use generating-sorbet or generating-sorbet-inline./generating-rbs-inlineThis skill should be used when the user asks to "add rbs-inline annotations", "annotate this file with @rbs comments", "use rbs-inline", "add inline RBS types", or "generate RBS from comments in the source". Writes RBS types as `# @rbs` comments directly inside .rb files. For standalone sig/**/*.rbs signature files instead, use generating-rbs; for Sorbet rather than RBS, use generating-sorbet or generating-sorbet-inline./generating-sorbet-inlineThis skill should be used when the user asks to "add sig blocks", "add Sorbet signatures to this class", "make this file typed: strict", "add T.let annotations", or "type this Ruby with Sorbet inline". Writes `sig { }` blocks and `# typed:` sigils directly into .rb source. For standalone .rbi shim files that leave the source untouched, use generating-sorbet; for RBS rather than Sorbet, use generating-rbs or generating-rbs-inline./rails-action-cableThis skill should be used when the user asks to "add real-time updates", "set up Action Cable", "create a channel", "broadcast changes to the browser", "push updates without polling", or mentions WebSockets, Solid Cable, or broadcasting from a model. Covers channels, subscriptions, connection authentication, and Turbo Stream broadcasts./rails-activerecordThis skill should be used when the user asks to "add an association", "add a validation", "write a scope", "set up has_many :through", "add a counter cache", or "use an enum", or is working with models, callbacks, or query chains. For schema changes and migration files, use rails-database-migrations; for diagnosing slow or N+1 queries, use rails-performance./rails-active-storageThis skill should be used when the user asks to "add file uploads", "attach an image to a model", "set up direct uploads to S3", "generate image thumbnails", "add a rich text editor", or mentions Active Storage, Action Text, Action Mailbox, variants, vips, or mini_magick.Other plugins' skills for the same job