skills/rails-audit/SKILL.md
Perform comprehensive code audits of Ruby on Rails applications based on thoughtbot best practices. Use this skill when the user requests a code audit, code review, quality assessment, or analysis of a Rails application. The skill analyzes the entire codebase focusing on testing practices (RSpec), security vulnerabilities, code design (skinny controllers, domain models, PORO with ActiveModel), Rails conventions, database optimization, and Ruby best practices. Outputs a detailed markdown audit report grouped by category (Testing, Security, Models, Controllers, Code Design, Views) with severity levels (Critical, High, Medium, Low) within each category.
npx skillsauth add rolemodel/rolemodel-skills rails-auditInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Perform comprehensive Ruby on Rails application audits based on thoughtbot's Ruby Science and Testing Rails best practices, with emphasis on Plain Old Ruby Objects (POROs) over Service Objects.
Ask user or infer from request:
app/, spec/ or test/, config/, db/, lib/Check for .rails-audit-ignore.yml at the project root — see references/ignore_file.md for format and matching rules.
Ask the user both questions upfront in a single AskUserQuestion so they can decide once:
Based on the user's choice, spawn the accepted subagents in parallel using the Task tool. Both can run at the same time because SimpleCov modifies the test helper while RubyCritic only reads source files — they don't conflict.
SimpleCov subagent (if accepted):
Read the file
agents/simplecov_agent.mdand follow all steps described in it. The audit scope is: {{SCOPE from Step 1}}. Return the coverage data in the output format specified in that file.
RubyCritic subagent (if accepted):
Read the file
agents/rubycritic_agent.mdand follow all steps described in it. The audit scope is: {{SCOPE from Step 1}}. Return the code quality data in the output format specified in that file.
After both finish, clean up: rm -rf coverage/ and/or rm -rf tmp/rubycritic/ as applicable.
Interpreting responses:
COVERAGE_FAILED / RUBYCRITIC_FAILED: no data for that tool — use estimation mode (SimpleCov) or omit the section (RubyCritic). Note the failure reason in the report.COVERAGE_DATA: parse and keep in context for Steps 4 and 5 (overall coverage, per-directory breakdowns, lowest-coverage files, zero-coverage files).RUBYCRITIC_DATA: parse and keep in context for Steps 4 and 5 (overall score, per-directory ratings, worst-rated files, top smells, most complex files).Before analyzing, read the relevant reference files:
references/code_smells.md - Code smell patterns to identifyreferences/ruby_testing_guidelines.md - Ruby testing best practicesreferences/javascript_testing_guidelines.md - Javascript testing best practicesreferences/poro_patterns.md - PORO and ActiveModel patternsreferences/security_checklist.md - Security vulnerability patternsreferences/rails_antipatterns.md - Rails-specific antipatterns (external services, migrations, performance)references/stimulus_patterns.md - Stimulus controller patterns and anti-patterns (betterstimulus.com)references/javascript_code_smells.md - JavaScript/TypeScript code smells (callback hell, god modules, magic numbers, etc.)references/javascript_antipatterns.md - JavaScript/TypeScript runtime anti-patterns (memory leaks, eval, innerHTML, layout thrashing, etc.)disconnect() cleanupapp/javascript/, app/assets/javascripts/) — callback hell, unhandled promise rejections, == vs ===, var usage, magic numbers/strings, long functions, god modules; see references/javascript_code_smells.mdeval() (Critical), innerHTML with unsanitized content (Critical), layout thrashing, swallowed errors; see references/javascript_antipatterns.mdCreate RAILS_AUDIT_REPORT.md in project root with structure defined in references/report_template.md.
When SimpleCov coverage data was collected in Step 2, use the SimpleCov variant of the Testing section in the report template. When coverage data is not available, use the estimation variant.
When RubyCritic data was collected in Step 2, include the Code Quality Metrics section in the report using the RubyCritic variant from the report template. When RubyCritic data is not available, use the not available variant.
| Level | Meaning | |-------|---------| | Critical | Security vulnerabilities, data loss risks, production-breaking issues | | High | Performance issues, missing tests for critical paths, major code smells | | Medium | Code smells, convention violations, maintainability concerns | | Low | Style issues, minor improvements, suggestions |
app/models/**/*.rb, app/controllers/**/*.rb, app/services/**/*.rbspec/**/*_spec.rb or test/**/*_test.rbrescue\s*$, \.save\b, params\.permit!)app/**/*.rb files, then Read each to check line countAlways save the audit report to RAILS_AUDIT_REPORT.md in the project root and present it to the user.
testing
Verify what Ruby versions actually exist and install a specific Ruby via rbenv. Use BEFORE asserting that any Ruby version does or doesn't exist (e.g., "Ruby 4.0 isn't out yet", "the latest Ruby is 3.x", "Ruby X.Y.Z doesn't exist"). Also use when the user asks "what's the latest Ruby", "is Ruby X out", "does Ruby X.Y exist", "install Ruby", "switch to Ruby X", "what Ruby is installed", or mentions a specific Ruby version you're unsure about. Claude's training data may be out of date — run `check.sh` first.
development
Trace code through the stack — upward to entry points, downward to data, or laterally across boundaries. Use when the user asks "where does this get called from", "what calls this method", "trace this through the stack", "how does this request flow", "where does this data come from", "follow this through the code", or pastes/selects a piece of code and wants to understand where it fits in the larger system.
tools
Pick the single highest-priority unresolved Sentry issue and hand it off to a fixer skill. Use when triaging Sentry errors, running automated issue triage, or when asked to fix the top Sentry issue in a project.
tools
Find and fix issues from Sentry using MCP. Use when asked to fix Sentry errors, debug production issues, investigate exceptions, or resolve bugs reported in Sentry. Methodically analyzes stack traces, breadcrumbs, traces, and context to identify root causes.