generating-sorbet-inline
Add Sorbet type signatures to Ruby methods
Ruby projects need type safety for reliable code. This skill adds Sorbet inline type signatures to methods using sig blocks. It analyzes Ruby source files, generates proper type annotations, and validates signatures with the Sorbet type checker.
下載技能 ZIP
在 Claude 中上傳
前往 設定 → 功能 → 技能 → 上傳技能
開啟並開始使用
測試它
正在使用「generating-sorbet-inline」。 Add Sorbet types to this User class
預期結果:
- Added # typed: true sigil
- Added extend T::Sig to User class
- Generated sig for initialize(name: String, age: Integer).void
- Generated sig for greet(greeting: String).returns(String)
- Generated sig for attr_reader :name returns(String)
- Generated sig for attr_reader :age returns(Integer)
正在使用「generating-sorbet-inline」。 Type this service object with params and returns
預期結果:
- Analyzed PaymentService class
- Generated sig for process(amount: T.any(Integer, Float), currency: String).returns(T::Boolean)
- Generated sig for validate_customer(customer_id: Integer).void
- Ran 'bundle exec srb tc' - all signatures valid
正在使用「generating-sorbet-inline」。 Add types to this module with class methods
預期結果:
- Found module with class methods
- Added extend T::Sig to module
- Generated sig for self.from_json(json: String).returns(T.untyped)
- Generated sig for self.parse(data: T::Hash[String, T.untyped]).returns(self)
安全審計
安全This is a documentation-only skill providing instructions for generating Sorbet inline type signatures. All static findings are in the reference/ directory which contains example code from the Packwerk gem (Shopify) for learning purposes. The 'weak cryptographic algorithm' findings are for MD5 digests used in cache invalidation (non-security use). Shell backtick execution is for running 'srb tc' validation command (legitimate tooling). No credential access or exfiltration patterns exist. The skill explicitly prohibits running project Ruby code.
風險因素
⚙️ 外部命令 (168)
🌐 網路存取 (30)
📁 檔案系統存取 (6)
品質評分
你能建構什麼
Add types to existing Ruby codebase
Gradually add type safety to Ruby methods in legacy applications
Type Rails models and services
Add type signatures to Rails models, services, and PORO classes
Document public APIs with types
Generate type signatures for gem public interfaces
試試這些提示
Add Sorbet inline type signatures to all methods in this Ruby class file
Analyze this Ruby file and add sig blocks to all methods, attributes, and class methods
Add Sorbet signatures to this Ruby class with type parameters and generics
Add Sorbet inline signatures to this file and run 'srb tc' to validate them
最佳實務
- Start with # typed: true and gradually increase strictness
- Use specific types like String, Integer instead of T.untyped
- Run 'srb tc' after adding signatures to catch errors early
- Ask for clarification when type information is ambiguous
避免
- Using T.untyped as a shortcut defeats the purpose of typing
- Changing typed sigil levels without understanding impact
- Adding signatures without running validation
- Running project Ruby code during signature generation