model-agent

Generate ActiveRecord models with validations, associations, scopes, and RSpec tests.

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/mlbright/notes --skill model-agent
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: model-agent
Source: https://github.com/mlbright/notes/tree/main/.github/skills/model-agent
Command: npx skills add https://github.com/mlbright/notes --skill model-agent

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the creation and refinement of ActiveRecord models in Rails applications, ensuring data integrity and maintainability through best practices and automated testing.

Core Features & Use Cases

  • Model Generation: Creates well-structured models with validations and associations.
  • Validation Implementation: Adds robust data validation rules.
  • Association Definition: Sets up correct belongs_to, has_many, etc., with dependent options.
  • Scope Creation: Defines reusable query scopes for common data retrieval patterns.
  • RSpec Test Generation: Automatically writes comprehensive RSpec tests for models, including validations, associations, and scopes.
  • Use Case: When starting a new feature that requires a Product model, use this Skill to generate the app/models/product.rb file, including validations for name and price, a belongs_to :user association, and a published scope, along with corresponding RSpec tests in spec/models/product_spec.rb.

Quick Start

Use the model-agent skill to create a new Rails model named 'User' with validations for 'email' and 'password_digest', and a 'has_many' association with 'posts'.

Frequently Asked Questions about model-agent

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate Rails ActiveRecord models with validations and RSpec tests?

You can generate Rails ActiveRecord models with validations, associations, scopes, and callbacks by using an automated model generation tool that simultaneously creates corresponding RSpec tests. This approach ensures clean data persistence and adherence to Rails conventions while maintaining data integrity.

What is the best way to set up polymorphic associations in an ActiveRecord model?

Setting up polymorphic associations in an ActiveRecord model involves defining the correct relationship structure within your Rails application. Using a model generation approach ensures that associations like `belongs_to` and `has_many` are configured with proper `dependent` options and tested with RSpec.

How do I add custom validations and scopes to a Ruby on Rails model?

Adding custom validations and reusable query scopes to a Ruby on Rails model requires defining robust data validation rules within the model file. A structured generation process can implement these validations and automatically write comprehensive RSpec tests to verify their behavior.

Does this model generation process support Rails enums and JSON attributes?

Yes, the model generation process supports common Rails patterns including enums, JSON attributes, and polymorphic associations. It focuses on clean data persistence and generates well-structured model files accompanied by validation tests in RSpec.

Can I automatically write RSpec tests for ActiveRecord validations and scopes?

Automatically writing RSpec tests for ActiveRecord validations and scopes is possible through a model generation workflow. It creates comprehensive test suites in `spec/models/` that cover validations, associations, and scopes alongside the generated model file.

What should I do if my Rails model associations are missing dependent options?

If your Rails model associations are missing dependent options, you should refine your ActiveRecord models to include correct configurations like `dependent: :destroy`. Using a structured generation tool ensures proper association definition and generates corresponding RSpec tests.