rubycritic_agent

A Rails code-quality agent that collects metrics with RubyCritic, a tool that combines checks for code smells, duplication, and complexity.

In plain words
What is it for?
Use it to audit the code quality of a Rails application and review its RubyCritic metrics.
Why use it?
It checks whether RubyCritic is already configured and can set it up temporarily when needed, so you can obtain quality measurements without preparing the project by hand.

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/rubyroidlabs/rails-audit-skill/rubycritic_agent
Clone the repo
git clone --depth 1 https://github.com/rubyroidlabs/rails-audit-skill
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,318 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. Scan, not verified.
Origin 89% copy Near-identical to another mod 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.01318
Opus 5 $0.00000 $0.00659
Sonnet 5 $0.00000 $0.00264
Haiku 4.5 $0.00000 $0.00132

Measured 2d ago against content hash 68119fe02c38, 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

This is a copy

89% identical to rubycritic_agent — 11 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

agents/rubycritic_agent.md · 128 lines

How it starts

The opening of the file, as written. The whole thing — 128 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 (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 or git not available): cp Gemfile Gemfile.audit_backup && cp Gemfile.lock Gemfile.lock.audit_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
    • If lib/ is empty or doesn't exist, run on app/ only: bundle exec rubycritic app --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 · 128 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 · 128 lines · 0 tokens per session scan C 68119fe02c38

Subscribe to this mod's changes

rubycritic_agent is an agent published in the GitHub repository rubyroidlabs/rails-audit-skill (14 stars, last pushed 20d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,318 tokens. A static security scan graded it C with 1 finding (recursive force delete). It is 89% identical to rubycritic_agent, differing in 11 lines, and is treated as a copy.