wk-workstyle-ruby
Enforces Ruby naming, file, control-flow, enumerable, exception, and comment idioms on every Ruby file the agent touches.
Works with
Agent Skills format with YAML frontmatter. Claude Code reads it as-is.
---
name: "wk-workstyle-ruby"
description: "Enforces Ruby naming, file, control-flow, enumerable, exception, and comment idioms on every Ruby file the agent touches."
license: "MIT"
---
# Workstyle — Ruby
Enforces Ruby naming, file, control-flow, enumerable, exception, and comment
idioms on every Ruby file the agent touches. Part of the `wk-workstyle` family.
**Project settings are authoritative — this skill fills gaps only, never
overrides.** When a linter/formatter config governs a rule below, that config
wins; see `wk-workstyle` Step 0 for the project-style-authority probe.
## When to Use
Auto-invoked whenever the agent writes or edits a `.rb` file or a bin script
loaded as Ruby. Trigger contexts:
- Writing or editing a `.rb` file.
- Editing a `bin/` script loaded as Ruby (shebang `#!/usr/bin/env ruby` or
similar).
- Adding or refactoring Ruby methods, control flow, or exception handling.
Manual: `/wk-workstyle-ruby scan` (full working tree) · `/wk-workstyle-ruby check <path>` (one file).
## Rules
- **Predicate methods end in `?`**; mutating methods end in `!`; follow the Ruby naming contract.
- **`frozen_string_literal: true`** magic comment in every file.
- **Guard `return` / `next` / `break`** at the top of a method rather than `unless … else`.
- **Prefer `map`, `select`, `reduce`** over imperative loops.
- **Parenthesize endless/beginless ranges in `case/when`**: `when (50..)`, `when (..29)`. A bare `when 50..` parses the range as extending into the next expression → empty `when` branch → RuboCop `Lint/RequireRangeParentheses` + `Lint/EmptyWhen`.
- **`raise` specific exception subclasses**, not bare `RuntimeError`.
- **No `rescue Exception`** — rescue `StandardError` at most unless explicitly handling signals.
- **ASCII-only in source comments.** Use `-`, `->`, `--`, `...` — not em dash (`—`), en dash (`–`), smart quotes,
or Unicode ellipsis. RuboCop's `Style/AsciiComments` enforces this in many Ruby shops; the cop default is
ASCII-only. Applies to `.rb` files and bin scripts loaded as Ruby.
- **Literal single space in a regex → `\x20`**, never a bare space (invisible) or `[ ]` (RuboCop `Style/RedundantRegexpCharacterClass` rejects the class).
- **`MatchData` named captures use bracket access (`match[:name]`)**, not `fetch` — `MatchData` does not implement `fetch`; check for `nil` match before access.
## Sorbet strict-mode friction (typed Rails apps)
- **Exercise a shared base-controller `before_action` via a concrete named subclass in the spec**, not an anonymous `controller do … end` block — the block form trips `Sorbet/BlockMethodDefinition` against the no-metaprogramming cop.
- **Prefer a plain sig'd class with an inlined filter over `ActiveSupport::Concern`** when the app has no concern precedent and Sorbet `requires_ancestor` + `included do` fails to type-check.
## Verify with RuboCop
- **Important — run `bundle exec rubocop --no-color <changed-files>` on every changed `.rb` file before staging.** Layout and style cops (argument line breaks, non-ASCII comment characters) are not reliably caught by inspection alone; only the linter sees them. Skipping the local run defers the catch to CI and forces a follow-up fix commit.
- **Delegating the edit never delegates the lint.** Whoever stages runs it,
however the code was produced — an agent that cannot run shell, a coordinator
applying another agent's edits, or a patch taken from elsewhere. Unowned lint is
unrun lint, and non-ASCII comment characters are exactly what slips through when
the author and the stager are different actors.
- Fix every offense before `wk-commit`.
- Skip only when the repo has no RuboCop config or `bundle exec rubocop` is unavailable.
## Apply or Report
- **Auto-fixable** (mechanical) → apply silently, note in the commit message.
- **Requires judgment** → surface as a suggestion before committing: what the
finding is, where, and a concrete fix sketch.
- **Conflicts with project config** → suppress; never fight the linter.
## Post-Completion
Invoke `wk-learn` with this skill's short name as the argument
(e.g., `wk-learn workstyle-ruby`).More General & Other skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
grill-with-docs
mattpocock/skills
A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.

