/rails-cto:rails-cto-securityfrom rails-cto
Runs Brakeman and bundler-audit security scans on changed Ruby and ERB files, fixing high/medium confidence warnings. Acts as a post-change quality gate for Rails projects.
Ships in rails-cto. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Every .rb and .html.erb change is scanned with Brakeman and bundler-audit before the work is considered done. Brakeman catches code-level vulnerabilities; bundler-audit catches known CVEs in your gem dependencies. High and medium confidence warnings must be fixed. This skill runs after code changes are made — it is a post-change quality gate, not a write blocker.
You MUST run these steps every time this skill is invoked.
bundle exec brakeman --version 2>/dev/null
If the command fails, inform the user:
"This project doesn't have the
brakemangem installed. Add it to your Gemfile:group :development do gem "brakeman", require: false endThen run
bundle install."
If Brakeman is not available, skip the scanning steps below and continue. Do not block on Brakeman installation. But if Brakeman IS available, you MUST run the scanning steps — do not skip them.
Check if the project already has a Brakeman config:
ls config/brakeman.yml 2>/dev/null
If the file does not exist, create it:
---
# Brakeman configuration
# See https://brakemanscanner.org/docs/options/ for all options
# Only report high and medium confidence warnings
:min_confidence: 1
# Output format (overridden by CLI flags, but serves as default)
:output_format: json
# Quiet mode — suppress informational messages
:quiet: true
# Ignored warning fingerprints (add false positives here)
:ignored_warnings: []
Use git to find only the .rb and .html.erb files that were modified:
git diff --name-only --diff-filter=ACMR HEAD 2>/dev/null | grep -E '\.(rb|html\.erb)$'
If there are unstaged changes too:
git diff --name-only --diff-filter=ACMR 2>/dev/null | grep -E '\.(rb|html\.erb)$'
Combine both lists and deduplicate. If no matching files were changed, skip the scan — there is nothing to check.
Run Brakeman scoped to only the changed files, outputting JSON to stdout:
bundle exec brakeman --only-files file1.rb,file2.rb -f json -q --no-pager
For example, if app/controllers/users_controller.rb and app/models/user.rb were changed:
bundle exec brakeman --only-files app/controllers/users_controller.rb,app/models/user.rb -f json -q --no-pager
Important: Pass file paths as a comma-separated list to --only-files. Use relative paths from the Rails root.
The JSON output contains a warnings array. Each warning has:
{
"warning_type": "SQL Injection",
"warning_code": 0,
"message": "Possible SQL injection",
"file": "app/controllers/users_controller.rb",
"line": 42,
"code": "User.where(params[:query])",
"confidence": "High",
"fingerprint": "abc123..."
}
Key fields:
confidence — "High", "Medium", or "Weak"warning_type — Category (SQL Injection, Cross-Site Scripting, Mass Assignment, etc.)file and line — Exact location of the issuecode — The vulnerable code snippetfingerprint — Unique identifier (used for ignoring false positives)For each high or medium confidence warning:
file, line, code, and message| Warning Type | Typical Fix |
|---|---|
| SQL Injection | Use parameterized queries, where(field: value), or sanitize_sql |
| Cross-Site Scripting (XSS) | Use sanitize, h(), or content_tag instead of raw/html_safe |
| Mass Assignment | Use strong_parameters — never permit! |
| Command Injection | Use Open3.capture3 or array form of system instead of backticks/exec |
| Dynamic Render Path | Use explicit template names, not user-controlled paths |
| File Access | Validate and sanitize file paths, use ActiveStorage |
| Redirect | Use _path/_url helpers, validate redirect targets with url_from |
| Unsafe Deserialization | Avoid Marshal.load, YAML.unsafe_load on user input |
| Session Manipulation | Use reset_session, don't store sensitive data in sessions |
| Dangerous Send | Validate method names against an allowlist before .send |
For weak confidence warnings, list them once as informational:
"Brakeman also reported N weak-confidence warnings that may be false positives:
- [file:line] warning_type: message
These are informational only — review them if you'd like, but no action is required."
Do not attempt to fix weak warnings. Do not block completion on them.
If a warning's fingerprint is listed in config/brakeman.yml under :ignored_warnings, skip it silently. Do not mention ignored warnings in the output.
After fixing all high and medium warnings, re-run Brakeman on the same files:
bundle exec brakeman --only-files file1.rb,file2.rb -f json -q --no-pager
After the Brakeman scan, run bundler-audit to check for known vulnerabilities in gem dependencies.
bundle-audit --version 2>/dev/null
If the command fails, inform the user:
"This project doesn't have the
bundler-auditgem installed. Add it to your Gemfile:group :development do gem "bundler-audit", require: false endThen run
bundle install."
If bundler-audit is not available, skip the audit steps below and continue. Do not block on installation. But if bundler-audit IS available, you MUST run it — do not skip.
Always update the advisory database before scanning to catch the latest CVEs:
bundle-audit check --update
This updates the ruby-advisory-db and immediately runs the check.
.bundler-audit.yml if missingCheck for a config file:
ls .bundler-audit.yml 2>/dev/null
If the file does not exist, create it:
---
# bundler-audit configuration
# Add advisory IDs here to ignore known false positives
ignore: []
bundler-audit reports vulnerable gems in this format:
Name: actionpack
Version: 7.0.4
Advisory: CVE-2023-22796
Criticality: High
URL: https://nvd.nist.gov/vuln/detail/CVE-2023-22796
Title: ReDoS vulnerability in Active Support
Solution: upgrade to >= 7.0.4.1
Key fields:
For each high or medium advisory:
Gemfile if it has a pinned versionbundle update <gem_name> to pull the patched versionbundle-audit check to verify the vulnerability is resolvedIf a gem cannot be updated (dependency conflicts, breaking changes), report it to the user with the CVE, current version, and required version so they can decide how to proceed.
For low criticality advisories, list them as informational:
"bundler-audit also reported N low-criticality advisories:
- [gem_name] (version) — CVE-XXXX-XXXX: title
These are informational only — review them if you'd like, but no action is required."
Do not block completion on low criticality advisories.
If an advisory ID is listed in .bundler-audit.yml under ignore, bundler-audit skips it automatically. Do not mention ignored advisories in the output.
This skill runs alongside /rails-cto-qa, not as a replacement. The typical end-of-task flow is:
/rails-cto-qa — RuboCop linting + test suite/rails-cto-security — Brakeman scan + bundler-auditBoth must pass before the work is considered done.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub mattsears/rails-cto --plugin rails-cto17 skills in this plugin
/rails-ctoOrchestrator skill for Ruby on Rails projects. Initializes sessions, routes to specialized skills, enforces mandatory QA gates, and runs the completion checklist. Invoke at the start of every Rails session./rails-cto-apiHow to build RESTful JSON APIs in a Rails 8 application following OpenAPI standards. Use when creating, modifying, or debugging API endpoints, serializers, authentication, documentation, or any code under the Api:: namespace. Also use when the user mentions "api", "endpoint", "api key", "serializer", "openapi", "swagger", "api documentation", "cors", "rate limit", "pagination cursor", "api versioning", or asks about exposing data to external consumers. Proactively apply these rules whenever touching API controllers, routes, or serializers, even if the user doesn't explicitly ask.
/rails-cto-architectHow to write comprehensive implementation plans for multi-step Rails features before any code is written. Use when the user has a spec, feature request, or multi-step task and wants to plan the approach before touching code. Also use when the user mentions "create a plan", "write a plan", "plan this", "plan a feature", "implementation plan", "build a new feature", "new feature", "how should I build", "how do I build", "architect this", "design this", "design a feature", "feature design", "spec", "requirements", or pastes long-form requirements. Proactively invoke this skill BEFORE writing any code for multi-file or multi-step work, even if the user doesn't explicitly say "plan" — every multi-step feature goes through architect first. Produces a bite-sized, task-by-task plan optimized for rails-cto-engineer to execute. Never writes code, never commits, and never generates plans that contain commit steps.
/rails-cto-commitStage and commit all outstanding code changes with a clear, human-friendly commit message. Use this skill whenever the user asks to commit, save their work, push changes, or says things like "commit this", "save my progress", "push this up", "ship it", "commit all", or "commit and push". Also triggers for "/commit-all". Do NOT use for cherry-picking, rebasing, or other advanced git operations./rails-cto-engineerThis file provides guidance to Claude Code (claude.ai/code) when working with Ruby on Rails projects./rails-cto-erbHow to write clean, well-formatted ERB templates for this Rails 8 project. Use when creating or modifying any ERB view, partial, layout, or component template. Also use when the user mentions "erb", "views", "partials", "templates", "html formatting", "attribute alignment", or asks about view-layer code. Proactively apply these rules whenever touching .html.erb files, even if the user doesn't explicitly ask for formatting help.
Other plugins' skills for the same job