/sorah-guides:sorbet-adoptionfrom sorah-guides
Provides a proven playbook for introducing Sorbet static type checking to an existing Ruby or Rails application, covering survey, infra PR, sigil stamping, and dependency-ordered stacked PRs.
Ships in sorah-guides. 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; scripts run unread.
This is a playbook for bringing an untyped Ruby or Rails application to Sorbet # typed: strict through a series of reviewable PRs. It is distilled from a rollout that took a Rails app and its client gem from no annotations to about 300 strict files in 22 stacked PRs.
Libraries and gems use Steep instead, through sorah-guides:steep-adoption: RBS is what gems ship in sig/ and what consumers load, while Sorbet suits an application that nobody depends on. A gem that lives inside an application's repository and is consumed only by that app may follow the app onto Sorbet.
Load sorah-guides:sorbet before writing any annotation. That skill defines how types are written. This one decides order, scope and mechanics. For branch and stack mechanics use /gh-stack; for commits and PR bodies use /sorah-guides:commit and /sorah-guides:pull-request.
The rollout runs in this order:
typed: true is not the goal.
true and was green. Yet the code carried 6 method signatures across about 1750 methods, because true demands none and the exit condition was "bump and srb tc green".strict, which surfaced over 3000 errors (about two thirds of them missing signatures).strict from the start.#: as !nil casts, and a later pass replaced them with restructures, raising readers and Must.sorbet skill's way from the first commit.logger method or the same timestamp cast produced add/add conflicts and duplicated work. One shim at the bottom of the stack removed every copy.initialize that silently received a Hash, and controllers reading current_user under a gate that a machine credential passes. They also produced workarounds that turned out to be unnecessary.Survey the repository before proposing anything; the defaults below bend to what you find. Count on the current default branch: git fetch, then use git ls-files against origin/<default>, because a local checkout may be weeks behind.
| Check | Why it matters |
|---|---|
| Size: files and methods in scope, and how fast main moves (merges and authors per month) | Sets slice count and size, and whether one deep stack can stay rebased |
Gemfile.lock for sorbet-runtime, pulled in by a gem | If it already loads in production, a stray sig or T.let becomes a live runtime check instead of a load error. Add a CI grep that bans those forms |
Gemfile.lock platforms, plus any local uncommitted lockfile change | sorbet-static cannot resolve with a ruby platform |
| Dockerfile and build context | A committed third_party/ copied before bundle install invalidates that layer on every RBI change. Add a .dockerignore entry or pick another RBI location |
| Engines, vendored gems and submodules inside the repo | Tapioca skips gems that live in the app tree, so those are read from source. Vendored code owned elsewhere is never edited here, and needs its upstream shims copied along. A submodule needed to boot must be initialized in every agent worktree |
ORMs and DSLs without a tapioca compiler (Dynamoid, ActiveHash, custom macros), and time_zone_aware_attributes | Plan custom DSL compilers or shims. With time-zone awareness off, datetime columns are typed Time, which clashes with Time.current |
Count of non-optional belongs_to | A few dozen are fine with Must.expect. Hundreds may justify a custom tapioca compiler that types them non-nil |
| Editor tooling such as Ruby LSP | It changes behaviour once sorbet-static is in the bundle. Tell the team |
Generators and templates (lib/templates, custom generators) | New files they produce must start at # typed: strict |
How specs isolate (TEST_ENV_NUMBER, shared databases) | Decides whether parallel slice agents may run specs |
| Existing CI, lint and hook layout (hk, lefthook, a lint workflow) | The typecheck joins whatever already runs RuboCop |
Settle these with the user through AskUserQuestion. Put the recommended option first.
| Decision | Recommended default |
|---|---|
| Checker and syntax | For an application, Sorbet with inline RBS comments (#:). Static only: sorbet and tapioca in the development/test group with require: false, and no sorbet-runtime of the project's own. For a published gem, switch to steep-adoption |
| Scope | Every Ruby project in the repo, covering app/, lib/, config/ and in-repo engines. Specs are never typed |
| Generated RBIs | Committed at //third_party/sorbet/rbi/<project>/{gems,dsl} and marked linguist-generated=true. Drop <project>/ when there is only one project; move elsewhere if the survey shows a build-context problem |
| PR shape | One infra PR for all projects, then slices stacked on it in one straight line. Sub-projects such as a gem go on top of that line. In a busy repo where one long stack cannot stay rebased, cut waves instead: each wave is a short stack (or siblings) off main, merged before the next wave starts |
| Branch names | <issue-key>/<part>, so the issue tracker links them |
| Target level | strict for every file that can reach it |
| Team sign-off | In a shared repo, agree with the team before the infra PR, because it changes everyone's workflow |
Also get the tracking issue key. Its description should list the scope, the rule "CI enforces typecheck", "gradual", and "infra PR first".
references/infra.md has the file-by-file checklist with templates. In summary:
sorbet and tapioca to the dev/test group. sorbet-static has no ruby-platform gem, so lock concrete platforms, and pin BUNDLE_FORCE_RUBY_PLATFORM=false in mise.toml [env], because sorah's shell exports true globally. Run mise trust afterwards.tapioca init.outdir at third_party/ and add the second --dir to sorbet/config.--parser=prism, --enable-experimental-rbs-comments and --enable-experimental-requires-ancestor.tapioca gem --all and tapioca annotations. Exclude gems whose RBIs are huge and unused statically.tapioca dsl for Rails. It boots the app against a real database, so bring the dev services up, and ask the user to authenticate when credentials are needed, rather than working around it.# typed: ignore: spec Class.new doubles, and files evaluated in another tool's DSL.--suppress-error-code. If a code pattern forces one, such as class Foo < Data.define, fix the code in a small PR directly on top of infra.spoom srb bump --from false --to true --dry across everything.logger, protobuf Timestamp.from_time, TimeWithZone#floor or Time.current go into sorbet/rbi/shims/ in this PR, together with any custom tapioca compilers the survey called for.Must (from the sorbet skill) and its spec here as well, so every slice can use it.typecheck, one task per project run in parallel, and tapioca, kept out of any gen task because it is slow and boots Rails.third_party/ RBIs.third_party/sorbet/rbi/** from the large-file check.typecheck job that installs only the bundles it needs; it takes about 30 s.# typed: strict, and, if sorbet-runtime is already in the bundle, a grep that bans sig/T. forms in .rb files.docs/type-checking.md with the sections Layout, Commands, Writing types, Nilable values, Union values, Strictness, Known gaps and References. Write it in the language the team's docs use.# typed: strict. Mirror the rule as a review rule if the project has a code-review bot.spoom srb metrics baseline in the PR body.Data.define assignment instead of inheritance. Each is its own PR on top of infra.spoom srb bump considers only files that already carry an explicit sigil. Without one it reports "No files to bump".# typed: false as the first line of every .rb file in scope with scripts/stamp_sigils.rb, then run srb tc.Order the slices bottom-up by call dependency, so each layer's callees are already typed. A typical Rails order:
lib/ and app/models/concerns/Data types and parsersconfig/initializersapplication.rb, routes.rb, environmentsSize each slice at 10 to 30 files, splitting a large directory by domain. Show the user a table with branch, glob and file count, and get approval before starting. Check with a script that every in-scope file lands in exactly one slice.
Each slice is one PR made of separate commits, so reviewers can skim the annotation-only commits and read the behavioural one:
typing: <scope>: raise to true. Annotations only.
typing: <scope> to typed: strict: a signature on every method, constant and instance variable. Annotations only, plus the allowed mechanical edits listed in the agent prompt.
<scope>: <what changed>: anything that changes runtime behaviour. This covers:
else raise arms and Must checks;Leave this commit out when there is nothing to put in it. Bug fixes in sensitive domains (billing, auth) go in separate PRs rather than in the typing PR.
A file that cannot reach strict stays at true or false. Name the Sorbet limitation in the commit message and in docs Known gaps.
A suspected bug is never fixed silently inside an annotation commit. Report it, then fix it in commit 3 with a test, or file an issue.
The orchestrator (the main session) runs this phase:
git worktree add .git/w/<key>-<slice> -b <key>/<slice> <key>/sigils. Run mise trust and initialize submodules in each.tmp/slice.txt with one path per line.references/slice-agent-prompt.md for each slice.Known traps:
cd <absolute path> in every command.bundle cannot resolve sorbet-static. Use eval "$(mise env -s bash)"; or mise x --. The same applies inside the pre-commit hook.TEST_ENV_NUMBER), agents may run their slice's specs.--no-verify.spoom bump --help, the deprecated command. It ignores --help and bumps files.tmp/<key>-heads-before.txt before rewriting anything.git rebase --onto <parent's new head> <slice's original base> <slice>, so each slice replays only its own commits.srb tc for every project.
srb tc, so fixes must go strictly bottom-up.git range-diff. A wrong upstream silently drops commits.hk check --pr or equivalent)./gh-stack:
gh stack init with every branch.git push.gh stack submit --auto for draft PRs, under timeout.untyped, every widened parameter and every shim, each with its reason. End with "Every file this PR owns is at # typed: strict unless its commit says otherwise" and Refs <key>.#: as, untyped, Kernel., allocate, = self #:, send(:, public_send, new parameters that carry narrowed copies, and comments that explain Sorbet.RESTRUCTURE, RAISING_READER, MUST, SHIM, KEEP).tmp/<key>-review.md, one line per decision, each followed by a response slot and an HTML comment listing the options with the recommended one first.srb tc output. Never resolve threads.srb tc again.Gemfile.lock moves or a model changes. Nothing detects that drift automatically, so consider a scheduled job that regenerates them and opens a PR.typed: strict" rule enforced;#: self as lines in concerns into # @requires_ancestor: once the flag is enabled;Timings from the original rollout (about 1750 methods and 300 files), for setting expectations. Scale them by method count.
| Step | Time |
|---|---|
| Infra PR | about 40 min |
| Sigils PR | minutes |
17 slices to true in parallel | about 45 min |
| Strict pass, about 22 agents with up to 10 in flight | about 2 h |
| Integration fixes | about 1 h per rebase onto main |
| Cast elimination | about 1 h 40 min |
| Pushing 20 PRs one at a time for green CI | about 3 h |
Review rounds then ran across several days.
references/infra.md: the infra PR checklist, with templates for sorbet/config, the tapioca config, mise tasks, hk steps, the CI job and the docs/type-checking.md skeletonreferences/slice-agent-prompt.md: the prompt template for a per-slice agent that takes files from false to strictscripts/stamp_sigils.rb: stamps # typed: false on files that have no sigilWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
23 skills in this plugin
/codingThis skill should be used when writing or reviewing code in any language. Provides language-agnostic coding conventions for code quality, comments, error handling, and formatting. Project-specific conventions always take priority./commit-styleThis skill should be used when writing git commit messages, creating git commits, composing pull request titles and descriptions, or when the user asks to "commit", "git commit", "write commit message", "pull request", or "PR description". Provides conventions for subject lines, prefix patterns, body content, and verb choices./dsql-on-railsThis skill should be used when building, extending, or testing a Rails app on Amazon Aurora DSQL, or when moving a Rails app onto DSQL. Use it when writing a transaction, a uniqueness check, a schema change, a spec, a rake task, or CI for such an app, even if the user only says "add a model" or "fix this flaky spec" in such an app. Signs include `aws-sdk-dsql`, `pg-aws_rds_iam`, `aws_rds_iam_auth_token_generator`, a `*.dsql.<region>.on.aws` host, `ActiveRecord::SerializationFailure` with `OC000`/`OC001`, `retryable_transaction`, `non_idempotent_transaction`, `create index async`, `script/pdsql`, or the user mentioning "DSQL", "Aurora DSQL", or "OCC". Provides connection settings and adapter patches, OCC-aware transactions, schema constraints with psqldef, roles, per-developer schemas, RSpec setup, and CI against real clusters. Project-specific conventions always take priority.npx claudepluginhub sorah/config --plugin sorah-guidesOther plugins' skills for the same job