CLI tool
ruby/rbs avatar
ruby/rbs

rbs prototype writes untyped signatures that you must tighten by hand

The type signature language for Ruby

2,186 stars265 forksRubyLicense varies

At a glance

What is it?
ruby/rbs is the type signature language for Ruby and a gem with a command line tool and a Ruby library for reading signatures. It describes classes, methods and variables in separate .rbs files, and it does not check anything on its own.
Who is it for?
Adopt RBS if you maintain a Ruby gem or application and want signatures kept in files separate from the code, starting with rbs prototype rb output that you then tighten. Skip it if you expect the gem to catch type errors by itself, since the README presents a language and tooling to read it.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly Ruby, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 26, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • ruby/rbs2,186 ★ · +3
Star history
Repository2026-10-082026-11-26
ruby/rbs2.2k2.2k

3 Stars in the last 49 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

A signature file lists structure and leaves the method bodies out

RBS is described as a language to describe the structure of Ruby programs. A signature file records a class or module, the methods defined in it, instance variables and their types, inheritance and mix-in relations, constants and global variables. The README's chat app example opens with a module and a constant:

rbs
module ChatApp
  VERSION: String

  class User
    attr_reader login: String
    attr_reader email: String

    def initialize: (login: String, email: String) -> void
  end

Two operators appear in the Message class of that example, both explained in its comments. A pipe means a union type, so from can be User or Bot, and a question mark means optional, so reply_to is a Message or nil. Method signatures use the form def name: (arguments) -> return type.

The code itself stays in .rb files. A signature in RBS is a statement about what the code should accept and return, and a mismatch is only found by a separate tool that reads both.

rbs prototype rb produces a starting point full of untyped

The README says an end user will probably find rbs prototype the most useful command. Given a person.rb with a Person class, attr_reader lines, an initialize taking name: and a speak method, it prints boilerplate:

console
$ rbs prototype rb person.rb
class Person
  @name: untyped

  @contacts: untyped

  attr_reader name: untyped

  attr_reader contacts: untyped

  def initialize: (name: untyped) -> void

  def speak: () -> ::String
end

Every instance variable and attribute comes out as untyped, and only speak gets a real return type, ::String, because it returns an interpolated string. The README states this is only a starting point and you should edit the output to match your signature more accurately.

The consequence is manual work proportional to the code. A file with thirty methods yields thirty signatures where most types are untyped until a person fills them in. Generation saves the typing of names and arities, and the judgment about types remains yours.

Three prototype modes, one of them deprecated

rbs prototype offers three options. The rb option generates from just the available Ruby code, which is the one in the example above. The rbi option generates from Sorbet RBI files, which gives a route for teams that already hold Sorbet signatures. The runtime option generates from the runtime API and is marked deprecated, with the README pointing to issue #2841.

A project that wanted to introspect loaded classes through runtime therefore needs another plan. The README does not name a replacement for runtime generation, so the linked issue is the place to learn what the maintainers recommend instead.

The practical order is rb for code you can read statically, rbi for code with existing Sorbet files, and no new work on the runtime option. Whichever mode you use, the output still goes through the same hand editing.

The library API centers on an environment and a definition

Besides the command line, the gem is a Ruby library built around two ideas. An environment is a dictionary that keeps track of all declarations, and it answers what declaration is associated with the String class. A definition gives the detail of a class, such as the list of methods it provides and the type of what gsub returns on String.

The README's sample code loads files through RBS::EnvironmentLoader, with commented lines for adding a path such as a sig directory or a library such as logger. It builds an environment with RBS::Environment.from_loader(loader).resolve_type_names, makes a type name for ::String, reads the class declaration from environment.class_decls, and uses RBS::DefinitionBuilder to turn a declaration into a definition.

That is the layer other tools build on to read signatures. The README's listing stops before the final lines, so the Architecture document under docs is the next stop for anyone writing a tool on top.

The CLI inspects the standard library as well as your own files

The gem ships the rbs command to demonstrate what it can do and to help develop RBS. The README lists five inspection commands:

console
$ rbs version
$ rbs list
$ rbs ancestors ::Object
$ rbs methods ::Object
$ rbs method Object then

These read the loaded signatures: list prints declarations, ancestors shows the ancestor chain of ::Object, methods lists its methods, and method prints one method's signature, here Object#then. The result is a quick way to ask what the signatures say before you open a source file.

Installation is the gem, either from the command line with gem install rbs or as a line in a Gemfile, gem "rbs". The repository also holds a stdlib directory, a core directory and a sig directory, which is where signatures for Ruby's own classes live.

Version targets are written for 2026 and move with Ruby

The README states two targets. The standard library signatures target the latest release of Ruby, 4.0 as of 2026. The library code targets non-EOL versions of Ruby, which means >= 3.3 as of 2026.

Two moving parts follow from this. Signatures for the standard library describe Ruby 4.0, so a project on an older Ruby may see signatures for methods its interpreter lacks. And the gem itself drops Ruby versions as they reach end of life, so an old Ruby will eventually stop getting new rbs releases.

Recent releases are 4.2.0 on 2026-08-23, 4.2.0.pre.1 on 2026-08-18 and 4.2.1.pre.1 on 2026-08-26, so prerelease tags appear close to final ones. The repository is not archived and the last push was 2026-10-23. Pin the gem to an exact version in your Gemfile and read CHANGELOG.md when upgrading.

Third-party gem signatures live in a separate repository

A gem that ships no RBS files has no signatures unless someone writes them. The community section points to gem_rbs_collection, a repository of third-party RBS type definitions, for the case where a dependency does not ship its own. The docs folder has a page on the RBS collection, and another on releasing a gem with RBS so that a library author can ship signatures inside the gem.

The README also lists a guide to using Data and Struct, a writing signatures guide, a syntax reference and an RBS by Example page. Maintainers can be reached in the rbs channel of the Ruby Discord server and the types channel of the ruby-jp Slack workspace, the second in Japanese.

The repository metadata lists the license as NOASSERTION. It contains COPYING and BSDL files, so the terms are in the repository even though GitHub could not classify them, and you should read both before redistributing.

The tree also includes C code, with clang-format setup and rake format:c and rake format:c_check tasks, plus rust and wasm directories that the README does not explain.

Editorial conclusion

Adopt RBS if you maintain a Ruby gem or application and want signatures kept in files separate from the code, starting with rbs prototype rb output that you then tighten. Skip it if you expect the gem to catch type errors by itself, since the README presents a language and tooling to read it. Before committing, run rbs prototype on one real file and count how many untyped entries you would have to replace.

Frequently asked questions

What is Ruby RBS?

RBS is a language to describe the structure of Ruby programs: classes, modules, methods, instance variables, inheritance, constants and global variables. The rbs gem ships a command line tool and a Ruby library for reading those signatures.

What does RBS stand for?

The README does not expand the abbreviation. It only calls RBS the type signature language for Ruby and a language to describe the structure of Ruby programs.

Is Ruby the same as Ruby on Rails, and where does RBS fit?

The repository does not discuss Rails. RBS describes Ruby programs, and its standard library signatures target Ruby 4.0 as of 2026.

Official sources

  1. Issues
  2. README
  3. Releases
  4. ruby/rbs on GitHub

Was this useful?