---
Finds Rails code patterns and best practices in your project using Ref, Grep, and reference patterns with WebFetch fallback. Auto-invoked when generating code to match project conventions, or manually triggered with specific pattern names like "service_objects" or "api_serialization".
/plugin marketplace add nbarthel/claudy/plugin install rails-workflow@claudyThis skill inherits all available tools. When active, it can use any tool Claude has access to.
reference.mdSearches the current Rails codebase for existing patterns and provides best-practice code examples. Helps agents write code consistent with project conventions.
Replaces: Manual codebase exploration and pattern recognition
Auto-invoked when agents need code examples:
Agent: "How is authentication implemented in this project?"
*invokes rails-pattern-finder pattern="authentication"*
Manual invocation:
@rails-pattern-finder pattern="service_objects"
@rails-pattern-finder pattern="api_serialization"
@rails-pattern-finder pattern="background_jobs"
See reference.md for complete pattern list. Common patterns:
service_objects - Service layer implementationform_objects - Form object patternquery_objects - Complex query encapsulationdecorators - Decorator/presenter patternpolicies - Authorization policies (Pundit)api_versioning - API version managementapi_serialization - JSON response formattingapi_authentication - Token/JWT authenticationapi_error_handling - Error response patternsscopes - Named scope usageconcerns - Model concern organizationpolymorphic_associations - Polymorphic patternsti - Single Table Inheritancedatabase_views - Database view usagefactory_usage - FactoryBot patternsrequest_specs - API request testingsystem_specs - System/feature testingshared_examples - RSpec shared examplesInput: pattern="service_objects"
Lookup: reference.md → search_paths, file_patterns, code_patterns
Tool: Grep
Pattern: "class.*Service$"
Glob: "app/services/**/*.rb"
Output: List of matching files
Tool: Read
Files: [top 3 matches by relevance]
Extract: Class structure, method signatures, usage patterns
## Pattern: Service Objects
### Found in Project (3 examples):
**1. UserRegistrationService** (app/services/user_registration_service.rb)
```ruby
class UserRegistrationService
def initialize(params)
@params = params
end
def call
user = User.create!(@params)
send_welcome_email(user)
user
end
private
def send_welcome_email(user)
UserMailer.welcome(user).deliver_later
end
end
2. PaymentProcessingService (app/services/payment_processing_service.rb) [Example code...]
[Fetch from reference.md or WebSearch]
Source: Project codebase + Rails best practices
## Reference Lookup
**Pattern → Search Strategy mapping** in `reference.md`:
```yaml
service_objects:
title: "Service Objects"
search_paths: ["app/services/**/*.rb"]
file_patterns: ["*_service.rb"]
code_patterns:
- "class \\w+Service"
- "def call"
best_practice_url: "https://example.com/rails-service-objects"
keywords: [service, business logic, call method]
api_serialization:
title: "API Serialization"
search_paths: ["app/serializers/**/*.rb", "app/blueprints/**/*.rb"]
file_patterns: ["*_serializer.rb", "*_blueprint.rb"]
code_patterns:
- "class \\w+Serializer"
- "ActiveModel::Serializer"
- "Blueprinter::Base"
keywords: [json, serializer, blueprint, jbuilder]
## Pattern: [Pattern Name]
### Found in Project ([N] examples):
**File**: [path/to/file.rb]
**Purpose**: [What this implementation does]
```ruby
[Code example from project]
Key characteristics:
Usage in project: [How this pattern is used - grep for usage examples]
### Pattern Not Found
```markdown
## Pattern: [Pattern Name] - Not found in project
**Searched**:
- app/services/**/*.rb
- app/lib/**/*.rb
**Best Practice Implementation**:
```ruby
[Example from reference.md or external source]
To implement in this project:
Similar patterns in project:
### Multiple Variants Found
```markdown
## Pattern: [Pattern Name] - Multiple variants found
This project uses [N] different approaches:
### Variant 1: [Approach Name] ([N] files)
[Example code...]
### Variant 2: [Approach Name] ([N] files)
[Example code...]
**Recommendation**: [Which variant to use for consistency]
Tools used (in order of preference):
reference.md pattern definitionsOptional dependencies:
Search strategies:
File-based search:
# Find files matching naming convention
glob: "app/services/*_service.rb"
Content-based search:
# Find class definitions
grep: "class \\w+Service$"
path: "app/services"
Usage search:
# Find where pattern is used
grep: "UserRegistrationService\\.new"
path: "app/controllers"
Relevance ranking:
Pattern not found:
⚠️ Pattern "[pattern]" not found in project
**Searched**:
- [paths searched]
**Options**:
1. View best practice example (from reference.md)
2. Search for similar pattern: [suggestions]
3. Implement from scratch using best practices
Invalid pattern name:
❌ Unknown pattern: "[pattern]"
Available patterns:
- service_objects
- form_objects
- query_objects
[...from reference.md...]
Try: @rails-pattern-finder pattern="[one of above]"
Ambiguous results:
⚠️ Multiple pattern variants found for "[pattern]"
Please review all variants and choose one for consistency.
[List all variants found...]
Auto-invoked by:
Workflow:
@rails-pattern-finder pattern="service_objects" compare_with="form_objects"
→ Shows differences and use cases for each
@rails-pattern-finder detect_conventions
→ Analyzes codebase and reports common patterns
@rails-pattern-finder anti_patterns
→ Searches for common Rails anti-patterns in codebase
@rails-pattern-finder pattern="service_objects" include_tests=true
→ Shows both implementation and test examples
service_objects - Business logic encapsulationform_objects - Form handlingquery_objects - Query encapsulationbuilder_pattern - Object constructionconcerns - Module organizationdecorators - Presentation logicadapters - External API integrationrepositories - Data access layerobservers - Event handlingstate_machines - State managementstrategies - Algorithm selectioncommands - Action encapsulationsti - Single Table Inheritancepolymorphic_associations - Flexible relationshipscustom_validators - Validation logicbackground_jobs - Async processingTest cases:
reference.md include search strategiesThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.