optimize-performance
Skill26 starsChanged 4 months agoMITView on GitHub
Use when investigating N+1s, slow queries, caching, or query plans in Rails. Profile before changing code. Trigger words: N+1, slow, performance, caching, EXPLAIN.
7 other projects use a version of this.
Adopted by
Most recently taken up by
- wollemiahq/skillstheir own version, first seen Nov 1, 2026
- VelimirMueller/ai-development-skillstheir own version, first seen Oct 25, 2026
- textura-agency/next16-claude-startertheir own version, first seen Oct 14, 2026
- VelimirMueller/claude-skillstheir own version, first seen Oct 11, 2026
- maksimzayats/diwiretheir own version, first seen Oct 8, 2026
- emaraschio/cursor-commandstheir own version, first seen Aug 7, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- maksimzayats/diwire★ 254same name
- textura-agency/next16-claude-starter★ 141same name
- emaraschio/cursor-commands★ 9same name
- VelimirMueller/ai-development-skills★ 7same name
- VelimirMueller/claude-skills★ 7same name
- wollemiahq/skills★ 2same name
- gologo13/agent-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository32 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- apply-code-conventionsSkill
- apply-stack-conventionsSkill
- code-reviewSkill
- create-engine-installerSkill
- create-engineSkill
- document-engineSkill
- extract-engineSkill
- generate-api-collectionSkill
- implement-authorizationSkill
- implement-background-jobSkill
- implement-graphqlSkill
- implement-hotwireSkill
- load-contextSkill
- plan-testsSkill
- rails-featureSkill
- rails-maintenanceSkill
- rails-reviewSkill
- refactor-codeSkill
- release-engineSkill
- review-architectureSkill
- review-engineSkill
- review-migrationSkill
- security-checkSkill
- seed-databaseSkill
- setup-environmentSkill
- test-engineSkill
- test-serviceSkill
- upgrade-engineSkill
- version-apiSkill
- write-testsSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 42
When completing a performance optimization, output MUST follow this seven-step report order.
- Very specific: line 93
Use the db-query-matchers gem or a custom make_database_queries matcher.
- Very specific: line 95
Run directly in rails dbconsole (PostgreSQL) after applying an index or query change:
“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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>msLanguage: 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 queryRegression 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
endUse the db-query-matchers gem or a custom make_database_queries matcher.
Run directly in rails dbconsole (PostgreSQL) after applying an index or query change:
EXPLAIN ANALYZE
SELECT posts.*, users.name
FROM posts
INNER JOIN users ON users.id = posts.author_id
WHERE posts.published = true;Reference Files and External Links
Load these files only when their specific content is needed:
- references/tools.md — Use when you need detailed Bullet, rack-mini-profiler, or EXPLAIN ANALYZE configuration and installation steps
External references:
Integration
| Skill | When to chain |
| write-tests | For regression specs |
| review-migration | When adding an index |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

