One-click install
npx skills add https://github.com/LaunchPadLab/ai-bank --skill state-records-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: state-records-patterns
Source: https://github.com/LaunchPadLab/ai-bank/tree/main/claude/skills/state-records-patterns
Command: npx skills add https://github.com/LaunchPadLab/ai-bank --skill state-records-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you eliminate fragile boolean state columns by modeling state as dedicated records that capture current status, change time, actor identity, and reasons/history.

Core Features & Use Cases

  • State as records (not booleans): Use a related “state record” (for example, a Closure/Publication/Goldness) so state queries become reliable and expressive.
  • Metadata-rich transitions: Track created_at, who made the change, and optional notes/reason to support auditability and user-facing UI.
  • Query and UI patterns: Provide consistent scopes for open/closed or published/private combinations, and show how to render state-aware views and toggle actions.
  • Migration guidance: Includes step-by-step migration/backfill strategy for converting existing boolean columns to state-record tables.

Quick Start

Ask an AI to generate a state-record model and Rails concerns for a resource you want to manage with open/closed behavior, including scopes, controller routes for create/destroy transitions, and view logic showing who changed the state and when.

Frequently Asked Questions about state-records-patterns

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

FAQPage Schema
Why use state records instead of boolean flags in Rails ActiveRecord models?

State records replace fragile boolean flags by capturing current status, timestamps, actor identity, and transition history. This approach makes state queries more reliable and fully auditable compared to simple true/false database columns.

How do I migrate existing boolean columns to state record tables in Rails?

You can migrate boolean columns to state record tables using a step-by-step migration and backfill strategy. This involves creating a companion record table with unique per-parent constraints and transferring existing boolean values into normalized state model entries.

How do Rails state models track workflow transitions and audit history?

Rails state models track workflow transitions by recording created_at timestamps, the actor who made the change, and optional reasons or notes. This metadata-rich approach provides a complete audit history for user-facing views and administrative tracking.

What is the best way to query open and closed states using domain-driven design in Rails?

The best way to query open and closed states is using model concerns that provide consistent ActiveRecord scopes. These scopes handle open/closed or published/private combinations deterministically based on the presence of related state records.

Can I use state record patterns for postponed and resumed workflow transitions?

Yes, state record patterns support postponed and resumed workflow transitions, including marked or not marked scenarios. They model these toggles as dedicated records with create and destroy actions for deterministic state changes.

When should I avoid replacing boolean columns with state models in a Rails application?

You should avoid state models if your application requires simple toggles without needing audit history, actor identity, or transition reasons. State records add database tables and relational complexity that are unnecessary for basic boolean tracking.