Use when reviewing Rails code for quality issues, refactoring problematic code, or encountering symptoms like fat controllers, god models, callback chains with side effects, N+1 queries, logic-heavy views, or non-idempotent background jobs. Covers controller, model, query, view, job, and migration anti-patterns with bad/good examples and fixes.
Identifies and fixes common Rails code quality issues across controllers, models, queries, views, jobs, and migrations.
npx claudepluginhub chaserx/cpcThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/controller-antipatterns.mdreferences/job-antipatterns.mdreferences/migration-antipatterns.mdreferences/model-antipatterns.mdreferences/query-antipatterns.mdreferences/view-antipatterns.mdA guide to recognizing and fixing common anti-patterns in Rails applications. Each reference file shows what to avoid (Bad), explains why it's problematic, and demonstrates the correct approach (Good).
Business logic in controllers, non-RESTful route proliferation, and synchronous external calls in the request cycle.
service-patterns skill).For detailed Bad/Good examples, see references/controller-antipatterns.md.
God objects, callback-driven side effects, invisible query scoping, and misused concerns.
default_scope Abuse — Use explicit named scopes instead of default_scope, which applies silently to every query.For detailed Bad/Good examples, see references/model-antipatterns.md.
Tight coupling through deep object graphs, inefficient Ruby-side processing, and N+1 queries.
delegate instead of reaching deep into object graphs.active-record-patterns skill.includes, preload, or eager_load. See rails-performance skill.For detailed Bad/Good examples, see references/query-antipatterns.md.
Logic-heavy templates, hidden partial dependencies, nil gymnastics, and misuse of Turbo/Stimulus. See hotwire-patterns skill for correct Hotwire patterns.
DOMContentLoaded listeners.For detailed Bad/Good examples, see references/view-antipatterns.md.
Non-idempotent jobs, race conditions from enqueueing inside transactions, and serialization issues.
after_commit.For detailed Bad/Good examples, see references/job-antipatterns.md.
Fragile migrations that mix concerns or depend on application code.
For detailed Bad/Good examples, see references/migration-antipatterns.md.
| Anti-Pattern | Fix |
|---|---|
| Fat controller | Extract to service object |
| Non-RESTful actions | Model as nested resources |
| Blocking external calls | Move to background jobs |
| God object | Extract concerns, services, and query objects |
| Callback hell | Use service objects for orchestration |
default_scope | Use explicit named scopes |
| Concerns as junk drawers | Keep concerns small and cohesive |
| Law of Demeter violations | Use delegate |
| Ruby where SQL suffices | Use ActiveRecord query methods |
| N+1 queries | Use includes, preload, or eager_load |
| Logic-heavy views | Extract to helpers or presenters |
| Instance vars in partials | Use strict locals |
| Nil gymnastics | Null Object pattern |
| Streams when Frames suffice | Use Turbo Frames for in-place updates |
| Stimulus for everything | Let Turbo Drive and Frames handle navigation |
DOMContentLoaded listeners | Use Stimulus controllers |
| Non-idempotent jobs | Add guard clauses and idempotency keys |
| Enqueueing inside transactions | Enqueue after commit |
| Complex objects as job args | Pass primitive IDs only |
| Mixed schema/data migrations | Separate into distinct migrations |
| Model classes in migrations | Use raw SQL or inline stubs |
For detailed Bad/Good code examples organized by category:
references/controller-antipatterns.md — Fat controllers, non-RESTful actions, blocking callsreferences/model-antipatterns.md — God objects, callbacks, default_scope, concernsreferences/query-antipatterns.md — Law of Demeter, Ruby vs SQL, N+1 queriesreferences/view-antipatterns.md — Logic-heavy views, partials, nil handling, Hotwire misusereferences/job-antipatterns.md — Idempotency, transaction timing, serializationreferences/migration-antipatterns.md — Schema/data mixing, model referencesservice-patterns — Service object, form object, and interactor patternshotwire-patterns — Correct Turbo Frames, Turbo Streams, and Stimulus patternsactive-record-patterns — Query and association patternsrails-performance — Eager loading and optimization strategiesActivates when the user asks about AI prompts, needs prompt templates, wants to search for prompts, or mentions prompts.chat. Use for discovering, retrieving, and improving prompts.
Search, retrieve, and install Agent Skills from the prompts.chat registry using MCP tools. Use when the user asks to find skills, browse skill catalogs, install a skill for Claude, or extend Claude's capabilities with reusable AI agent components.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.