davila7/claude-code-templates / cli-tool/components/skills/ai-research/loki-mode
loki-mode
FlaggedMulti-agent autonomous startup system for Claude Code. Triggers on "Loki Mode". Orchestrates 100+ specialized agents across engineering, QA, DevOps, security, data/ML, business operations, marketing, HR, and customer success. Takes PRD to fully deployed, revenue-generating product with zero human intervention. Features Task tool for subagent dispatch, parallel code review with 3 specialized reviewers, severity-based issue triage, distributed task queue with dead letter handling, automatic deployment to cloud providers, A/B testing, customer feedback loops, incident response, circuit breakers, and self-healing. Handles rate limits via distributed state checkpoints and auto-resume with exponential backoff. Requires --dangerously-skip-permissions flag.
autonomy/README.md
View on GitHub# Loki Mode - Autonomous Runner
Single script that handles everything: prerequisites, setup, Vibe Kanban monitoring, and autonomous execution with auto-resume.
## Quick Start
```bash
# Run with a PRD
./autonomy/run.sh ./docs/requirements.md
# Run interactively
./autonomy/run.sh
```
That's it! The script will:
1. Check all prerequisites (Claude CLI, Python, Git, etc.)
2. Verify skill installation
3. Initialize the `.loki/` directory
4. **Start Vibe Kanban background sync** (monitor tasks in real-time)
5. Start Claude Code with **live output** (no more waiting blindly)
6. Auto-resume on rate limits or interruptions
7. Continue until completion or max retries
## Live Output
Claude's output is displayed in real-time - you can see exactly what's happening:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CLAUDE CODE OUTPUT (live)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[Claude's output appears here in real-time...]
```
## Status Monitor (Built-in)
The runner updates `.loki/STATUS.txt` every 5 seconds with task progress:
```
╔════════════════════════════════════════════════════════════════╗
║ LOKI MODE STATUS ║
╚════════════════════════════════════════════════════════════════╝
Updated: Sat Dec 28 15:30:00 PST 2025
Phase: DEVELOPMENT
Tasks:
├─ Pending: 10
├─ In Progress: 1
├─ Completed: 5
└─ Failed: 0
Monitor: watch -n 2 cat .loki/STATUS.txt
```
### Monitor in Another Terminal
```bash
# Watch status updates live
watch -n 2 cat .loki/STATUS.txt
# Or view once
cat .loki/STATUS.txt
```
## What Gets Checked
| Prerequisite | Required | Notes |
|--------------|----------|-------|
| Claude Code CLI | Yes | Install from https://claude.ai/code |
| Python 3 | Yes | For state management |
| Git | Yes | For version control |
| curl | Yes | For web fetches |
| Node.js | No | Needed for some builds |
| jq | No | Helpful for JSON parsing |
## Configuration
Environment variables:
```bash
# Retry settings
export LOKI_MAX_RETRIES=50 # Max retry attempts (default: 50)
export LOKI_BASE_WAIT=60 # Base wait time in seconds (default: 60)
export LOKI_MAX_WAIT=3600 # Max wait time in seconds (default: 3600)
# Skip prerequisite checks (for CI/CD or repeat runs)
export LOKI_SKIP_PREREQS=true
# Run with custom settings
LOKI_MAX_RETRIES=100 LOKI_BASE_WAIT=120 ./autonomy/run.sh ./docs/prd.md
```
## How Auto-Resume Works
```
┌─────────────────────────────────────────────────────────────┐
│ ./autonomy/run.sh prd.md │
└─────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────┐
│ Check Prerequisites │
└───────────────────────┘
│
▼
┌───────────────────────┐
│ Initialize .loki/ │
└───────────────────────┘
│
▼
┌────────────────────────────────┐
│ Run Claude Code with prompt │◄────────────────┐
└────────────────────────────────┘ │
│ │
▼ │
┌───────────────────────┐ │
│ Claude exits │ │
└───────────────────────┘ │
│ │
┌───────────┴───────────┐ │
▼ ▼ │
┌───────────────┐ ┌───────────────┐ │
│ Completed? │──Yes──│ SUCCESS! │ │
└───────────────┘ └───────────────┘ │
│ No │
▼ │
┌───────────────┐ │
│ Wait (backoff)│─────────────────────────────────────┘
└───────────────┘
```
## State Files
The autonomy runner creates:
```
.loki/
├── autonomy-state.json # Runner state (retry count, status)
├── logs/
│ └── autonomy-*.log # Execution logs
├── state/
│ └── orchestrator.json # Loki Mode phase tracking
└── COMPLETED # Created when done
```
## Resuming After Interruption
If you stop the script (Ctrl+C) or it crashes, just run it again:
```bash
# State is saved, will resume from last checkpoint
./autonomy/run.sh ./docs/requirements.md
```
The script detects the previous state and continues from where it left off.
## Differences from Manual Mode
| Feature | Manual Mode | Autonomy Mode |
|---------|-------------|---------------|
| Start | `claude --dangerously-skip-permissions` | `./autonomy/run.sh` |
| Prereq check | Manual | Automatic |
| Rate limit handling | Manual restart | Auto-resume |
| State persistence | Manual checkpoint | Automatic |
| Logging | Console only | Console + file |
| Max runtime | Session-based | Configurable retries |
## Troubleshooting
### "Claude Code CLI not found"
```bash
npm install -g @anthropic-ai/claude-code
# or visit https://claude.ai/code
```
### "SKILL.md not found"
Make sure you're running from the loki-mode directory or have installed the skill:
```bash
# Option 1: Run from project directory
cd /path/to/loki-mode
./autonomy/run.sh
# Option 2: Install skill globally
cp -r . ~/.claude/skills/loki-mode/
```
### "Max retries exceeded"
The task is taking too long or repeatedly failing. Check:
```bash
# View logs
cat .loki/logs/autonomy-*.log | tail -100
# Check orchestrator state
cat .loki/state/orchestrator.json
# Increase retries
LOKI_MAX_RETRIES=200 ./autonomy/run.sh ./docs/prd.md
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |