Agent skill
generating-sorbet-inline
Generates Sorbet inline type signatures using sig blocks directly in Ruby source files. Triggers when adding Sorbet types, annotating Ruby methods with sig syntax, or generating type signatures for Sorbet-typed projects.
Install this agent skill to your Project
npx add-skill https://github.com/aiskillstore/marketplace/tree/main/skills/dmitrypogrebnoy/generating-sorbet-inline
SKILL.md
Sorbet Inline Generation Skill
Generate Sorbet type signatures using sig {} blocks directly in Ruby source 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 execif the project has Gemfile. - You MUST use
sig { }block syntax for method signatures. - You MUST add
extend T::Sigto classes/modules before usingsig. - You MUST focus on method signatures only. Skip local variables, intermediate expressions, and other non-method annotations.
- You MUST NOT use or generate
.rbifiles. 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.
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.
-
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: trueas a sensible default (allows gradual typing).
Sigil levels (least to most strict):
ignore<false<true<strict<strong -
Add
extend T::Sigto the class/module:rubyclass MyClass extend T::Sig end -
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.untypedwith proper types. - Use code context, method calls, and tests to infer types.
- Use
T.untypedonly 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.untypedtypes. - 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
- syntax.md - Sorbet signature syntax guide
- sorbet_examples/ - Real-world Sorbet examples from production gems
- Sorbet documentation - Official Sorbet docs
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
perigon-backend
Perigon ASP.NET Core + EF Core + Aspire conventions
perigon-agent
Pointers for Copilot/agents to apply Perigon conventions
perigon-angular
Angular 21+ standalone/Material/signal conventions for Perigon WebApp
fastapi-mastery
Comprehensive FastAPI development skill covering REST API creation, routing, request/response handling, validation, authentication, database integration, middleware, and deployment. Use when working with FastAPI projects, building APIs, implementing CRUD operations, setting up authentication/authorization, integrating databases (SQL/NoSQL), adding middleware, handling WebSockets, or deploying FastAPI applications. Triggered by requests involving .py files with FastAPI code, API endpoint creation, Pydantic models, or FastAPI-specific features.
context7-efficient
Token-efficient library documentation fetcher using Context7 MCP with 86.8% token savings through intelligent shell pipeline filtering. Fetches code examples, API references, and best practices for JavaScript, Python, Go, Rust, and other libraries. Use when users ask about library documentation, need code examples, want API usage patterns, are learning a new framework, need syntax reference, or troubleshooting with library-specific information. Triggers include questions like "Show me React hooks", "How do I use Prisma", "What's the Next.js routing syntax", or any request for library/framework documentation.
browser-use
Browser automation using Playwright MCP. Navigate websites, fill forms, click elements, take screenshots, and extract data. Use when tasks require web browsing, form submission, web scraping, UI testing, or any browser interaction.
Didn't find tool you were looking for?