Agent skill

Performance Optimization

by ThibautBaissac in ThibautBaissac/rails_ai_agents

Identifies and fixes Rails performance issues including N+1 queries, slow queries, and memory problems.

MITAuto-check: notesDevelopment

Install Performance Optimization

skills CLI
$ npx skills add ThibautBaissac/rails_ai_agents --skill performance-optimization -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ThibautBaissac/rails_ai_agents performance-optimization --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ThibautBaissac/rails_ai_agents.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/performance-optimization .claude/skills/performance-optimization && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
performance-optimization
GitHub stars
665
Token cost
~1.2k tokens
SKILL.md length
452 words
Files
4 (incl. references)
Skills in repo
19
Repo updated
First seen
Licence
MIT

At a glance

Identifies and fixes Rails performance issues including N+1 queries, slow queries, and memory problems.

  • Works in 4 steps: Detect -- Enable Bullet, run specs,… → Analyze -- Use explain(:analyze), check… → Fix -- Apply the appropriate pattern… → …
  • Optimizing queries
  • SKILL.md covers Overview, Quick Start, N+1 Query Detection and… and Query Optimization, plus 5 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Performance Optimization is an agent skill from ThibautBaissac/rails_ai_agents. Identifies and fixes Rails performance issues including N+1 queries, slow queries, and memory problems. Use when optimizing queries, fixing N+1 issues, improving response times, or when user mentions performance, slow, optimization, or Bullet gem. WHEN NOT: Caching-specific patterns (use caching-strategies), adding new features, or general code quality improvements unrelated to speed.

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/memory-and-profiling.md`, `references/n-plus-one.md` and `references/query-optimization.md`).

It sits in Development, covering Performance optimization, Query optimization and Backend development. The repository describes itself as: Specialized AI skills, agents, rules and hooks for modern Rails AI driven-development + Spec-Driven-Development kit + MCP. The licence is MIT.

When your agent uses it

  • Optimizing queries
  • Fixing N+1 issues
  • Improving response times
  • User mentions performance

Example prompts

  • “Use the performance-optimization skill to identify and fixes Rails performance issues including N+1 queries, slow queries, and memory problems”
  • “/performance-optimization”

Requirements

  • Pre-approved tools (allowed-tools): Read, Grep, Glob, Bash

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Detect -- Enable Bullet, run specs, check Rack Mini Profiler
  2. Analyze -- Use explain(:analyze), check slow query logs, profile memory
  3. Fix -- Apply the appropriate pattern from the reference files
  4. Verify -- Re-run specs, confirm query counts, check profiler

What it can do on your machine

Read from SKILL.md and the folder at commit 03622f2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Grep
    • Glob
    • Bash

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are ruby).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Performance Optimization loads about 1.2k tokens when it runs, and up to ~3.6k if it reads all its reference files. Until then it costs about 103 tokens; SKILL.md has 452 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~103
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~3.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Grep, Glob, Bash

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ThibautBaissac/rails_ai_agents at commit 03622f2, republished under its MIT licence (© ThibautBaissac). 452 words, ~1,209 tokens.

Download SKILL.mdSave it as .claude/skills/performance-optimization/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
performance-optimization
description
Identifies and fixes Rails performance issues including N+1 queries, slow queries, and memory problems. Use when optimizing queries, fixing N+1 issues, improving response times, or when user mentions performance, slow, optimization, or Bullet gem. WHEN NOT: Caching-specific patterns (use caching-strategies), adding new features, or general code quality improvements unrelated to speed.
allowed-tools
Read, Grep, Glob, Bash
context
fork
agent
Explore

Performance Optimization for Rails 8

Overview

Performance optimization focuses on:

  • N+1 query detection and prevention
  • Query optimization
  • Memory management
  • Response time improvements
  • Database indexing

Quick Start

ruby
# Gemfile
group :development, :test do
  gem 'bullet'           # N+1 detection
  gem 'rack-mini-profiler' # Request profiling
  gem 'memory_profiler'  # Memory analysis
end

N+1 Query Detection and Prevention

N+1 queries occur when code loads a collection then makes a separate query for each associated record. The Bullet gem detects these automatically. Fix them with eager loading via includes, preload, or eager_load.

Eager Loading Decision Table
MethodUse When
includesMost cases (Rails chooses best strategy)
preloadForcing separate queries, large datasets
eager_loadFiltering on association, need single query
joinsOnly need to filter, don't need association data

Key patterns: Bullet configuration, eager loading methods, scoped eager loading, counter caches, N+1 specs with query count assertions.

See references/n-plus-one.md for all code examples and patterns.

Query Optimization

Optimize queries by selecting only needed columns, using batch processing for large datasets, and choosing efficient existence checks.

Key Patterns
PatternBadGood
Column selectionUser.all.map(&:name)User.pluck(:name)
Large iterationsEvent.all.each { ... }Event.find_each { ... }
Existence checks.any? / .present?.exists?
Collection size.length (loads all).size (smart)
Database Indexing

Add indexes for: foreign keys, columns in WHERE/ORDER BY/JOIN clauses, and unique constraints. Use composite indexes for multi-column queries. Use partial indexes for filtered subsets.

Query Analysis

Use Event.where(...).explain(:analyze) to inspect query plans. Set up slow query logging via ActiveSupport::Notifications to catch queries over a threshold.

See references/query-optimization.md for all code examples and patterns.

Memory Management and Profiling

Use memory_profiler to detect memory issues. Prefer pluck over loading full AR objects, use find_each for streaming, and use update_all / in_batches for bulk operations.

Rack Mini Profiler

Provides per-request profiling in development. Shows query count, timing, and flamegraphs (with stackprof gem). Access via the profiler badge or ?pp=flamegraph.

See references/memory-and-profiling.md for all code examples and patterns.

Show full SKILL.md (165 more words)Show less

Quick Fixes Reference

ProblemSolution
N+1 on belongs_toincludes(:association)
N+1 on has_manyincludes(:association)
Slow COUNTAdd counter_cache
Loading all columnsUse select or pluck
Large dataset iterationUse find_each
Missing index on FKAdd index on *_id columns
Slow WHERE clauseAdd index on filtered column
Loading unused associationsRemove from includes

Performance Checklist

  • Bullet enabled in development/test
  • No N+1 queries in critical paths
  • Foreign keys have indexes
  • Counter caches for frequent counts
  • Eager loading in controllers
  • Batch processing for large datasets
  • Query analysis for slow endpoints

Workflow

  1. Detect -- Enable Bullet, run specs, check Rack Mini Profiler
  2. Analyze -- Use explain(:analyze), check slow query logs, profile memory
  3. Fix -- Apply the appropriate pattern from the reference files
  4. Verify -- Re-run specs, confirm query counts, check profiler

Reference Files

© ThibautBaissac, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in .agents/skills/performance-optimization of ThibautBaissac/rails_ai_agents.

  • SKILL.md
  • references/memory-and-profiling.md
  • references/n-plus-one.md
  • references/query-optimization.md

Open the folder on GitHubat commit 03622f2

Compare with similar skills

Performance Optimization next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Performance Optimization compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Performance Optimization this skillThibautBaissac/rails_ai_agents665—~1.2kAutomated safety check: NotesMIT
Performance CheckZeroDeng01/sublinkPro1.7k—~1.8kAutomated safety check: PassMIT
Performancekid-sid/claude-spellbook189—~3.8kAutomated safety check: PassMIT
Keybase RPC Log Analysiskeybase/client9.3k—~3kAutomated safety check: PassBSD-3-Clause
Groovy 5 Developer Guideapache/grails-core2.9k—~3kAutomated safety check: PassApache-2.0
WooCommerce Backend Conventionswoocommerce/woocommerce11k1 repos~614Automated safety check: PassCustom licence

Similar skills

  • Performance Check

    ZeroDeng01/sublinkPro

    Checklist for reviewing code changes that touch queries, APIs, rendering, caching or algorithms for performance, scalability and resource-usage problems.

    1.7k GitHub stars~1.8k tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • Performance

    kid-sid/claude-spellbook

    A skill your agent uses when diagnosing a slow HTTP endpoint or high-latency service — profiling, adding an application-level cache, offloading CPU-bound work to threads or workers, or defining a…

    189 GitHub stars~3.8k tokensUpdated 2 mo ago
    DatabasesAuto-check passed
  • Captures a clean Keybase service log and analyzes it for redundant, duplicated or looping RPCs, then checks whether a caching fix reduced the calls.

    9.3k GitHub stars~3k tokensUpdated today
    DevelopmentAuto-check passed
  • Groovy 5 Developer Guide

    apache/grails-core

    Guidance for Groovy 5 work in Grails projects: syntax, closures, traits, DSLs, metaprogramming, Spock tests, static compilation and Java 21 integration.

    2.9k GitHub stars~3k tokensUpdated today
    DevelopmentAuto-check passed
  • WooCommerce Backend Conventions

    woocommerce/woocommerce

    Guides agents writing or changing WooCommerce backend PHP so new classes, hooks and unit tests follow the project's conventions.

    11k GitHub starsUsed in 1 repo~614 tokens
    DevelopmentAuto-check passed
  • Searches synthetic workloads for cases where Caffeine's adaptive eviction policy falls short of its achievable hit rate, then classifies each gap by cause.

    18k GitHub stars~16k tokensUpdated yesterday
    DevelopmentAuto-check: notes

More from ThibautBaissac/rails_ai_agents

All 19 skills in this repo
  • Accessibility Review

    ThibautBaissac/rails_ai_agents

    Audits Rails application accessibility against WCAG 2.2 Level AA, detects violations with axe-core / Lighthouse / Pa11y, and reports remediation guidance for ERB views, ViewComponents, Stimulus…

    665 GitHub stars~2.9k tokensUpdated 4 mo ago
    Auto-check: notes
  • Action Cable Patterns

    ThibautBaissac/rails_ai_agents

    Implements real-time features with Action Cable and WebSockets.

    665 GitHub stars~1.2k tokensUpdated 4 mo ago
    Auto-check passed
  • Active Storage Setup

    ThibautBaissac/rails_ai_agents

    Configures Active Storage for file uploads with variants and direct uploads.

    665 GitHub stars~1.2k tokensUpdated 4 mo ago
    Auto-check passed
  • Authentication Flow

    ThibautBaissac/rails_ai_agents

    Implements authentication using Rails 8 built-in generator. An agent skill from ThibautBaissac/rails_ai_agents.

    665 GitHub stars~1.9k tokensUpdated 4 mo ago
    Auto-check passed
  • Caching Strategies

    ThibautBaissac/rails_ai_agents

    Implements Rails caching patterns for performance optimization.

    665 GitHub stars~1.4k tokensUpdated 4 mo ago
    Auto-check passed
  • I18n Patterns

    ThibautBaissac/rails_ai_agents

    Implements internationalization with Rails I18n for multi-language support.

    665 GitHub stars~1.4k tokensUpdated 4 mo ago
    Auto-check passed

Questions about Performance Optimization

What does Performance Optimization do?

Identifies and fixes Rails performance issues including N+1 queries, slow queries, and memory problems. Performance Optimization is an agent skill from ThibautBaissac/rails_ai_agents. Identifies and fixes Rails performance issues including N+1 queries, slow queries, and memory problems.

When should I use Performance Optimization?

Performance Optimization fits situations like: optimizing queries; fixing N+1 issues; improving response times; user mentions performance.

How do I install Performance Optimization in Claude Code?

Run `npx skills add ThibautBaissac/rails_ai_agents --skill performance-optimization -a claude-code`. Or copy the skill folder (.agents/skills/performance-optimization in ThibautBaissac/rails_ai_agents) into .claude/skills/performance-optimization in your project. Claude Code loads it when a task matches its description.

How do I install Performance Optimization in Codex?

Run `npx skills add ThibautBaissac/rails_ai_agents --skill performance-optimization -a codex`. Or copy the skill folder (.agents/skills/performance-optimization in ThibautBaissac/rails_ai_agents) into .agents/skills/performance-optimization in your project. Codex loads it when a task matches its description.

Can I use Performance Optimization in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ThibautBaissac/rails_ai_agents --skill performance-optimization -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/performance-optimization, .gemini/skills/performance-optimization, .github/skills/performance-optimization and .opencode/skills/performance-optimization in your project.

What does Performance Optimization need to run?

SKILL.md names no scripts, command-line tools or credentials: Performance Optimization is instructions for the agent only. Its frontmatter pre-approves these tools: Read, Grep, Glob, Bash.

Does Performance Optimization access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Performance Optimization safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Performance Optimization use?

Performance Optimization is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Performance Optimization use?

About 1.2k tokens (SKILL.md is roughly 4.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.4k tokens, read only when the agent opens those files.

What are the alternatives to Performance Optimization?

Skills that share tags, products or a category with Performance Optimization: Performance Check (ZeroDeng01/sublinkPro, 1.7k stars), Performance (kid-sid/claude-spellbook, 189 stars), Keybase RPC Log Analysis (keybase/client, 9.3k stars) and Groovy 5 Developer Guide (apache/grails-core, 2.9k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Performance Optimization?

ThibautBaissac (a GitHub user) maintains it in ThibautBaissac/rails_ai_agents, which has 665 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on June 1, 2026.

Source: ThibautBaissac/rails_ai_agents on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.