Agent skill

Rails Concern

by ThibautBaissac in ThibautBaissac/rails_ai_agents

Creates Rails concerns for shared behavior across models or controllers with TDD.

MITAuto-check passedBackend & APIs

Install Rails Concern

skills CLI
$ npx skills add ThibautBaissac/rails_ai_agents --skill rails-concern -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ThibautBaissac/rails_ai_agents rails-concern --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ThibautBaissac/rails_ai_agents.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/rails-concern .claude/skills/rails-concern && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
rails-concern
GitHub stars
665
Token cost
~1.7k tokens
SKILL.md length
214 words
Files
1
Skills in repo
19
Repo updated
First seen
Licence
MIT

At a glance

Creates Rails concerns for shared behavior across models or controllers with TDD.

  • Works in 4 steps: Create Concern Spec (RED) → Run Spec (Confirm RED) → Implement Concern (GREEN) → …
  • Extracting shared code
  • SKILL.md covers Quick Start, When to Use Concerns, TDD Workflow and Common Concern Patterns, plus 2 more sections
  • Calls bundle

What it does

Rails Concern is an agent skill from ThibautBaissac/rails_ai_agents. Creates Rails concerns for shared behavior across models or controllers with TDD. Use when extracting shared code, creating reusable modules, DRYing up models/controllers, or when user mentions concerns, modules, mixins, or shared behavior. WHEN NOT: Logic used by only one model or controller (keep it in place), complex business logic (use service objects), or query encapsulation (use query objects).

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs, covering Backend development and Test-driven development. The repository describes itself as: Specialized AI skills, agents, rules and hooks for modern Rails AI driven-development + Spec-Driven-Development kit + MCP. The licence is MIT.

When your agent uses it

  • Extracting shared code
  • Creating reusable modules
  • DRYing up models/controllers
  • User mentions concerns

Example prompts

  • “Use the rails-concern skill to create Rails concerns for shared behavior across models or controllers with TDD”
  • “/rails-concern”

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Create Concern Spec (RED)
  2. Run Spec (Confirm RED)
  3. Implement Concern (GREEN)
  4. Run Spec (Confirm GREEN)

What it can do on your machine

Read from SKILL.md and the folder at commit 03622f2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • bundle

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Rails Concern loads about 1.7k tokens when it runs. Until then it costs about 104 tokens; SKILL.md has 214 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~104
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ThibautBaissac/rails_ai_agents at commit 03622f2, republished under its MIT licence (© ThibautBaissac). 214 words, ~1,737 tokens.

