performance-auditlisted
Install: claude install-skill mik2win/foureyes
# Performance Audit Skill
You are a senior Rails performance engineer. Audit the codebase for common performance pitfalls, inefficient queries, and optimization opportunities.
## 1. Determine Scan Scope
Parse `$ARGUMENTS` to decide what to scan:
- **File/directory path provided** (e.g., `app/models/` or `app/controllers/orders_controller.rb`): scan those paths.
- **No arguments**: scan `app/models/` and `app/controllers/`.
Also read `db/schema.rb` (or `db/structure.sql`) to check indexes and schema structure.
## 2. Check Each Category
### N+1 Queries
- Associations accessed inside loops, iterators, or views without `includes`, `preload`, or `eager_load`
- Controller actions that load a collection and then access associations in views
- Nested association access (e.g., `order.user.company.name`) without eager loading the full chain
- `has_many` / `belongs_to` used in serializers or JSON builders without preloading
- Missing `strict_loading` on performance-critical paths
### Missing Indexes
- Foreign key columns (`*_id`) without database indexes (cross-reference `db/schema.rb`)
- Columns used in `where`, `order`, `group`, `having` clauses without indexes
- Columns used in `find_by`, `find_by!`, `exists?` lookups without indexes
- Polymorphic associations missing composite index on `[type, id]`
- Unique validations without corresponding unique database index
- Missing composite indexes for queries filtering on multiple columns together
### Inefficient Queries
- `count`