Skip to content
generating-sorbet-inline logo

Sorbet Inline Generation Skill

generating-sorbet-inline

Generates or updates Sorbet inline type signatures directly in Ruby source files using sig blocks. Triggers when creating, updating, or maintaining inline type signatures for Ruby source files.

SKILL.md

Full skill instructions

Sorbet Inline Generation Skill

Generate or update Sorbet type signatures using sig {} blocks directly in Ruby source files. Supports both full generation from scratch and partial updates for individual changed files. Sorbet signatures are valid Ruby code that enable both static and runtime type checking.

Instructions

When generating Sorbet inline signatures, always follow these steps.

Copy this checklist and track your progress:

Sorbet Inline Generation Progress:
- [ ] Step 1: Analyze the Ruby source
- [ ] Step 2: Add Sorbet signatures
- [ ] Step 3: Eliminate `T.untyped` in signatures
- [ ] Step 4: Review and refine signatures
- [ ] Step 5: Validate signatures with Sorbet

Rules

  • You MUST NOT run Ruby code of the project.
  • You MUST NOT use T.untyped. Infer the proper type instead.
  • You MUST NOT use T.unsafe - it bypasses type checking entirely.
  • You MUST NOT use T.cast - it forces types without verification.
  • You MUST ask the user to provide more details if something is not clear.
  • You MUST prepend any command with bundle exec if the project has Gemfile.
  • You MUST use sig { } block syntax for method signatures.
  • You MUST add extend T::Sig to classes/​modules before using sig.
  • You MUST focus on method signatures only. Skip local variables, intermediate expressions, and other non-method annotations.
  • You MUST NOT use or generate .rbi files. This skill is for inline signatures only.
  • You MUST preserve the existing # typed: sigil level if one exists. Do not upgrade or change strictness without explicit user consent.
  • You MUST use the tracking file when processing multiple files to ensure no files are missed.

Multi-File Processing

When processing multiple Ruby files, create a tracking file to ensure all files are covered:

  1. Create tracking file .sorbet-inline-generation-todo.tmp:

    [ ] app/​models/​user.rb
    [ ] app/​models/​post.rb
    [ ] app/​services/​auth_service.rb
    
  2. Process files one by one:

    • Take the next pending [ ] entry
    • Complete all steps (1-5) for that file
    • Mark as processed [x]
    • Save the tracking file
    • Continue to next pending entry
  3. Cleanup: Remove the tracking file after all files are processed:

    rm .sorbet-inline-generation-todo.tmp
    

If interrupted, the tracking file allows resuming from where you left off.

1. Analyze the Ruby Source

Always perform this step.

Read and understand the Ruby source file:

  • Identify all classes, modules, methods, constants and instance variables.
  • Note inheritance, module inclusion and definitions based on metaprogramming.
  • Note visibility modifiers - public, private, protected.
  • Note existing # typed: sigil level at the top of the file.
  • Note type parameters for generic classes.

2. Add Sorbet Signatures

Always perform this step.

  1. First, check if the file already has a # typed: sigil at the top:

    • If sigil exists: Preserve the existing level. Do not change it without user consent.
    • If no sigil exists: Add # typed: true as a sensible default (allows gradual typing).

    Sigil levels (least to most strict): ignore < false < true < strict < strong

  2. Add extend T::Sig to the class/​module:

    class MyClass
      extend T::Sig
    end
    
  3. Then add type signatures using sig {} blocks:

Example - Before:

class User
  attr_reader :name, :age

  def initialize(name, age)
    @name = name
    @age = age
  end

  def greet(greeting)
    "#{greeting}, #{@name}!"
  end
end

Example - After:

# typed: true

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)
    @name = name
    @age = age
  end

  sig { params(greeting: String).returns(String) }
  def greet(greeting)
    "#{greeting}, #{@name}!"
  end
end
  • Focus on method and attribute signatures only
  • See syntax.md for the full Sorbet syntax guide

3. Eliminate T.untyped in Signatures

Always perform this step.

  • Review all signatures and replace T.untyped with proper types.
  • Use code context, method calls, and tests to infer types.
  • Use T.untyped only as a last resort when type cannot be determined.

4. Review and Refine Signatures

Always perform this step.

  • Verify signatures are correct, coherent, and complete.
  • Remove unnecessary T.untyped types.
  • Ensure all methods and attributes have signatures.
  • Fix any errors and repeat until signatures are correct.

5. Validate Signatures with Sorbet

Always perform this step.

Run Sorbet type checker to validate signatures:

srb tc

Or with bundle:

bundle exec srb tc

This checks:

  • Signature syntax correctness
  • Type consistency
  • Method parameter/​return type matching
  • Instance variable initialization

Fix any errors reported and repeat until validation passes.

References

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View