Enables OpenClaw agents to autonomously execute prioritized tasks on a heartbeat loop with logging, auditing, error handling, and workspace hygiene.
# God Mode — True Autonomous AI Agent Loop
## What This Does
Turns any OpenClaw agent into a continuously executing autonomous worker. No more "wait for user message." The agent wakes on a heartbeat cycle, reads its task queue, picks the highest-priority task, executes it, audits the result, logs everything, and sleeps until next cycle.
## How It Works
1. **Heartbeat triggers** → OpenClaw sends heartbeat message to agent session
2. **Agent reads TASKS.md** → ordered priority queue of work items
3. **Agent picks top task** → executes it using available tools
4. **Agent writes result** → logs to `memory/YYYY-MM-DD.md` + updates TASKS.md
5. **Agent self-audits** → was the result good? What to improve?
6. **Agent sleeps** → waits for next heartbeat
## Architecture
```
HEARTBEAT.md → What to check/do on each heartbeat
TASKS.md → Priority queue of autonomous work items
memory/YYYY-MM-DD.md → Execution log (append-only)
memory/god-mode-state.json → State tracking (last task, cycle count, errors)
```
## Files
### TASKS.md Format
```markdown
# Task Queue — Priority Order
## Priority 1 (Critical)
- [ ] Task description here | context/goals
## Priority 2 (High)
- [ ] Task description | context
## Priority 3 (Medium)
- [ ] Task description | context
## Completed
- [x] Done task | result summary | completed YYYY-MM-DD HH:MM
```
### god-mode-state.json Format
```json
{
"lastCycle": "2026-04-16T07:00:00Z",
"cycleCount": 42,
"lastTask": "Check Moltbook engagement",
"lastResult": "success",
"errors": 0,
"consecutiveErrors": 0,
"totalTasksCompleted": 15
}
```
## Heartbeat Behavior
On every heartbeat, the agent:
1. **Read state** — load `god-mode-state.json`
2. **Error check** — if 3+ consecutive errors, pause and log warning
3. **Read TASKS.md** — pick first uncompleted task
4. **Execute task** — do the work
5. **Log result** — append to daily memory
6. **Update state** — increment cycle, record result
7. **Update TASKS.md** — mark task done, add any new tasks discovered
8. **Self-audit** — one line: was this cycle productive?
## Self-Cleaning (Auto-Hygiene)
Every 12th cycle (roughly hourly at 5-min intervals), the agent runs a hygiene sweep:
### Workspace Hygiene
- Scan workspace root for files > 7 days old and not in core set (AGENTS.md, SOUL.md, USER.md, IDENTITY.md, MEMORY.md, HEARTBEAT.md, TASKS.md, TOOLS.md, STATE.md)
- Move stale files to `memory/archive/`
- Delete empty directories
- Remove stale pending flags (`.audit-pending`, `.work-pending`, etc.)
- Clean `node_modules/` if present and not actively used
### Memory Hygiene
- Archive daily logs older than 7 days to `memory/archive/`
- Archive research/reference files not accessed in last 7 days
- Compress `memory/archive/` if > 10MB
- If TASKS.md > 100 lines → archive completed section
### Log Hygiene
- Truncate log files (`*.log`) > 1MB → keep last 100 lines
- Delete stale state files (test JSON, temp files)
- Clean `__pycache__` directories
### Hygiene Rules
- NEVER delete: AGENTS.md, SOUL.md, USER.md, IDENTITY.md, MEMORY.md, HEARTBEAT.md, TASKS.md, TOOLS.md, STATE.md
- NEVER delete: `memory/YYYY-MM-DD.md` for today and yesterday
- NEVER delete: `scripts/` directory
- NEVER delete: `.secrets/`, `.git/`
- ALWAYS move to archive before deleting — nothing is truly deleted
- Log every hygiene action in daily notes
## Guardrails
- **Never execute red-line tasks** (money, contracts, irreversible actions) without human approval
- **Max 1 task per heartbeat cycle** — prevents runaway execution
- **Error circuit breaker** — 3 consecutive errors = pause + alert human
- **Quiet hours** — respect configured quiet hours (no work, only monitoring)
- **Audit every cycle** — no silent work, every action logged
- **Self-cleaning** — hygiene sweep every 12th cycle keeps workspace lean
## Installation
1. Copy this skill to `~/.openclaw/workspace/skills/god-mode/`
2. Create `TASKS.md` in workspace root
3. Create `memory/god-mode-state.json` with initial state
4. Add heartbeat schedule to OpenClaw config (every 30 min recommended)
5. Update `HEARTBEAT.md` to reference God Mode protocol
## Pricing
- ClawHub: $49 one-time
- Includes: task queue, state tracking, audit log, guardrails, documentation
- Target: OpenClaw users who want their agents truly autonomous
## Why This Is Different
- Not a prompt hack — infrastructure-based autonomy
- Built on OpenClaw's heartbeat system (250K+ star platform)
- Memory persists across sessions
- Audit trail for every action
- Guardrails prevent runaway behavior
- Actually works (we use it ourselves)
don't have the plugin yet? install it then click "run inline in claude" again.
added explicit decision points for error circuit breaker, quiet hours, red-line task detection,
this skill transforms any openclaw agent into a continuously executing autonomous worker that wakes on heartbeat cycles, reads a priority task queue, executes the highest-priority item, logs and audits results, and self-cleans its workspace. use this when you want your agent to work without waiting for user input, with full audit trails and guardrails against runaway execution.
external connections:
workspace files required:
TASKS.md (priority task queue, markdown format, agent-readable)memory/god-mode-state.json (state tracking between cycles, json format)HEARTBEAT.md (cycle behavior specification, markdown format)memory/YYYY-MM-DD.md (daily execution log, created auto on first cycle)permissions needed:
memory/ and memory/archive/optional configurations:
heartbeat received → openclaw sends heartbeat message to agent session, triggering god mode startup.
load cycle state → agent reads god-mode-state.json from disk.
memory/god-mode-state.jsoncheck error circuit breaker → if consecutiveErrors >= 3, log warning, skip task execution, alert human via logs, proceed only to state update and sleep.
check quiet hours → if current time falls in configured quiet hours window, skip task execution, log monitoring event, jump to step 9.
read task queue → agent reads TASKS.md, scans for first uncompleted task (unmarked checkbox [ ] not [x]).
TASKS.mdexecute task → agent uses available tools to complete the task described in step 5. execution runs with timeout (recommend 5-10 min per task, configurable).
append to daily log → agent appends execution record to memory/YYYY-MM-DD.md (today's date, created if missing). format: timestamp, task name, result, execution time, any errors.
memory/YYYY-MM-DD.md updated with new lineself-audit and update state → agent writes one audit line to daily log (e.g., "cycle productive: yes, task completed successfully"). agent increments cycleCount, records lastTask, lastResult, updates lastCycle timestamp. if result.success = true, reset consecutiveErrors to 0, increment totalTasksCompleted; if result.success = false, increment both errors and consecutiveErrors.
god-mode-state.json updated on diskmark task complete in queue → if step 6 succeeded, agent marks checkbox [x] in TASKS.md. if any new subtasks were discovered during execution, agent appends them to TASKS.md under appropriate priority.
TASKS.md updatedcheck if hygiene cycle → if cycleCount mod 12 = 0, run workspace hygiene (step 11). else skip to step 12.
run workspace hygiene → agent scans workspace following rules in "self-cleaning" section below. moves stale files to memory/archive/, compresses if needed, logs all actions.
sleep until next heartbeat → agent goes idle, waiting for next heartbeat signal from openclaw.
error circuit breaker: if consecutiveErrors >= 3, skip task execution (step 6 and 9), log warning alert, proceed to state update and sleep. this prevents runaway failure loops. human must manually reset consecutiveErrors in god-mode-state.json to 0 to resume autonomy.
quiet hours: if current time falls within configured quiet hours (e.g., 10pm to 6am), skip task execution and logging, only perform state monitoring. this respects human sleep schedules and defined agent downtime. if no quiet hours configured, agent runs 24/7.
red-line task detection: if task description contains any of these keywords (money, payment, contract, delete, fire, irreversible, critical infrastructure), agent logs task but does not execute. instead, agent appends flag [HUMAN-APPROVAL-REQUIRED] to task in TASKS.md and alerts human via logs. human must manually approve by adding [APPROVED] flag before agent will execute.
task queue empty: if no uncompleted tasks found in TASKS.md, agent logs "queue empty" to daily log, does not increment totalTasksCompleted, resets consecutiveErrors to 0, and proceeds to sleep. this is normal, not an error.
execution timeout: if task execution exceeds configured timeout (default 5-10 min), agent terminates execution, logs timeout error, marks task as failed, increments consecutiveErrors, and proceeds to state update and sleep.
workspace hygiene: if cycleCount mod 12 = 0, run hygiene sweep. else skip. this keeps workspace lean on a schedule. if workspace is under 100MB and has no files > 7 days old, hygiene sweep logs "workspace clean" and exits early.
success looks like:
god-mode-state.json updated after every cycle with:
memory/YYYY-MM-DD.md appended with one line per cycle:
HH:MM:SS | task name | success/failure | execution time (s) | error details (if any) | audit note14:22:45 | Check Moltbook engagement | success | 28 | none | cycle productive: yes, engaged 12 usersTASKS.md updated:
[HUMAN-APPROVAL-REQUIRED] if detectedmemory/archive/ created and populated if hygiene cycle runs:
.tar.gz if archive > 10MBdata formats are strictly yaml/json/markdown, human and machine readable. no binary formats. all timestamps in iso 8601 UTC.
the user knows the skill worked when:
daily log appears → memory/YYYY-MM-DD.md exists and contains timestamped entries, one per heartbeat cycle, showing tasks attempted and results.
state file updates → god-mode-state.json cycleCount increments on each heartbeat, lastCycle timestamp moves forward, totalTasksCompleted increases when tasks succeed.
tasks get marked done → items in TASKS.md marked [x] when completed, moved to "Completed" section with timestamp, proving execution happened.
no manual intervention needed → once configured, agent runs autonomously, no user needs to prompt it or check on it between heartbeats. work happens on schedule.
audit trail is complete → every action logged with timestamp, task name, result, execution time, errors if any. audit trail is append-only, immutable, and reviewable.
workspace stays clean → on hygiene cycles, stale files moved to archive, no junk accumulates in workspace root, memory/archive/ grows as logs age.
guardrails fire on red-line tasks → if task contains "money", "contract", "delete", etc., agent does not execute, instead flags it for human approval in logs and TASKS.md.
consecutive errors trigger pause → if 3+ tasks fail in a row, agent logs alert and stops executing new tasks, waiting for human to investigate and reset the error counter.
if god mode is broken, none of these signals appear. daily log stays empty. state file does not update. TASKS.md does not change. workspace gets messy. no audit trail.