What problem does it solve?
AI coding agents routinely generate non-idiomatic, buggy ActiveRecord code that violates core Ruby on Rails conventions, leading to performance bottlenecks like N+1 queries, data integrity issues from misused callbacks, and unmaintainable model code that deviates from senior Rails developer standards.
Core Features & Use Cases
- Pattern Guidance: Covers 12 core ActiveRecord pattern pairs (before/after) for associations, scopes, callbacks, eager loading, batch processing, counter caches, and inheritance type selection.
- Decision Matrices: Provides quick-reference tables to choose the correct method for single-record lookups, boolean checks, eager loading strategies, and association cleanup.
- Anti-Pattern Prevention: Explicitly calls out common AI-generated mistakes like non-deterministic
where.first usage, after_save for side effects, and default_scope for soft deletes.
- Use Cases: Use when writing new Rails models, reviewing existing model code, debugging slow query performance, fixing callback race conditions, or selecting the right association type for a new domain relationship.
Quick Start
Use the activerecord-patterns skill to write, review, or fix ActiveRecord model code in your Ruby on Rails project to align with senior Rails developer best practices and avoid common performance and data integrity bugs.