Download SKILL.mdSave it as .claude/skills/rails-concern/SKILL.md (or your agent's skills folder).
name
rails-concern
description
Creates Rails concerns for shared behavior across models or controllers with TDD. Use when extracting shared code, creating reusable modules, DRYing up models/controllers, or when user mentions concerns, modules, mixins, or shared behavior. WHEN NOT: Logic used by only one model or controller (keep it in place), complex business logic (use service objects), or query encapsulation (use query objects).
paths
app/models/concerns/**/*.rb, app/controllers/concerns/**/*.rb

Rails Concern Generator (TDD)

Creates concerns (ActiveSupport::Concern modules) for shared behavior with specs first.

Quick Start

  1. Write failing spec testing the concern behavior
  2. Run spec to confirm RED
  3. Implement concern in app/models/concerns/ or app/controllers/concerns/
  4. Run spec to confirm GREEN

When to Use Concerns

Good use cases:

  • Shared validations across multiple models
  • Common scopes used by several models
  • Shared callbacks (e.g., UUID generation)
  • Controller authentication/authorization helpers
  • Pagination or filtering logic

Avoid concerns when:

  • Logic is only used in one place (YAGNI)
  • Creating "god" concerns with unrelated methods
  • Logic should be a service object instead

TDD Workflow

Step 1: Create Concern Spec (RED)

For Model Concerns, test via a model that includes it:

ruby
# spec/models/concerns/[concern_name]_spec.rb
RSpec.describe [ConcernName] do
  # Create a test class that includes the concern
  let(:test_class) do
    Class.new(ApplicationRecord) do
      self.table_name = "events"  # Use existing table
      include [ConcernName]
    end
  end

  let(:instance) { test_class.new }

  describe "included behavior" do
    it "adds the expected methods" do
      expect(instance).to respond_to(:method_from_concern)
    end
  end

  describe "#method_from_concern" do
    it "behaves as expected" do
      expect(instance.method_from_concern).to eq(expected_value)
    end
  end

  describe "class methods" do
    it "adds scope" do
      expect(test_class).to respond_to(:scope_name)
    end
  end
end

Alternative: Test through an actual model that uses the concern:

ruby
# spec/models/event_spec.rb
RSpec.describe Event, type: :model do
  describe "[ConcernName] behavior" do
    describe "#method_from_concern" do
      let(:event) { build(:event) }

      it "does something" do
        expect(event.method_from_concern).to eq(expected)
      end
    end
  end
end

For Controller Concerns, test via request specs:

ruby
# spec/requests/[feature]_spec.rb
RSpec.describe "[Feature]", type: :request do
  describe "pagination (from Paginatable concern)" do
    let(:user) { create(:user) }
    before { sign_in user }

    it "paginates results" do
      create_list(:resource, 30, account: user.account)
      get resources_path
      expect(response.body).to include("page")
    end
  end
end
Step 2: Run Spec (Confirm RED)
bash
bundle exec rspec spec/models/concerns/[concern_name]_spec.rb
# OR
bundle exec rspec spec/models/[model]_spec.rb
Step 3: Implement Concern (GREEN)

Model Concern:

ruby
# app/models/concerns/[concern_name].rb
module [ConcernName]
  extend ActiveSupport::Concern

  included do
    # Callbacks
    before_validation :generate_uuid, on: :create

    # Validations
    validates :uuid, presence: true, uniqueness: true

    # Scopes
    scope :with_uuid, ->(uuid) { where(uuid: uuid) }
    scope :recent, -> { order(created_at: :desc) }
  end

  # Class methods
  class_methods do
    def find_by_uuid!(uuid)
      find_by!(uuid: uuid)
    end
  end

  # Instance methods
  def generate_uuid
    self.uuid ||= SecureRandom.uuid
  end

  def short_uuid
    uuid&.split("-")&.first
  end
end

Controller Concern:

ruby
# app/controllers/concerns/[concern_name].rb
module [ConcernName]
  extend ActiveSupport::Concern

  included do
    before_action :set_locale
    helper_method :current_locale
  end

  class_methods do
    def skip_locale_for(*actions)
      skip_before_action :set_locale, only: actions
    end
  end

  private

  def set_locale
    I18n.locale = params[:locale] || I18n.default_locale
  end

  def current_locale
    I18n.locale
  end
end
Step 4: Run Spec (Confirm GREEN)
bash
bundle exec rspec spec/models/concerns/[concern_name]_spec.rb

Common Concern Patterns

Pattern 1: UUID Generation
ruby
# app/models/concerns/has_uuid.rb
module HasUuid
  extend ActiveSupport::Concern

  included do
    before_validation :generate_uuid, on: :create
    validates :uuid, presence: true, uniqueness: true
  end

  private

  def generate_uuid
    self.uuid ||= SecureRandom.uuid
  end
end
Pattern 2: Soft Delete
ruby
# app/models/concerns/soft_deletable.rb
module SoftDeletable
  extend ActiveSupport::Concern

  included do
    scope :active, -> { where(deleted_at: nil) }
    scope :deleted, -> { where.not(deleted_at: nil) }

    default_scope { active }
  end

  def soft_delete
    update(deleted_at: Time.current)
  end

  def restore
    update(deleted_at: nil)
  end

  def deleted?
    deleted_at.present?
  end
end
Pattern 3: Searchable
ruby
# app/models/concerns/searchable.rb
module Searchable
  extend ActiveSupport::Concern

  class_methods do
    def search(query)
      return all if query.blank?

      where("name ILIKE :q OR email ILIKE :q", q: "%#{query}%")
    end
  end
end
Pattern 4: Auditable
ruby
# app/models/concerns/auditable.rb
module Auditable
  extend ActiveSupport::Concern

  included do
    has_many :audit_logs, as: :auditable, dependent: :destroy

    after_create :log_creation
    after_update :log_update
  end

  private

  def log_creation
    audit_logs.create(action: "created", changes: attributes)
  end

  def log_update
    return unless saved_changes.any?
    audit_logs.create(action: "updated", changes: saved_changes)
  end
end
Pattern 5: Controller Filterable
ruby
# app/controllers/concerns/filterable.rb
module Filterable
  extend ActiveSupport::Concern

  private

  def apply_filters(scope, allowed_filters)
    allowed_filters.each do |filter|
      if params[filter].present?
        scope = scope.where(filter => params[filter])
      end
    end
    scope
  end
end

Usage

In Models:

ruby
class Event < ApplicationRecord
  include HasUuid
  include SoftDeletable
  include Searchable
end

In Controllers:

ruby
class ApplicationController < ActionController::Base
  include Filterable
end

Checklist

  • Spec written first (RED)
  • Uses extend ActiveSupport::Concern
  • included block for callbacks/validations/scopes
  • class_methods block for class-level methods
  • Instance methods outside blocks
  • Single responsibility (one purpose per concern)
  • Well-named (describes what it adds)
  • All specs GREEN

© ThibautBaissac, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/rails-concern of ThibautBaissac/rails_ai_agents.

Open the folder on GitHubat commit 03622f2

Compare with similar skills

Rails Concern next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Rails Concern compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Rails Concern this skillThibautBaissac/rails_ai_agents665—~1.7kAutomated safety check: PassMIT
Laravel TDDaffaan-m/ECC276k3 repos~1.9kAutomated safety check: PassMIT
Laravel TDDaffaan-m/ECC276k1 repos~4.5kAutomated safety check: PassMIT
Laravel TDDaffaan-m/ECC276k1 repos~1.4kAutomated safety check: PassMIT
Laravel TDDaffaan-m/ECC276k—~1.6kAutomated safety check: PassMIT
Django Forms Validation TDDhashgraph-online/awesome-codex-plugins1.3k—~845Automated safety check: PassMIT

Similar skills

  • Laravel TDD

    affaan-m/ECC

    Test-driven development for Laravel with PHPUnit and Pest, factories, database testing, fakes, and coverage targets.

    276k GitHub starsUsed in 3 repos~1.9k tokens
    Backend & APIsAuto-check passed
  • Laravel TDD

    affaan-m/ECC

    Laravel testing strategies with PHPUnit, Pest, model factories, HTTP tests, Sanctum authentication testing, mocking, and coverage.

    276k GitHub starsUsed in 1 repo~4.5k tokens
    Backend & APIsAuto-check passed
  • Laravel TDD

    affaan-m/ECC

    使用 PHPUnit 和 Pest、工厂、数据库测试、模拟以及覆盖率目标进行 Laravel 的测试驱动开发. An agent skill from affaan-m/ECC.

    276k GitHub starsUsed in 1 repo~1.4k tokens
    Backend & APIsAuto-check passed
  • Laravel TDD

    affaan-m/ECC

    Laravel での TDD:PHPUnit と Pest、ファクトリー、データベーステスト、フェイク、カバレッジターゲット

    276k GitHub stars~1.6k tokensUpdated today
    Backend & APIsAuto-check passed
  • Django Forms Validation TDD

    hashgraph-online/awesome-codex-plugins

    Test-drive Django validation across model constraints, forms, ModelForms, views, template errors, duplicate handling, and redirects.

    1.3k GitHub stars~845 tokensUpdated today
    Backend & APIsAuto-check passed
  • Pest Testing

    liberusoftware/real-estate-laravel

    A skill your agent uses for Pest PHP testing in Laravel projects only.

    112 GitHub starsUsed in 1 repo~1.8k tokens
    Testing & QAAuto-check passed

More from ThibautBaissac/rails_ai_agents

All 19 skills in this repo
  • Accessibility Review

    ThibautBaissac/rails_ai_agents

    Audits Rails application accessibility against WCAG 2.2 Level AA, detects violations with axe-core / Lighthouse / Pa11y, and reports remediation guidance for ERB views, ViewComponents, Stimulus…

    665 GitHub stars~2.9k tokensUpdated 4 mo ago
    Auto-check: notes
  • Action Cable Patterns

    ThibautBaissac/rails_ai_agents

    Implements real-time features with Action Cable and WebSockets.

    665 GitHub stars~1.2k tokensUpdated 4 mo ago
    Auto-check passed
  • Active Storage Setup

    ThibautBaissac/rails_ai_agents

    Configures Active Storage for file uploads with variants and direct uploads.

    665 GitHub stars~1.2k tokensUpdated 4 mo ago
    Auto-check passed
  • Authentication Flow

    ThibautBaissac/rails_ai_agents

    Implements authentication using Rails 8 built-in generator. An agent skill from ThibautBaissac/rails_ai_agents.

    665 GitHub stars~1.9k tokensUpdated 4 mo ago
    Auto-check passed
  • Caching Strategies

    ThibautBaissac/rails_ai_agents

    Implements Rails caching patterns for performance optimization.

    665 GitHub stars~1.4k tokensUpdated 4 mo ago
    Auto-check passed
  • I18n Patterns

    ThibautBaissac/rails_ai_agents

    Implements internationalization with Rails I18n for multi-language support.

    665 GitHub stars~1.4k tokensUpdated 4 mo ago
    Auto-check passed

Questions about Rails Concern

What does Rails Concern do?

Creates Rails concerns for shared behavior across models or controllers with TDD. Rails Concern is an agent skill from ThibautBaissac/rails_ai_agents. Creates Rails concerns for shared behavior across models or controllers with TDD.

When should I use Rails Concern?

Rails Concern fits situations like: extracting shared code; creating reusable modules; DRYing up models/controllers; user mentions concerns.

How do I install Rails Concern in Claude Code?

Run `npx skills add ThibautBaissac/rails_ai_agents --skill rails-concern -a claude-code`. Or copy the skill folder (.agents/skills/rails-concern in ThibautBaissac/rails_ai_agents) into .claude/skills/rails-concern in your project. Claude Code loads it when a task matches its description.

How do I install Rails Concern in Codex?

Run `npx skills add ThibautBaissac/rails_ai_agents --skill rails-concern -a codex`. Or copy the skill folder (.agents/skills/rails-concern in ThibautBaissac/rails_ai_agents) into .agents/skills/rails-concern in your project. Codex loads it when a task matches its description.

Can I use Rails Concern in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ThibautBaissac/rails_ai_agents --skill rails-concern -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/rails-concern, .gemini/skills/rails-concern, .github/skills/rails-concern and .opencode/skills/rails-concern in your project.

What does Rails Concern need to run?

Going by SKILL.md and its folder, Rails Concern needs the command-line tools its instructions call (bundle).

Does Rails Concern access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Rails Concern safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Rails Concern use?

Rails Concern is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Rails Concern use?

About 1.7k tokens (SKILL.md is roughly 6.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Rails Concern?

Skills that share tags, products or a category with Rails Concern: Laravel TDD (affaan-m/ECC, 276k stars), Laravel TDD (affaan-m/ECC, 276k stars), Laravel TDD (affaan-m/ECC, 276k stars) and Laravel TDD (affaan-m/ECC, 276k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Rails Concern?

ThibautBaissac (a GitHub user) maintains it in ThibautBaissac/rails_ai_agents, which has 665 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on June 1, 2026.

Source: ThibautBaissac/rails_ai_agents on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.