thibautbaissac/rails_ai_agents/concern-patterns
Claude Code and agent skill by thibautbaissac/rails_ai_agents
- community
Checking that the SKILL.md file is still in the repository.
Creates and refactors model and controller concerns for shared behavior. Use when extracting shared code, organizing models with horizontal concerns, DRYing up controllers, or when user mentions concerns, mixins, or modules. WHEN NOT: Logic used by only one model (keep in place), service object extraction (use model-patterns), or job organization (use job-patterns).
Install
npx vskill@latest install thibautbaissac/rails_ai_agents/concern-patternsSKILL.md
Concern Patterns (37signals)
Concerns for horizontal behavior, inheritance for vertical specialization.
Project knowledge
Tech Stack: Rails 8.2 (edge), ActiveSupport::Concern Location: app/models/[model]/ for model concerns, app/controllers/concerns/ for controller concerns
Commands:
Core principles
Each concern should be:
- Self-contained: All related code (associations, validations, scopes, methods) in one place
- Cohesive: Focused on one aspect (e.g.,
Closeable,Watchable,Searchable) - Composable: Models include multiple concerns to build up behavior
When to extract a concern
Extract when you see:
- Repeated associations across models
``ruby # Multiple models have: has_many :comments, as: :commentable # Extract to: app/models/concerns/commentable.rb ``
- Repeated state patterns
``ruby # Multiple models have close/reopen pattern # Extract to: Card::Closeable, Board::Publishable, etc. ``
- Repeated scopes
``ruby # Multiple models have: scope :recent, -> { order(created_at: :desc) } # Extract to: Timestampable concern ``
- Repeated controller patterns
``ruby # Multiple controllers load parent resource # Extract to: ParentScoped concern ``
Do NOT extract when:
- Code is used by only one model (YAGNI)
- You'd create a god concern with unrelated methods
- Logic should be in explicit model methods instead
Model concern structure
State management concern
Association concern
Behavior concern with class methods
Controller concern structure
Naming conventions
- Model concerns (adjectives):
Closeable,Publishable,Watchable,Assignable,Searchable,Eventable,Broadcastable,Readable,Positionable - Controller concerns (nouns):
CardScoped,BoardScoped,FilterScoped,CurrentRequest,CurrentTimezone,Authentication
Testing concerns
Test in isolation:
Refactoring workflow
- Identify the pattern -- Find duplicated code across models/controllers
- Name the concern -- Use an adjective describing the capability
- Create the file --
app/models/[model]/[concern].rborapp/controllers/concerns/[concern].rb - Move code -- Associations, validations, scopes, methods
- Include it -- Add
include ConcernNameto models/controllers - Write tests -- Test concern in isolation and in context
- Remove duplication -- Delete the old code from models/controllers
Files to create
- Concern file:
app/models/card/closeable.rborapp/controllers/concerns/card_scoped.rb - Model/Controller: Add
include ConcernName - Test file:
test/models/concerns/closeable_test.rb
See references/concern-catalog.md for the full catalog of concern types.
Boundaries
- Always: Extract repeated code into concerns, keep concerns focused on one aspect, include all related code (associations, scopes, methods), write tests, use
extend ActiveSupport::Concern, namespace model concerns under the model - Ask first: Before creating concerns that span multiple domains, before extracting concerns with complex dependencies, before modifying widely-used concerns
- Never: Create god concerns with too many responsibilities, use concerns to hide service objects, skip
included doblock for callbacks/associations, create concerns for one-off code
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.claude_37signals/skills/concern-patterns/SKILL.md
Popularity
- Repository stars
- 589
- Repository forks
- 67
- 7-day trend score
- 32
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/thibautbaissac/rails_ai_agents/concern-patterns)