From ruby-rails
Comprehensive PostgreSQL configuration and usage analysis for Rails applications. Use when Claude Code needs to analyze a Rails codebase for database performance issues, optimization opportunities, or best practice violations. Detects N+1 queries, missing indexes, suboptimal database configurations, anti-patterns, and provides actionable recommendations. Ideal for performance audits, optimization tasks, or when users ask to "analyze the database", "check for N+1 queries", "optimize PostgreSQL", "review database performance", or "suggest database improvements".
npx claudepluginhub el-feo/ai-context --plugin ruby-railsThis skill uses the workspace's default tool permissions.
Analyze Rails applications for PostgreSQL performance issues and provide actionable optimization recommendations based on "High Performance PostgreSQL for Rails" best practices.
Generates design tokens/docs from CSS/Tailwind/styled-components codebases, audits visual consistency across 10 dimensions, detects AI slop in UI.
Records polished WebM UI demo videos of web apps using Playwright with cursor overlay, natural pacing, and three-phase scripting. Activates for demo, walkthrough, screen recording, or tutorial requests.
Delivers idiomatic Kotlin patterns for null safety, immutability, sealed classes, coroutines, Flows, extensions, DSL builders, and Gradle DSL. Use when writing, reviewing, refactoring, or designing Kotlin code.
Analyze Rails applications for PostgreSQL performance issues and provide actionable optimization recommendations based on "High Performance PostgreSQL for Rails" best practices.
Run from the Rails application root directory:
ruby scripts/analyze_n_plus_one.rb
Detects potential N+1 query issues by analyzing:
includes, preload, or eager_load callsruby scripts/analyze_indexes.rb
Identifies indexing opportunities:
ruby scripts/analyze_config.rb
Reviews database.yml for:
Clarify what the user wants to analyze: full performance audit, specific issue (slow queries, N+1 problems), configuration review, or schema optimization.
# For comprehensive analysis, run all three
ruby scripts/analyze_n_plus_one.rb
ruby scripts/analyze_indexes.rb
ruby scripts/analyze_config.rb
Script output categorizes issues by severity:
Create a prioritized list of actionable recommendations:
For index and schema recommendations, provide ready-to-use migration code. Use algorithm: :concurrently for production migrations to avoid locking tables.
class AddPerformanceIndexes < ActiveRecord::Migration[7.0]
disable_ddl_transaction!
def change
add_index :posts, :user_id, algorithm: :concurrently
add_index :users, :active, where: "active = false", algorithm: :concurrently
add_index :orders, [:status, :created_at], algorithm: :concurrently
end
end
Load these references when users need deeper understanding:
references/performance_guide.md — comprehensive best practices (indexes, queries, config, schema design, monitoring)references/anti_patterns.md — 25 common mistakes organized by category (queries, indexes, schema, config, transactions)For deeper analysis beyond the scripts, manually review:
rails c to run EXPLAIN ANALYZE on slow queries, check for sequential scans on large tablesfind_each instead of each)These analysis scripts use static analysis. They may produce false positives (flagging non-issues) or false negatives (missing runtime-only issues). Always recommend testing fixes in staging and using EXPLAIN ANALYZE to verify.
Suggest for ongoing monitoring: PgHero (dashboard), pg_stat_statements (query stats), Bullet gem (runtime N+1 detection), Rails query logging (development visibility).