Skip to main content
skill CX Codex

ruby-optimise — Claude Code skill for Ruby performance

The ruby-optimise skill guides Ruby code reviews and refactors around performance. Use it when working with allocations, collections, ActiveRecord queries, or runtime settings.

MIT 292 installs ★ 227 updated 2026-08-15

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add pproenca/dot-skills --skill ruby-optimise -a claude-code
Open on GitHub

What ruby-optimise does

The skill groups guidance into eight areas, from object allocation and collection processing to concurrency and Ruby runtime configuration. Each area has a priority; allocation and collection rules rank as critical. Those are the first places to look, while runtime tuning sits lower in the order.

Topics include ActiveRecord queries, strings, data structures, and threads. For instance, the guidance covers eager-loading associations and using find_each for large record sets. More detailed explanations and code samples live in separate files under references/. Specific recommendations depend on the Ruby code being reviewed.

What it helps with

  • spot unnecessary object creation in Ruby code
  • refactor collection processing into a single pass
  • find database queries inside loops
  • reduce repeated string operations
  • choose guidance for thread pools and GC settings

Example prompts for the agent

  • Review this Ruby code for unnecessary object allocations and suggest changes.
  • Check this ActiveRecord method for queries inside loops.
  • Suggest a way to process this large collection without creating temporary arrays.

How to install ruby-optimise

1Skills CLI (Vercel)

npx skills add pproenca/dot-skills --skill ruby-optimise -a claude-code

2Manually: put the files in place

~/.claude/skills/ruby-optimise/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/ruby-optimise/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about ruby-optimise

How do I install ruby-optimise in Claude Code?

Run npx skills add pproenca/dot-skills --skill ruby-optimise -a claude-code. The skill file will be at ~/.claude/skills/ruby-optimise/SKILL.md.

What does ruby-optimise do?

It provides Ruby performance guidance covering object allocation, collections, ActiveRecord access, strings, concurrency, and runtime configuration.

Which ruby-optimise topics have the highest priority?

Object allocation and collection processing come first, and both are marked critical. Runtime configuration is lower on the priority list.

Source text

SKILL.md · MIT
---
name: ruby-optimise
description: Ruby performance optimization guidelines. This skill should be used when writing, reviewing, or refactoring Ruby code to ensure optimal performance patterns. Triggers on tasks involving object allocation, collection processing, ActiveRecord queries, string handling, concurrency, or Ruby runtime configuration.
---

# Community Ruby Best Practices

Comprehensive performance optimization guide for Ruby applications, maintained by the community. Contains 42 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.

## When to Apply

Reference these guidelines when:
- Writing new Ruby code or gems
- Optimizing ActiveRecord queries and database access patterns
- Processing large collections or building data pipelines
- Reviewing code for memory bloat and GC pressure
- Configuring Ruby runtime settings for production

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Object Allocation | CRITICAL | `alloc-` |
| 2 | Collection & Enumeration | CRITICAL | `enum-` |
| 3 | I/O & Database | HIGH | `io-` |
| 4 | String Handling | HIGH | `str-` |
| 5 | Method & Dispatch | MEDIUM-HIGH | `meth-` |
| 6 | Data Structures | MEDIUM | `ds-` |
| 7 | Concurrency | MEDIUM | `conc-` |
| 8 | Runtime & Configuration | LOW-MEDIUM | `runtime-` |

## Quick Reference

### 1. Object Allocation (CRITICAL)

- [`alloc-avoid-unnecessary-dup`](references/alloc-avoid-unnecessary-dup.md) - Avoid Unnecessary Object Duplication
- [`alloc-freeze-constants`](references/alloc-freeze-constants.md) - Freeze Constant Collections
- [`alloc-lazy-initialization`](references/alloc-lazy-initialization.md) - Use Lazy Initialization for Expensive Objects
- [`alloc-avoid-temp-arrays`](references/alloc-avoid-temp-arrays.md) - Avoid Temporary Array Creation
- [`alloc-reuse-buffers`](references/alloc-reuse-buffers.md) - Reuse Buffers in Loops
- [`alloc-avoid-implicit-conversions`](references/alloc-avoid-implicit-conversions.md) - Avoid Repeated Computation in Hot Paths

### 2. Collection & Enumeration (CRITICAL)

- [`enum-single-pass`](references/enum-single-pass.md) - Use Single-Pass Collection Transforms
- [`enum-lazy-large-collections`](references/enum-lazy-large-collections.md) - Use Lazy Enumerators for Large Collections
- [`enum-flat-map`](references/enum-flat-map.md) - Use flat_map Instead of map.flatten
- [`enum-each-with-object`](references/enum-each-with-object.md) - Use each_with_object Over inject for Building Collections
- [`enum-avoid-count-in-loops`](references/enum-avoid-count-in-loops.md) - Avoid Recomputing Collection Size in Conditions
- [`enum-chunk-batch-processing`](references/enum-chunk-batch-processing.md) - Use each_slice for Batch Processing

### 3. I/O & Database (HIGH)

- [`io-eager-load-associations`](references/io-eager-load-associations.md) - Eager Load ActiveRecord Associations
- [`io-select-only-needed-columns`](references/io-select-only-needed-columns.md) - Select Only Needed Columns
- [`io-batch-find-each`](references/io-batch-find-each.md) - Use find_each for Large Record Sets
- [`io-avoid-queries-in-loops`](references/io-avoid-queries-in-loops.md) - Avoid Database Queries Inside Loops
- [`io-stream-large-files`](references/io-stream-large-files.md) - Stream Large Files Line by Line
- [`io-connection-pool-sizing`](references/io-connection-pool-sizing.md) - Size Connection Pools to Match Thread Count
- [`io-cache-expensive-queries`](references/io-cache-expensive-queries.md) - Cache Expensive Database Results

