business-logic-coder

Implement business logic with ActiveInteraction and AASM state machines. Use when creating typed operations, managing state transitions, or refactoring service objects. Triggers on interaction creation, state machines, workflows, or typed business operations.

⭐13stars🔀0forks📁View on GitHub🕐Updated Jan 3, 2026⬇️3downloads

When & Why to Use This Skill

This Claude skill streamlines the implementation of structured business logic in Ruby on Rails applications. By leveraging ActiveInteraction for type-safe service objects and AASM for robust state machine management, it helps developers transition from bloated models to maintainable, scalable, and testable architectural patterns.

Use Cases

  • Refactoring complex controller logic or overweight ActiveRecord models into isolated, typed service objects using ActiveInteraction.
  • Designing and implementing multi-state lifecycles for entities such as order processing (pending, paid, shipped) or document workflows (draft, review, published) using AASM.
  • Creating standardized business operations with strict input validation and predictable outcomes to improve codebase reliability.
  • Orchestrating complex workflows where specific business interactions trigger automated state transitions and side effects.
  • Accelerating Ruby on Rails development by automating the boilerplate code required for state machine events and typed operation schemas.
namebusiness-logic-coder
descriptionImplement business logic with ActiveInteraction and AASM state machines. Routes to specialized skills for typed operations and state management.

Business Logic Patterns

Orchestrator for structured business logic in Rails.

Skill Routing

Need Skill Use When
Typed operations active-interaction-coder Creating business operations, refactoring service objects
State machines aasm-coder Implementing workflows, managing state transitions

When to Use Each

ActiveInteraction

Use for operations - things that happen once:

  • User registration
  • Order placement
  • Payment processing
  • Data imports
  • Report generation
# Example: One-time operation with typed inputs
outcome = Users::Create.run(email: email, name: name)

AASM

Use for state management - things with lifecycle:

  • Order status (pending → paid → shipped)
  • Subscription state (trial → active → cancelled)
  • Document workflow (draft → review → published)
  • Task status (todo → in_progress → done)
# Example: Stateful entity with transitions
order.pay!  # pending → paid
order.ship! # paid → shipped

Combined Pattern

Often used together - interactions trigger state changes:

module Orders
  class Process < ActiveInteraction::Base
    object :order, class: Order

    def execute
      order.process!  # AASM transition
      fulfill_order(order)
      order
    end
  end
end

Setup

# Gemfile
gem "active_interaction", "~> 5.3"
gem "aasm", "~> 5.5"

Quick Reference

ActiveInteraction:

  • .run - Returns outcome (check .valid?)
  • .run! - Raises on failure
  • compose - Call nested interactions

AASM:

  • .event! - Transition or raise
  • .event - Transition or return false
  • .may_event? - Check if transition valid
  • .aasm.events - List available events
  • event-sourcing-coder - Record domain events from state transitions