ai-agentslisted
Install: claude install-skill ghozimahdi/gm-aiagent-plugins
## AI Agent Patterns
### Architecture
**State (DB)** → **Planner (Agent)** → **Action (Job/Logic/LLM)** → **Trace (History)**
### Directory Structure
```
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
└── ...
```
### Base Agent
```ruby
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
```
### Agent Implementation
```ruby
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(@re