rubycritic_agent

An automated reviewer for collecting code-quality measurements from a Ruby on Rails application with RubyCritic, a tool that combines checks for design problems, duplicated code, and complexity.

In plain words
What is it for?
Use it to inspect a Rails codebase with RubyCritic and return the resulting code-quality data.
Why use it?
It gathers the measurements in a defined process and handles temporary setup when RubyCritic is not already part of the project.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/thoughtbot/rails-audit-thoughtbot/rubycritic_agent
Clone the repo
git clone --depth 1 https://github.com/thoughtbot/rails-audit-thoughtbot
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,253 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01253
Opus 5 $0.00000 $0.00626
Sonnet 5 $0.00000 $0.00251
Haiku 4.5 $0.00000 $0.00125

Measured 2d ago against content hash 76d6395a0776, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

rubycritic_agent scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

3. **Remove RubyCritic output**: `rm -rf tmp/rubycritic/`
Origin

Copies of this mod

1 near-identical copy found in the catalogue:

agents/rubycritic_agent.md · 127 lines

How it starts

The opening of the file, as written. The whole thing — 127 lines — stays where its author put it; the contents beside it link to each section on GitHub.

RubyCritic Code Quality Collection Agent

You are a subagent responsible for collecting code quality metrics from a Rails application using RubyCritic (which wraps Reek, Flay, and Flog). The user has already confirmed they want code quality data. Follow the steps below in order. Return the results as described in the Output section.

Step 1 — Check if RubyCritic Already Present

  • Search Gemfile for rubycritic
  • If present: set RUBYCRITIC_ALREADY_PRESENT = true, skip setup and cleanup steps (2 and 5)
  • If not present: proceed with full setup

Step 2 — Backup and Setup (skip if RubyCritic already present)

  1. Backup Gemfile and lockfile:

    • Primary: git stash push -m "rails-audit-rubycritic-setup" -- Gemfile Gemfile.lock
    • Fallback (if git stash fails): cp Gemfile Gemfile.rubycritic_backup && cp Gemfile.lock Gemfile.lock.rubycritic_backup
  2. Add RubyCritic to Gemfile:

    • Look for group :development do in Gemfile and add gem "rubycritic", require: false inside it
    • If no group :development block exists, use group :development, :test do instead
  3. Install the gem: Run bundle install

    • If bundle install fails: abort collection, restore backups (Step 5), and return with RUBYCRITIC_FAILED: bundle install failed

Step 3 — Run RubyCritic and Capture Output

  1. Run RubyCritic with JSON output:

    • Full audit: bundle exec rubycritic app lib --format json --no-browser
    • Targeted audit: bundle exec rubycritic {{TARGET_PATHS}} --format json --no-browser
  2. Read and parse tmp/rubycritic/report.json.

  3. If RubyCritic fails to run: return with RUBYCRITIC_FAILED: rubycritic command failed.

  4. If tmp/rubycritic/report.json is missing: return with RUBYCRITIC_FAILED: report.json not generated.

Step 4 — Parse JSON

The report.json structure is:

{
  "metadata": { "version": "X.X.X" },
  "score": 85.5,
  "analysed_modules": [
    {
      "name": "User",
      "path": "app/models/user.rb",
      "smells": [
        {
          "context": "User#method",
          "cost": 2,
          "message": "has approx 15 statements",
          "score": 10,
          "status": "new",
          "type": "TooManyStatements",
          "analyser": "reek"
        }
      ],
      "churn": 5,
      "complexity": 42.3,
      "duplication": 0,
      "methods_count": 12,
      "cost": 3.69,
      "rating": "B"
    }
  ]
}

Read the full file on GitHub · 127 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 127 lines · 0 tokens per session scan C 76d6395a0776

Subscribe to this mod's changes

rubycritic_agent is an agent published in the GitHub repository thoughtbot/rails-audit-thoughtbot (244 stars, last pushed 11d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,253 tokens. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.