Alfred
Agentic AI automation - From SPEC to code with autonomous loop
---
description: "Agentic AI automation - From SPEC to code with autonomous loop"
argument-hint: '"task description" [--loop] [--max N] [--seq] | resume SPEC-XXX'
type: utility
allowed-tools: Task, AskUserQuestion, TodoWrite, Bash, Read, Write, Edit, Glob, Grep
model: inherit
---
## Pre-execution Context
!git status --porcelain
!git branch --show-current
## Essential Files
@.moai/config/sections/ralph.yaml
@.moai/config/sections/git-strategy.yaml
@.moai/config/sections/quality.yaml
@.moai/config/sections/llm.yaml
---
# /moai:alfred - Agentic AI Autonomous Automation
## Core Principle: Fully Autonomous Automation
User provides a goal, AI autonomously plans, executes, and completes.
USER: "Add authentication feature"
↓
AI: Explore → Plan → Implement → Verify → Repeat
↓
AI: All issues resolved
↓
AI:
## Command Purpose
Autonomously execute the full MoAI workflow:
1. **Parallel Exploration** (Explore + Research simultaneously)
2. **SPEC Generation** (after user approval)
3. **DDD Implementation** (auto iterative fixing)
4. **Documentation Sync**
5. **Completion Marker Detection** (`<moai>DONE</moai>`)
Feature Description: $ARGUMENTS
## Quick Start
```bash
# Default autonomous execution (parallel exploration)
/moai:alfred "Add JWT authentication"
# Enable auto loop (max 50 iterations)
/moai:alfred "JWT auth" --loop --max 50
# Sequential exploration + auto loop
/moai:alfred "JWT auth" --loop --sequential
# Resume previous work
/moai:alfred resume SPEC-AUTH-001
Command Options
| Option | Alias | Description | Default |
|---|---|---|---|
--loop |
- | Enable auto iterative fixing | ralph.yaml |
--max N |
--max-iterations | Maximum iteration count | 100 |
--sequential |
--seq | Sequential exploration (for debugging) | Parallel |
--branch |
- | Auto-create feature branch | git-strategy |
--pr |
- | Auto-create PR | git-strategy |
--resume SPEC |
- | Resume previous work | - |
Completion Promise
AI must add a marker when work is complete:
## Complete
All implementation complete, tests passing, docs updated. <moai>DONE</moai>
Marker Types:
<moai>DONE</moai>- Task complete<moai>COMPLETE</moai>- Full completion<moai:done />- XML format
Agentic Autonomous Flow
START: /moai:alfred "task description"
PHASE 0: Parallel Exploration (autonomous)
[SOFT] Apply --ultrathink keyword for autonomous workflow orchestration
WHY: Alfred must analyze task complexity, determine routing strategy, and select appropriate agents
IMPACT: Sequential thinking ensures optimal agent delegation and execution strategy
┌── Explore Agent: Codebase analysis
├── Research Agent: Documentation/issue search
└── Quality Agent: Current state diagnosis
↓
Integration → Execution plan generation
PHASE 1: SPEC Generation
└── Written in EARS format
↓
User Approval
↓
PHASE 2: DDD Implementation (autonomous loop)
│
└── WHILE (issues_exist AND iteration < max):
├── Diagnostics (LSP + Tests + Coverage)
├── TODO generation
├── Fix execution
├── Verification
└── Completion marker detected? → BREAK
↓
PHASE 3: Documentation Sync
└── Add marker: <moai>DONE</moai>
↓
COMPLETE
Phase 0: Parallel Exploration Implementation
By default, execute three exploration agents simultaneously for optimal performance:
Step 1 - Launch Parallel Agent Tasks:
In a single response, invoke all three Task tools simultaneously (Claude Code executes them in parallel automatically):
Explore Agent:
- subagent_type: Explore
- description: Codebase analysis for task context
- prompt: Include user task description, request relevant files, architecture patterns, existing implementations
Research Agent:
- subagent_type: Explore (with WebSearch/WebFetch focus)
- description: External documentation and best practices research
- prompt: Include user task description, request API docs, library documentation, similar implementations
Quality Agent:
- subagent_type: manager-quality
- description: Current project quality assessment
- prompt: Request test coverage status, lint status, technical debt assessment
All three Task calls in the same response triggers automatic parallel execution (up to 10 concurrent).
Step 2 - Collect and Integrate Results:
After all three agents complete:
Collect outputs from each agent response
Extract key findings:
- From Explore: Relevant files, architecture patterns, existing code to reference
- From Research: External knowledge, best practices, API patterns
- From Quality: Current test coverage, code quality baseline, known issues
Synthesize into unified exploration report
Step 3 - Generate Execution Plan:
Based on integrated findings:
- Identify implementation approach
- List files to create/modify
- Define test strategy
- Estimate scope and complexity
Step 4 - User Approval Checkpoint:
Present integrated findings and proposed plan to user via AskUserQuestion:
- Options: Proceed to SPEC creation, Modify approach, Cancel
Error Handling:
If any agent fails:
- Continue with results from successful agents
- Note missing information in plan
- Offer to retry failed agent or proceed with partial information
WHY: Parallel exploration reduces Phase 0 time from 45-90 seconds to 15-30 seconds (2-3x speedup) IMPACT: Faster initial context gathering without sacrificing comprehensiveness
TODO-Obsessive Rule
[HARD] TodoWrite Tool Mandatory Usage:
- Immediate Creation: When issues are discovered, call TodoWrite tool to add items with pending status
- Immediat
Maintain Alfred?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[Alfred on getagentictools](https://getagentictools.com/loops/hnabyz-bot-moai-alfred-agentic-ai-autonomous-automation?ref=badge)