Back to Skills

store-model-coder

verified

Wrap JSON-backed database columns with ActiveModel-like classes using store_model. Use when creating configuration objects, managing nested JSON attributes, or adding validations to JSON data. Triggers on JSON columns, store_model, typed JSON, configuration objects, or nested attributes.

View on GitHub

Marketplace

majestic-marketplace

majesticlabs-dev/majestic-marketplace

Plugin

majestic-rails

Repository

majesticlabs-dev/majestic-marketplace
19stars

plugins/majestic-rails/skills/store-model-coder/SKILL.md

Last Verified

January 24, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/majesticlabs-dev/majestic-marketplace/blob/main/plugins/majestic-rails/skills/store-model-coder/SKILL.md -a claude-code --skill store-model-coder

Installation paths:

Claude
.claude/skills/store-model-coder/
Powered by add-skill CLI

Instructions

# StoreModel: JSON-Backed ActiveRecord Attributes

Wrap JSON-backed database columns with ActiveModel-like classes for type safety, validations, and clean separation of concerns.

## When to Use This Skill

- Configuration objects with validated fields
- Nested attributes stored in JSON columns
- JSON data requiring type safety and ActiveModel behavior
- Separating JSON logic from parent ActiveRecord model

## When NOT to Use StoreModel

| Scenario | Better Alternative |
|----------|-------------------|
| Simple key-value settings | `ActiveRecord::Store` or `store_accessor` |
| Need database-level queries on JSON | Raw `jsonb` with PostgreSQL operators |
| Data needs relationships/joins | Normalize into separate tables |
| Truly simple JSON without validation | Plain JSON column access |

## Setup

```ruby
# Gemfile
gem "store_model", "~> 3.0"
```

## Basic Usage

### Define a StoreModel Class

```ruby
# app/models/configuration.rb
class Configuration
  include StoreModel::Model

  attribute :model, :string
  attribute :color, :string
  attribute :max_speed, :integer, default: 100

  validates :model, presence: true
  validates :max_speed, numericality: { greater_than: 0 }
end
```

### Register in ActiveRecord

```ruby
# app/models/product.rb
class Product < ApplicationRecord
  attribute :configuration, Configuration.to_type
end
```

### Usage

```ruby
product = Product.new
product.configuration = { model: "rocket", color: "red" }
product.configuration.model  # => "rocket"
product.configuration.color = "blue"
product.save!

# Also accepts StoreModel instances
product.configuration = Configuration.new(model: "shuttle")
```

## Enums

```ruby
class Configuration
  include StoreModel::Model

  attribute :model, :string

  enum :status, %i[draft active archived], default: :draft

  # With custom values
  enum :priority, { low: 0, medium: 1, high: 2 }, default: :medium
end
```

```ruby
config = Configuration.new
config.status        # => "draft"
config.active?       # =>

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
5526 chars