### 4. String Handling (HIGH)

- [`str-frozen-literals`](references/str-frozen-literals.md) - Enable Frozen String Literals
- [`str-shovel-over-plus`](references/str-shovel-over-plus.md) - Use Shovel Operator for String Building
- [`str-interpolation-over-concatenation`](references/str-interpolation-over-concatenation.md) - Use String Interpolation Over Concatenation
- [`str-avoid-repeated-gsub`](references/str-avoid-repeated-gsub.md) - Chain gsub Calls into a Single Replacement
- [`str-symbol-for-identifiers`](references/str-symbol-for-identifiers.md) - Use Symbols for Identifiers and Hash Keys

### 5. Method & Dispatch (MEDIUM-HIGH)

- [`meth-avoid-method-missing-hot-paths`](references/meth-avoid-method-missing-hot-paths.md) - Avoid method_missing in Hot Paths
- [`meth-cache-method-references`](references/meth-cache-method-references.md) - Cache Method References for Repeated Calls
- [`meth-block-vs-proc`](references/meth-block-vs-proc.md) - Pass Blocks Directly Instead of Converting to Proc
- [`meth-avoid-dynamic-send`](references/meth-avoid-dynamic-send.md) - Avoid Dynamic send in Performance-Critical Code
- [`meth-reduce-method-chain-depth`](references/meth-reduce-method-chain-depth.md) - Reduce Method Chain Depth in Hot Loops

### 6. Data Structures (MEDIUM)

- [`ds-set-for-membership`](references/ds-set-for-membership.md) - Use Set for Membership Tests
- [`ds-struct-over-openstruct`](references/ds-struct-over-openstruct.md) - Use Struct Over OpenStruct
- [`ds-sort-by-over-sort`](references/ds-sort-by-over-sort.md) - Use sort_by Instead of sort with Block
- [`ds-array-preallocation`](references/ds-array-preallocation.md) - Preallocate Arrays When Size Is Known
- [`ds-hash-default-value`](references/ds-hash-default-value.md) - Use Hash Default Values Instead of Conditional Assignment

### 7. Concurrency (MEDIUM)

- [`conc-fiber-for-io`](references/conc-fiber-for-io.md) - Use Fibers for I/O-Bound Concurrency
- [`conc-thread-pool-sizing`](references/conc-thread-pool-sizing.md) - Size Thread Pools to Match Workload
- [`conc-ractor-cpu-bound`](references/conc-ractor-cpu-bound.md) - Use Ractors for CPU-Bound Parallelism
- [`conc-avoid-shared-mutable-state`](references/conc-avoid-shared-mutable-state.md) - Avoid Shared Mutable State Between Threads

### 8. Runtime & Configuration (LOW-MEDIUM)

- [`runtime-enable-yjit`](references/runtime-enable-yjit.md) - Enable YJIT for Production
- [`runtime-tune-gc-parameters`](references/runtime-tune-gc-parameters.md) - Tune GC Parameters for Your Workload
- [`runtime-frozen-string-literal-default`](references/runtime-frozen-string-literal-default.md) - Set Frozen String Literal as Project Default
- [`runtime-optimize-require`](references/runtime-optimize-require.md) - Optimize Require Load Order

## How to Use

Read individual reference files for detailed explanations and code examples:

- [Section definitions](references/_sections.md) - Category structure and impact levels
- [Rule template](assets/templates/_template.md) - Template for adding new rules

## Reference Files

| File | Description |
|------|-------------|
| [references/_sections.md](references/_sections.md) | Category definitions and ordering |
| [assets/templates/_template.md](assets/templates/_template.md) | Template for new rules |
| [metadata.json](metadata.json) | Version and reference information |

© pproenca · MIT · pproenca/dot-skills

Similar skills

All skills for Programming languages →

From the same set139

The whole set →
restful-hateoas restful-hateoas adds 47 guidelines for building Richardson Maturity Level 3 REST APIs with HATEOAS in Ruby on Rails projects. CX Codex +1 304installs ios-ui-refactor The ios-ui-refactor skill reviews existing SwiftUI screens and guides refactoring of hierarchy, transitions, animations, and visual systems for iOS 26 and Swift 6.2. CX Codex +1 299installs rails-dev Set of guidelines for Ruby on Rails development. Helps build clean controllers, optimize ActiveRecord queries, and configure caching. CX Codex +1 299installs swift-optimise The swift-optimise skill reviews Swift and SwiftUI performance across concurrency, rendering, and animation. Use it while profiling clinic modules. CX Codex +1 293installs swift-refactor swift-refactor is a Claude Code skill for reshaping existing SwiftUI code around a modular MVVM-C architecture. It applies to work on navigation, state, and app layer boundaries. CX Codex +1 289installs ios-testing ios-testing is a Claude Code skill for testing modular apps on iOS 26 and Swift 6.2. It guides unit, UI, and snapshot tests with protocol mocks and actor isolation. CX Codex +1 288installs dev-rfc dev-rfc guides coding agents through writing technical proposals, system design docs, and architecture overviews with structured templates. CX Codex +1 286installs swift-ui-architect swift-ui-architect enforces modular MVVM-C architecture for SwiftUI and Swift 6.2 across local SPM packages. Keeps Domain, Data, and Feature boundaries strict during code generation. CX Codex +1 283installs

Project sponsors

Companies that keep this analytics open