cqrs-patterns
Skill93 starsChanged 8 days agoMITView on GitHub
CQRS architecture conventions and patterns for rails_error_dashboard
In this repository11 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- add-breadcrumb-pageSkill
- chaosSkill
- demo-updateSkill
- host-app-safetySkill
- new-featureSkill
- release-rulesSkill
- releaseSkill
- roadmap-statusSkill
- safety-checkSkill
- testSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Purpose: Create, update, or delete records.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CQRS Architecture Patterns
This gem uses strict Command/Query/Service separation. All new features MUST follow these patterns.
Directory Structure
lib/rails_error_dashboard/
├── commands/ # Write operations (create, update, delete)
├── queries/ # Read operations (fetch, filter, aggregate)
├── services/ # Pure algorithms (parse, calculate, detect)Commands — Write Operations
Location: lib/rails_error_dashboard/commands/
Purpose: Create, update, or delete records. Never return data for display.
Pattern
module RailsErrorDashboard
module Commands
class DoSomething
def self.call(...)
new(...).call
end
def initialize(params)
@param = params
end
def call
# Write to database
# Dispatch notifications via ActiveSupport::Notifications
# Return the record (but callers shouldn't use it for display)
rescue => e
Rails.logger.error("[RailsErrorDashboard] DoSomething failed: #{e.message}")
nil
end
end
end
endExisting Commands
LogError— main error capture write pathFindOrIncrementError— deduplication + increment occurrence countFindOrCreateApplication— multi-app supportResolveError,UpdateErrorStatus,SnoozeError,UnsnoozeError— workflow stateAssignError,UnassignError— assignment managementUpdateErrorPriority— priority changesAddErrorComment— discussion threadBatchResolveErrors,BatchDeleteErrors— bulk operationsIncrementCascadeDetection,CalculateCascadeProbability— cascade tracking
Queries — Read Operations
Location: lib/rails_error_dashboard/queries/
Purpose: Fetch and filter data for display. Never mutate state.
Pattern
module RailsErrorDashboard
module Queries
class FetchSomething
def self.call(...)
new(...).call
end
def initialize(params)
@param = params
end
def call
# Build ActiveRecord query
# Apply filters
# Return data (relation, hash, or array)
end
end
end
endExisting Queries
ErrorsList— main error listing with 15+ filters, pagination, sortingDashboardStats— overview metrics (counts, rates, MTTR)AnalyticsStats— time-series data for chartsBaselineStats— anomaly detection baselinesSimilarErrors— similarity matchingRecurringIssues— repeat offender detectionMttrStats— mean time to resolutionErrorCascades— parent-child cascade chainsErrorCorrelation— co-occurring error pairsPlatformComparison— browser/OS breakdownFilterOptions— available filter values for dropdownsCriticalAlerts— threshold-based alertsDeprecationWarnings— Rails deprecation aggregatesNPlusOneSummary— N+1 query pattern aggregatesCacheHealthSummary— cache miss/hit aggregates
Services — Pure Algorithms
Location: lib/rails_error_dashboard/services/
Purpose: Computation, parsing, transformation. No direct DB access — receive data as params, return computed results.
Pattern
module RailsErrorDashboard
module Services
class CalculateSomething
def self.call(...)
new(...).call
end
def initialize(data)
@data = data
end
def call
# Pure computation on @data
# Return result
end
end
end
endExisting Services (a sample; 76 files including storm_protection/, so list the directory for all of them)
- Parsing:
BacktraceParser,BacktraceProcessor - Detection:
CascadeDetector,PatternDetector,PlatformDetector - Calculation:
SimilarityCalculator,PearsonCorrelation,BaselineCalculator,BaselineAlertThrottler - Normalization:
ErrorNormalizer(smart deduplication — UUIDs, timestamps, IDs, tokens) - Source:
SourceCodeReader,GitBlameReader,GithubLinkGenerator - Notifications:
ErrorBroadcaster,ErrorNotificationDispatcher - Payload builders:
SlackPayloadBuilder,DiscordPayloadBuilder,TelegramPayloadBuilder,PagerdutyPayloadBuilder,WebhookPayloadBuilder,BaselineAlertPayloadBuilder - Issue trackers:
IssueTrackerClientand itsGitHubIssueClient,GitLabIssueClient,CodebergIssueClient,LinearIssueClient;IssueBodyFormatter - Breadcrumbs:
BreadcrumbCollector(ring buffer, thread-local) - Health:
SystemHealthSnapshot(GC.stat, connection pool, threads) - Data:
SensitiveDataFilter,ExceptionFilter,CauseChainExtractor - Storm protection:
StormProtection::Gate,CircuitBreaker,CountBuffer,FingerprintBuckets
Naming Conventions
| Layer | Verb Style | Examples |
| Commands | Action verb | LogError, ResolveError, BatchDelete |
| Queries | Noun/adjective | ErrorsList, DashboardStats, SimilarErrors |
| Services | Algorithm name | ErrorNormalizer, SimilarityCalculator, BacktraceParser |
Spec File Locations
spec/
├── commands/rails_error_dashboard/ # Command specs
├── queries/rails_error_dashboard/ # Query specs
├── services/rails_error_dashboard/ # Service specs
├── models/ # Model specs
├── jobs/ # Job specs
├── integration/ # Cross-layer integration tests
├── system/ # Capybara browser testsCommon Violations to Avoid
- Controller doing
ErrorLog.create(...)instead ofCommands::LogError.call(...) - Query that updates a counter (use a Command for the write)
- Service that does
ErrorLog.where(...)(pass data in, don't query inside) - Command returning complex data for view rendering (just write, let a Query read)
- Business logic in models beyond simple validations/scopes
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

