Help us improve
Share bugs, ideas, or general feedback.
From rubyku
AI Agent architecture patterns for workflow automation in this plugin using RubyLLM
npx claudepluginhub ghozimahdi/gm-claude-plugins --plugin rubykuHow this skill is triggered — by the user, by Claude, or both
Slash command
/rubyku:ai-agentsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**State (DB)** → **Planner (Agent)** → **Action (Job/Logic/LLM)** → **Trace (History)**
Provides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Structures git workflow practices for committing, branching, resolving conflicts, and organizing work across parallel streams. Use when making any code change.
Share bugs, ideas, or general feedback.
State (DB) → Planner (Agent) → Action (Job/Logic/LLM) → Trace (History)
app/agents/
├── base_agent.rb # Base class
├── task_agent.rb # Multi-step workflow
├── task_group_agent.rb # Batch processing
├── document_ocr_agent.rb # OCR processing
├── document_classifier.rb # Document classification
├── form_fill_agent.rb # AI form filling
└── tools/ # Reusable tools
└── ...
class BaseAgent
def initialize(record)
@record = record
end
def run
raise NotImplementedError, "Subclasses must implement #run"
end
private
def log_action(action, details = {})
@record.ai_action_histories.create!(
action: action,
details: details
)
end
end
class TaskAgent < BaseAgent
def run
case @record.status
when "pending"
check_prerequisites_and_notify
when "waiting_response"
check_deadline_and_escalate
when "documents_received"
validate_and_advance
end
end
private
def check_prerequisites_and_notify
if prerequisites_met?
@record.update!(status: :in_progress)
TaskMailer.started(@record).deliver_later
log_action("advanced_to_in_progress")
end
end
def check_deadline_and_escalate
if @record.due_at < 3.days.from_now
TaskMailer.deadline_approaching(@record).deliver_later
log_action("deadline_warning_sent")
end
end
end
Schedule future actions with state validation:
# Schedule a reminder
AiScheduledEvent.create!(
eventable: @task,
scheduled_at: 3.days.from_now,
workflow_status: "waiting_response", # MUST match current status when executing
event_type: "send_reminder",
priority: :normal
)
Rules:
workflow_status — events check status before executingpriority for urgent eventsProcessAiScheduledEventsJob# Use LLM for intelligent reasoning
def classify_document(document)
chat = RubyLLM.chat(model: "gpt-4o")
response = chat.ask(
"Classify this document: #{document.text_content}"
)
parse_classification(response)
end
# app/jobs/run_task_agent_job.rb
class RunTaskAgentJob < ApplicationJob
queue_as :default
def perform(task)
TaskAgent.new(task).run
end
end
app/agents/BaseAgent with run methodapp/jobs/ for async executionapp/agents/tools/ if reusabletest/agents/class TaskAgentTest < ActiveSupport::TestCase
test "advances pending task when prerequisites met" do
task = tasks(:pending_with_prerequisites)
agent = TaskAgent.new(task)
agent.run
assert task.reload.in_progress?
end
test "sends deadline warning for approaching due date" do
task = tasks(:waiting_due_soon)
assert_enqueued_emails 1 do
TaskAgent.new(task).run
end
end
end