install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/ruby-optimise" ~/.claude/skills/comeonoliver-skillshub-ruby-optimise && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/ruby-optimise/SKILL.mdsource content
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 | |
| 2 | Collection & Enumeration | CRITICAL | |
| 3 | I/O & Database | HIGH | |
| 4 | String Handling | HIGH | |
| 5 | Method & Dispatch | MEDIUM-HIGH | |
| 6 | Data Structures | MEDIUM | |
| 7 | Concurrency | MEDIUM | |
| 8 | Runtime & Configuration | LOW-MEDIUM | |
Quick Reference
1. Object Allocation (CRITICAL)
- Avoid Unnecessary Object Duplicationalloc-avoid-unnecessary-dup
- Freeze Constant Collectionsalloc-freeze-constants
- Use Lazy Initialization for Expensive Objectsalloc-lazy-initialization
- Avoid Temporary Array Creationalloc-avoid-temp-arrays
- Reuse Buffers in Loopsalloc-reuse-buffers
- Avoid Repeated Computation in Hot Pathsalloc-avoid-implicit-conversions
2. Collection & Enumeration (CRITICAL)
- Use Single-Pass Collection Transformsenum-single-pass
- Use Lazy Enumerators for Large Collectionsenum-lazy-large-collections
- Use flat_map Instead of map.flattenenum-flat-map
- Use each_with_object Over inject for Building Collectionsenum-each-with-object
- Avoid Recomputing Collection Size in Conditionsenum-avoid-count-in-loops
- Use each_slice for Batch Processingenum-chunk-batch-processing
3. I/O & Database (HIGH)
- Eager Load ActiveRecord Associationsio-eager-load-associations
- Select Only Needed Columnsio-select-only-needed-columns
- Use find_each for Large Record Setsio-batch-find-each
- Avoid Database Queries Inside Loopsio-avoid-queries-in-loops
- Stream Large Files Line by Lineio-stream-large-files
- Size Connection Pools to Match Thread Countio-connection-pool-sizing
- Cache Expensive Database Resultsio-cache-expensive-queries
4. String Handling (HIGH)
- Enable Frozen String Literalsstr-frozen-literals
- Use Shovel Operator for String Buildingstr-shovel-over-plus
- Use String Interpolation Over Concatenationstr-interpolation-over-concatenation
- Chain gsub Calls into a Single Replacementstr-avoid-repeated-gsub
- Use Symbols for Identifiers and Hash Keysstr-symbol-for-identifiers
5. Method & Dispatch (MEDIUM-HIGH)
- Avoid method_missing in Hot Pathsmeth-avoid-method-missing-hot-paths
- Cache Method References for Repeated Callsmeth-cache-method-references
- Pass Blocks Directly Instead of Converting to Procmeth-block-vs-proc
- Avoid Dynamic send in Performance-Critical Codemeth-avoid-dynamic-send
- Reduce Method Chain Depth in Hot Loopsmeth-reduce-method-chain-depth
6. Data Structures (MEDIUM)
- Use Set for Membership Testsds-set-for-membership
- Use Struct Over OpenStructds-struct-over-openstruct
- Use sort_by Instead of sort with Blockds-sort-by-over-sort
- Preallocate Arrays When Size Is Knownds-array-preallocation
- Use Hash Default Values Instead of Conditional Assignmentds-hash-default-value
7. Concurrency (MEDIUM)
- Use Fibers for I/O-Bound Concurrencyconc-fiber-for-io
- Size Thread Pools to Match Workloadconc-thread-pool-sizing
- Use Ractors for CPU-Bound Parallelismconc-ractor-cpu-bound
- Avoid Shared Mutable State Between Threadsconc-avoid-shared-mutable-state
8. Runtime & Configuration (LOW-MEDIUM)
- Enable YJIT for Productionruntime-enable-yjit
- Tune GC Parameters for Your Workloadruntime-tune-gc-parameters
- Set Frozen String Literal as Project Defaultruntime-frozen-string-literal-default
- Optimize Require Load Orderruntime-optimize-require
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |