ruby-conventions

A set of rules for writing Ruby code, including its layout, naming, syntax, errors, strings, and advanced features.

In plain words
What is it for?
Writing, reviewing, or editing Ruby source files such as .rb, .rake, Gemfile, Rakefile, and gemspec files.
Why use it?
It helps keep Ruby files consistent with the Rootstrap style guide and catches many formatting issues through RuboCop, a Ruby code-checking tool.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/rootstrap/rails_api_base/ruby-conventions
Any agent
npx skills add rootstrap/rails_api_base --skill ruby-conventions
Clone the repo
git clone --depth 1 https://github.com/rootstrap/rails_api_base

Made for: Claude Code, Codex.

Per session 84 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,325 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00084 $0.03325
Opus 5 $0.00042 $0.01663
Sonnet 5 $0.00017 $0.00665
Haiku 4.5 $0.00008 $0.00332

Measured yesterday against content hash 9a40b4b6e7c8, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

ruby-conventions scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/ruby-conventions/SKILL.md · 192 lines

How it starts

The opening of the file, as written. The whole thing — 192 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Ruby Conventions (Rootstrap)

Apply these conventions whenever producing or modifying Ruby code. Full guide: https://github.com/rootstrap/tech-guides/blob/master/ruby/README.md

Most of these are enforced by RuboCop (see .rubocop.yml). When in doubt, run RuboCop.

Source Code Layout

  • UTF-8, Unix line endings, 2-space indentation (no tabs), one expression per line (no ;).
  • Max 100 chars per line; end files with a newline; no trailing whitespace.
  • Prefer FooError = Class.new(StandardError) over empty class ... end.
  • Avoid single-line methods (exception: def no_op; end).
  • Spaces around operators, after commas/colons; no spaces inside (, [, around !, or in range literals (1..3).
  • Exception: no spaces around exponent: c**2.
  • Indent when the same as case.
  • Blank lines between methods and around access modifiers; no blank lines inside class/method bodies.
  • No trailing comma after last arg/element.
  • Spaces around = in default params: def f(a = 1).
  • Avoid line continuation \ except for string concatenation.
  • In multi-line chains, keep . on the next line.
  • Use underscores in big numbers: 1_000_000. Lowercase prefixes 0x, 0o, 0b.
  • No block comments (=begin/=end).
  • Never more than one consecutive blank line.
  • Align multi-line method args after (, OR single-indent with ) on its own line (avoid "double indent").
  • For case/if result assignment, either align branches under the keyword or break with kind = on its own line.

Syntax

  • Use :: only for constants/constructors, not method calls.
  • def with parens when params exist, omit when empty.
  • Parens around method arguments, except: no-arg calls, DSL methods (validates :name, ...), and keyword-like (attr_reader, puts).
  • Optional args at end of parameter list.
  • Prefix unused block vars with _: |_k, v|.
  • Avoid parallel assignment (a, b, c = 1, 2, 3) except for swap, method-return destructuring, or splat.
  • Prefer trailing-underscore form: a, = foo.split(',') over a, _, _ = .... Use named underscore vars (_second) when position conveys meaning.
  • Don't use for; use iterators (each).
  • No then in multi-line if; no if x; .... Always put the condition on the same line as if/unless.
  • Avoid multi-line ternary — use if/unless instead.
  • No while cond do / until cond do for multi-line loops (drop the do).
  • Favor ternary over if/then/else one-liners; don't nest ternaries.
  • Leverage if/case as expressions.
  • Use ! not not; avoid !! boolean coercion.
  • and/or keywords are banned — use &&/||.
  • Favor modifier if/unless/while/until for single-line bodies; avoid on multi-line blocks; don't nest modifiers.
  • Favor unless for negatives; favor until over while for negative loop conditions. Never unless with else.
  • No parens around control-expression conditions (except safe assignment if (v = ...)).
  • Use Kernel#loop for infinite loops; prefer loop { ... break unless ... } over begin ... end while for post-condition loops.
  • Omit outer {} AND parens for internal DSL methods: validates :name, presence: true, length: { within: 1..10 }.
  • Omit outer {} on trailing options hashes: user.set(name: 'John', age: 45).
  • Use &:method shorthand: names.map(&:upcase).
  • {...} for single-line blocks, do...end for multi-line. Avoid do...end in chains.
  • Avoid explicit return when unnecessary; avoid self. unless required.
  • Use ||= to init nil/unset vars; don't use ||= for booleans.
  • Use &&= to preprocess nullable values.
  • Avoid === outside case.
  • Use == not eql? unless strict type comparison is intended.
  • No space between method name and opening paren: f(x).
  • No nested method defs; use lambdas.
  • Lambda: ->(a, b) { ... } with args (parens required); -> { ... } with no args (omit parens); lambda do ... end for multi-line.
  • Prefer proc over Proc.new; use .call() not [] or .().
  • Use shorthand self-assignment: x += y, x **= y, etc.
  • Use explicit &block to forward blocks rather than wrapping them.
  • Don't shadow methods with local variables (e.g. naming an arg options when an accessor already exists).
  • Don't use character literals (?x) — use 'x'.
  • Avoid Perl-style special vars ($;, $,); prefer English library aliases ($LOAD_PATH, etc.).
  • Don't use BEGIN/END blocks; use Kernel#at_exit instead.
  • Use warn over $stderr.puts.
  • Favor sprintf/format over String#%; Array#join over Array#*.
  • Use Array(var) to coerce possibly-single values into arrays.
  • Use ranges or between? instead of x >= a && x <= b.
  • Predicate methods (.even?, .zero?, .nil?) over == 0, == nil.
  • Avoid !x.nil? when if x suffices.
  • Guard clauses over nested conditionals; next over if in loops.
  • Prefer: map over collect, select over find_all, find over detect, reduce over inject, size over length/count (note: count on non-Array Enumerables iterates the full collection).
  • flat_map over map.flatten(1); reverse_each over reverse.each.

Read the full file on GitHub · 192 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 192 lines · 84 tokens per session scan A 9a40b4b6e7c8

Subscribe to this mod's changes

ruby-conventions is a skill published in the GitHub repository rootstrap/rails_api_base (633 stars, last pushed 3d ago), licensed MIT. It adds 84 tokens to every session and 3,325 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.