Add inline RBS type annotations to Ruby code using magic comments. Use when the user asks for inline types, @rbs comments, type hints in Ruby files, or annotating methods directly in source.
/plugin marketplace add DmitryPogrebnoy/ruby-agent-skills/plugin install dmitrypogrebnoy-ruby-type-signature-skills-plugins-ruby-type-signature-skills@DmitryPogrebnoy/ruby-agent-skillsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Add inline RBS type annotations directly to Ruby source code using magic comments.
RBS supports inline annotations via magic comments:
# @rbs generic T
class Container
# @rbs @items: Array[T]
# @rbs (T item) -> void
def add(item)
@items << item
end
# @rbs () -> T?
def first
@items.first
end
end
Basic method signature:
# @rbs (String name, Integer age) -> User
def create_user(name, age)
User.new(name, age)
end
Optional parameters:
# @rbs (String name, ?Integer age) -> User
def create_user(name, age = nil)
User.new(name, age)
end
Keyword arguments:
# @rbs (name: String, age: Integer) -> User
def create_user(name:, age:)
User.new(name, age)
end
Block parameters:
# @rbs (Array[String] items) { (String) -> void } -> void
def process(items, &block)
items.each(&block)
end
Splat arguments:
# @rbs (*String names) -> Array[User]
def create_users(*names)
names.map { |n| User.new(n) }
end
class User
# @rbs @name: String
# @rbs @email: String
# @rbs @active: bool
def initialize(name, email)
@name = name
@email = email
@active = true
end
end
class User
# @rbs!
# attr_reader name: String
# attr_reader email: String
# attr_accessor active: bool
attr_reader :name, :email
attr_accessor :active
end
Generic classes:
# @rbs generic T
class Stack
# @rbs @items: Array[T]
# @rbs (T item) -> void
def push(item)
@items.push(item)
end
end
Module inclusion:
# @rbs!
# include Enumerable[User]
class UserCollection
include Enumerable
end
When to use inline annotations:
Best practices:
class User
# Class-level annotations at top
# @rbs generic T
# Instance variable annotations
# @rbs @items: Array[T]
# Method annotation immediately before method
# @rbs (T item) -> void
def add(item)
@items << item
end
end
Original Ruby:
class Calculator
def initialize
@history = []
end
def add(a, b)
result = a + b
@history << result
result
end
def history
@history.dup
end
end
Annotated Ruby:
class Calculator
# @rbs @history: Array[Numeric]
# @rbs () -> void
def initialize
@history = []
end
# @rbs (Numeric a, Numeric b) -> Numeric
def add(a, b)
result = a + b
@history << result
result
end
# @rbs () -> Array[Numeric]
def history
@history.dup
end
end
Inline annotations can be extracted to separate files:
rbs prototype rb --out-dir=sig lib/user.rb