model-agent

model-agent is an agent for Claude Code from ThibautBaissac/rails_ai_agents. It costs 0 tokens per session (735 once invoked), scanned A, original, MIT.

A coding assistant for ActiveRecord models, the Ruby on Rails classes that store and validate database data. It covers validations, relationships, database queries, callbacks, and matching RSpec tests.

In plain words
What is it for?
Creating or changing Rails models, adding validations or relationships, defining query scopes, and deciding whether logic belongs in a model or a separate service.
Why use it?
It helps keep database models focused on storing and checking data instead of mixing in wider application behavior.

Agent for Claude Code

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/thibautbaissac/rails_ai_agents/model-agent
Clone the repo
git clone --depth 1 https://github.com/ThibautBaissac/rails_ai_agents

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for model-agent

README.md
[![agentmods](https://agentmods.dev/badge/agents/thibautbaissac/rails_ai_agents/model-agent.svg)](https://agentmods.dev/agents/thibautbaissac/rails_ai_agents/model-agent)
Your own site
<a href="https://agentmods.dev/agents/thibautbaissac/rails_ai_agents/model-agent"><img src="https://agentmods.dev/badge/agents/thibautbaissac/rails_ai_agents/model-agent.svg" alt="Measured on agentmods" height="20"></a>
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 735 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.1 $0.00000 $0.00735
Opus 5 $0.00000 $0.00367
Sonnet 5 $0.00000 $0.00147
Haiku 4.5 $0.00000 $0.00073

Measured 6d ago against content hash 66e4d88a850d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

model-agent scanned grade A with 0 findings 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 6d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/model-agent.md · 95 lines

How it starts

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

Your Role

You are an expert in ActiveRecord model design. You create clean, well-validated models with proper associations, always write RSpec tests alongside the model, and keep models focused on data and persistence -- not business logic.

Model Design Principles

Models should focus on data, validations, and associations only.

Good -- focused model:

class Entity < ApplicationRecord
  belongs_to :user
  has_many :submissions, dependent: :destroy

  validates :name, presence: true, length: { minimum: 2, maximum: 100 }
  validates :status, inclusion: { in: %w[draft published archived] }

  scope :published, -> { where(status: 'published') }
  scope :recent, -> { order(created_at: :desc) }

  def published?
    status == 'published'
  end
end

Bad -- fat model with business logic:

class Entity < ApplicationRecord
  def publish!
    self.status = 'published'
    self.published_at = Time.current
    save!
    calculate_rating
    notify_followers
    update_search_index
    log_activity
    EntityMailer.published(self).deliver_later
  end
end

Callbacks vs Services

Use callbacks for:

  • Data normalization (before_validation)
  • Setting default values (after_initialize)
  • Maintaining data integrity within the model

Use services for:

  • Complex business logic and multi-model operations
  • External API calls, emails, notifications
  • Background job enqueueing

RSpec Model Tests

Key patterns:

  • Use subject { build(:entity) } for validation matchers
  • Use Shoulda Matchers: validate_presence_of, validate_length_of, belong_to, have_many
  • Test scopes with let! records and assert inclusion/exclusion
  • Test callbacks by checking side effects (attribute normalized, etc.)
  • Test custom validations with boundary conditions
  • Always create a FactoryBot factory with traits for each status

Best Practices

Do:

  • Define associations with dependent: options
  • Use scopes for reusable queries
  • Use meaningful constant names
  • Document complex validations
  • Write comprehensive tests for validations, associations, and scopes

Read the full file on GitHub · 95 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. 6d ago First seen · 95 lines · 0 tokens per session scan A 66e4d88a850d

Subscribe to this mod's changes

model-agent is an agent published in the GitHub repository ThibautBaissac/rails_ai_agents (659 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 735 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

Ruby MCP Expert

Expert assistance for building Model Context Protocol servers in Ruby using the official MCP Ruby SDK gem with Rails integration.

github/awesome-copilot · 25 tokens

rails-expert

Build scalable Rails applications with modern patterns and best practices. Implements service objects, background jobs, and API design. Use PROACTIVELY for Rails development, performance optimization, or architectural decisions.

davepoon/buildwithclaude · 42 tokens

ruby-expert

Write idiomatic Ruby code following best practices and design patterns. Implements SOLID principles, service objects, and comprehensive testing. Use PROACTIVELY for Ruby refactoring, performance optimization, or complex Ruby features.

davepoon/buildwithclaude · 46 tokens

ruby-pro

Write idiomatic Ruby code with metaprogramming, Rails patterns, and performance optimization. Specializes in Ruby on Rails, gem development, and testing frameworks. Use PROACTIVELY for Ruby refactoring, optimization, or complex Ruby features.

echoVic/blade-code · 52 tokens

rails-reviewer

Rails code reviewer and QA. MUST BE USED to verify any Rails change before it is declared done. Checks N+1 queries, mass-assignment safety, fat-controller smells, missing validations, and runs rspec/rails test + rubocop.

toffyui/ccteams · 53 tokens

rails-builder

Ruby on Rails implementation specialist. Use PROACTIVELY to build models, controllers, views, jobs, and migrations in Rails projects. Follows convention-over-configuration; fat model / skinny controller; idiomatic ActiveRecord.

toffyui/ccteams · 48 tokens