optimize-performance

optimize-performance is a skill for Claude Code, Codex from igmarin/rails-agent-skills. It costs 45 tokens per session (904 once invoked), scanned A, original, MIT.

A set of rules for finding and fixing slow database queries and other performance bottlenecks in a Ruby on Rails application. It uses measurements such as query counts, endpoint timings, and database query plans.

In plain words
What is it for?
Use it to investigate N+1 queries, slow requests, missing indexes, caching issues, and inefficient database access. It helps document the baseline, cause, test, change, and verification.
Why use it?
It prevents changes based on guesses by requiring a baseline measurement and a regression test first. It also checks that database changes improve the query plan.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to investigate N+1 queries, slow requests, missing indexes, caching issues, and inefficient database access. It helps document the baseline, cause, test, change, and verification.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/igmarin/rails-agent-skills/optimize-performance
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.

Any agent
npx skills add igmarin/rails-agent-skills --skill optimize-performance
Clone the repo
git clone --depth 1 https://github.com/igmarin/rails-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for optimize-performance

README.md
[![agentmods](https://agentmods.dev/badge/skills/igmarin/rails-agent-skills/optimize-performance.svg)](https://agentmods.dev/skills/igmarin/rails-agent-skills/optimize-performance)
Your own site
<a href="https://agentmods.dev/skills/igmarin/rails-agent-skills/optimize-performance"><img src="https://agentmods.dev/badge/skills/igmarin/rails-agent-skills/optimize-performance.svg" alt="Measured on agentmods" height="20"></a>
Per session 45 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 904 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00045 $0.00904
Opus 5 $0.00023 $0.00452
Sonnet 5 $0.00009 $0.00181
Haiku 4.5 $0.00005 $0.00090

Measured 8d ago against content hash 87557aa14341, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

optimize-performance 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 8d ago.

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.

skills/optimize-performance/SKILL.md · 120 lines

How it starts

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

Optimize Performance

Identify and fix performance bottlenecks in Rails applications.

Quick Reference

Tool Use
bullet N+1 detection in development
rack-mini-profiler Endpoint timing breakdown
EXPLAIN ANALYZE Query plan analysis

HARD-GATE

NEVER optimize without a baseline measurement
ALWAYS write a regression spec before optimizing (query count assertion)
ALWAYS verify with EXPLAIN ANALYZE for database changes

NEVER write the report as "I applied includes(:author), then wrote a spec
to lock it in." The spec MUST be written and shown failing BEFORE the fix
appears in your output. Reordering for narrative flow fails the audit even
when the underlying work was correct.

Output Style

When completing a performance optimization, output MUST follow this seven-step report order. Each step must appear in output:

# Performance Optimization — [Description]

## 1. Baseline
<N> queries for <endpoint/action> — source: <log line / profiler output>

## 2. Bottleneck
<N+1 on association X / missing index on column Y> — tool: <bullet / rack-mini-profiler / EXPLAIN ANALYZE>

## 3. Regression Spec — RED
`make_database_queries(count: <N>)` at <path>:<line> — failure: expected <M>, got <N>

## 4. Fix
<path>:<line> — <includes(:association) / add_index / cache block>

## 5. Regression Spec — GREEN
Spec passes ✓ (<M> queries)

## 6. EXPLAIN ANALYZE
Before: Seq Scan, actual time=<X>ms → After: Index Scan, actual time=<Y>ms

## 7. Quantified Improvement
Queries: <N> → <M> | p95: <X>ms → <Y>ms

Language: English unless explicitly requested otherwise.

Extended Resources

Less-Obvious Optimization

# Use counter_cache to avoid COUNT queries in loops
# In migration: add_column :users, :posts_count, :integer, default: 0
# In Post model: belongs_to :user, counter_cache: true
user.posts_count  # no extra query

Regression Spec (Query Count Assertion)

RSpec.describe "Post index performance" do
  it "loads posts with authors in a fixed number of queries" do
    create_list(:post, 10, :with_author)

    expect do
      get posts_path
    end.to make_database_queries(count: 2) # 1 posts query + 1 authors query
  end
end

Use the db-query-matchers gem or a custom make_database_queries matcher.

Read the full file on GitHub · 120 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 8d ago First seen · 120 lines · 45 tokens per session scan A 87557aa14341

Subscribe to this mod's changes

optimize-performance is a skill published in the GitHub repository igmarin/rails-agent-skills (24 stars, last pushed 17d ago), licensed MIT. It adds 45 tokens to every session and 904 once invoked, about $0.0002 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.

Related

Other skills, from other repositories

fix-failing-tests

Diagnose a failing test in the googleapis/mcp-toolbox repo and land a fix by reasoning from the actual error: read the failure, reproduce it, shrink it until the cause is forced into the open, then fix the cause. Use this whenever a test or CI job is red, a build breaks after a change, many packages fail at once, or a…

googleapis/mcp-toolbox · 87 tokens

triage-issues

Triage GitHub issues in the googleapis/mcp-toolbox repo: propose the correct labels (type / priority / product / status), check for duplicates, verify a bug has enough info to act on, and draft a triage comment. Use whenever a maintainer asks you to triage, label, categorize, prioritize, or "look at" an issue (or a…

googleapis/mcp-toolbox · 164 tokens

postgresql-indexing

PostgreSQL indexing best practices for Prowler: index design, partial indexes, partitioned table indexing, EXPLAIN ANALYZE validation, concurrent operations, monitoring, and maintenance. Trigger: When creating or modifying PostgreSQL indexes, analyzing query performance with EXPLAIN, debugging slow queries, reviewing…

prowler-cloud/prowler · 108 tokens

graphjin-eval

Create, extend, run, baseline, and diagnose GraphJin agent evaluations through the graphjin eval CLI.

dosco/graphjin · 27 tokens

axiom-audit-grdb-performance

Use when the user mentions GRDB performance review, slow GRDB queries, app-group database setup audit, a ValueObservation that stopped updating, or pre-release GRDB scan.

CharlesWiltgen/Axiom · 43 tokens

django-perf-review

Django performance code review. Use when asked to "review Django performance", "find N+1 queries", "optimize Django", "check queryset performance", "database performance", "Django ORM issues", or audit Django code for performance problems.

getsentry/skills · 55 tokens