ai_misc/skills/rails-audit-thoughtbot/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 madbomber/experiments rails-audit-thoughtbotInstall 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.
The audit can be run in two modes:
Ask user or infer from request:
app/, spec/ or test/, config/, db/, lib/Before doing anything else in this step, use AskUserQuestion to ask the user:
If the user declines: skip the rest of this step entirely. Use estimation mode in Steps 4 and 5. Do NOT spawn the subagent.
If the user accepts: use the Task tool to spawn a general-purpose subagent with this prompt:
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.
After the agent finishes, run rm -rf coverage/ to ensure the coverage directory is removed even if the agent failed to clean up.
Interpreting the agent's response:
COVERAGE_FAILED: no coverage data — use estimation mode in Steps 4 and 5. Note the failure reason in the report.COVERAGE_DATA: parse the structured data and keep it in context for Steps 4 and 5. The data includes overall coverage, per-directory breakdowns, lowest-coverage files, and zero-coverage files.Before analyzing, read the relevant reference files:
references/code_smells.md - Code smell patterns to identifyreferences/testing_guidelines.md - 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)Analyze in this order:
Testing Coverage & Quality
Security Vulnerabilities
Models & Database
Controllers
Code Design & Architecture
Views & Presenters
External Services & Error Handling
Database & Migrations
Create 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 you find classes in app/services/:
*Service, *Manager, *Handler.call or .perform methodsActiveModel::ModelModels with:
Controllers with:
For each Ruby file in app/:
_spec.rb or _test.rbUse these bash patterns for file discovery:
# Find all Ruby files by type
find app/models -name "*.rb" -type f
find app/controllers -name "*.rb" -type f
find app/services -name "*.rb" -type f 2>/dev/null
# Find test files
find spec -name "*_spec.rb" -type f 2>/dev/null
find test -name "*_test.rb" -type f 2>/dev/null
# Count lines per file
wc -l app/models/*.rb
# Find long files (over 200 lines)
find app -name "*.rb" -exec wc -l {} + | awk '$1 > 200'
Always save the audit report to /mnt/user-data/outputs/RAILS_AUDIT_REPORT.md and present it to the user.
data-ai
Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.
development
Apply SOLID principles when writing, reviewing, or refactoring Ruby code. This skill should be used when designing classes, evaluating architecture, reviewing pull requests, or refactoring existing code. It provides actionable checklists, violation detection patterns, and Ruby-idiomatic refactoring strategies for each of the five SOLID principles.
tools
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
development
Analyze Ruby and Rails code quality with RubyCritic. Identifies code smells, complexity issues, and refactoring opportunities. Provides detailed metrics, scores files A-F, compares branches, and prioritizes high-churn problem areas. Use when analyzing Ruby code quality, reviewing PRs, or identifying technical debt.