r/ruby • • 11h ago

Steep / RBS toolkit - (steep-kit gem)

Hi all,

I just open-sourced (slope-coded) steep-kit, a companion toolkit for Ruby apps and gems typed with inline RBS (# u/rbs / #:) and checked with Steep.

It was battle-tested in our company for about 4-5 months and evolved (slope-rewritten) to a point of being community ready. https://github.com/maokomioko/steep-kit

Why it exists

RBS 4.2's native inline parser + Steep 2.1 are great, but adopting them incrementally on a larger codebase hits two recurring gaps:

  • Runtime definitions the inline parser can't see: Data.define / Struct.new, class-body alias / alias_method, unannotated literal constants, ClassMethods mixins, dynamic superclasses, and macros like attr_json.
  • Scaling friction: body-checking overhead on silent donor files, CLI/LSP memory retention, drifted rbs_rails output, and signature/runtime drift.

What it does

  • Projected RBS (sig/projected + watch): generates classic RBS reopenings for Data.define/Struct.new, alias/alias_method, and (opt-in) attr_json.
  • In-memory RBS & Steep enhancements: infers literal/record constants, handles value/dynamic superclasses and opt-in mixin contracts (ClassMethods, command aliases, nested classes), and patches Steep for lower overhead (signature-only silent donors, path-indexed lookups, completed-typing compaction).
  • Single CI / pre-push gate (bundle exec steep-kit): syncs rbs_collection, lints inline grammar pitfalls (class << self, Data.define blocks), validates record-constant key lookups workspace-wide via Rubydex, and checks sig/projected freshness.
  • Optional tooling: steep-kit fast (targeted --validate=skip checks), deterministic scratch-DB steep-kit rbs-rails, and SteepKit::Runtime (rbs/test with inline RBS + nested mismatch paths).

All Rails and convention features are off by default, so it works for plain Ruby apps and gems too (Ruby 3.3+, RBS 4.2, Steep 2.1, Rubydex 0.4).

Hope it helps someone else :3

5 Upvotes

2 comments sorted by

1

u/KevinSaison 8h ago

Interesting ! How do you decide what steep-kit should figure out automatically, what it should generate as RBS files, and what developers still need to define themselves?

2

u/maokomioko 8h ago

I think it boils down to a few questions that devs can ask:
- Is it a method contract, type, or domain intent? Then "#:"
- Is it an idiom, that will be more clear in a typed form (class << self, Data.define { def ... }) ? Then lint-inline rule
- Does it break inline parsing itself, or repeats across classes/ constants etc? Then automatic in-memory (config/steep_kit.yml)
- Does it only appear "here and there" in a few places across the project? Then sig/handwritten

Before this, we've been heavily using YARD in JetBrains RubyMine compatible form (https://www.jetbrains.com/help/ruby/documenting-source-code.html) and over time our declarations became very standardized, almost autocomplete ready. So steep-kit naturally took over.