AgentSkillsCN

shopify-ruby

Shopify 的 Ruby/Rails 开发模式——切片、开发 CLI、Sorbet、Rubocop

SKILL.md
--- frontmatter
name: shopify-ruby
description: Ruby/Rails development patterns at Shopify - slices, dev CLI, Sorbet, rubocop
license: MIT
compatibility: opencode
metadata:
  audience: developers
  workflow: ruby

Shopify Ruby/Rails Development

Dev CLI

  • Location: /opt/dev/bin/dev
  • Always prefer dev commands over direct tool access
bash
dev check          # Run all checks
dev style          # Lint (rubocop)
dev typecheck      # Sorbet
dev test           # Tests
dev console        # Rails console

Sorbet & Tapioca

After adding/modifying models, associations, or using new DSLs:

bash
bin/tapioca dsl                  # Regenerate all DSL RBIs
bin/tapioca dsl <ModelName>      # Regenerate specific model
bin/tapioca gem <gem-name>       # Regenerate gem RBIs

Common triggers for tapioca dsl:

  • New ActiveRecord models
  • New associations (has_many, belongs_to, etc.)
  • New enums
  • New scopes

slices.yml

Editing Caveat

CAUTION: The Edit tool corrupts YAML formatting by changing indentation throughout the file.

Use Python for precise edits:

python
python3 << 'EOF'
with open('slices.yml', 'r') as f:
    content = f.read()
content = content.replace('old_pattern', 'new_pattern')
with open('slices.yml', 'w') as f:
    f.write(content)
EOF

Or use awk for insertions:

bash
awk '/pattern/{print; print "  - new/entry/here"; next}1' slices.yml > tmp && mv tmp slices.yml

Requirements

  • Entries must be alphabetically sorted within each section
  • Run dev check slices-style to verify formatting/ordering

Interpreting slices-check Failures

slices-check may report "uncovered files" that are:

  • From parent branches (in graphite stacks) - not your responsibility
  • Local development files (.opencode/, etc.)

To verify if a file is from your branch:

bash
git diff <parent-branch> -- <file>

Common Rubocop Fixes

IssueFix
unless .any?Use if .none?
if wrapping single statementUse next unless / return unless
return nilUse return
Single quotes in interpolationUse double quotes
Missing frozen_string_literalAdd # frozen_string_literal: true
Method calls without parensAdd parentheses: method(args)

dev check Interpretation

CheckYour responsibility?
style-rubyYes - your code
slices-styleYes - your slices.yml changes
slices-check uncovered filesMaybe - check if from parent branch
typecheckYes - run tapioca dsl if needed