Let the AI work while you're away from the keyboard!
A tool-agnostic CLI for autonomous AI-driven software development. afk runs your AI coding tasks in a loop, spawning a fresh agent instance for each iteration - so context never overflows and the AI stays sharp.
AI coding agents are powerful, but they have a fatal flaw: context window exhaustion. The longer an AI works on a problem, the more context it accumulates - past attempts, dead ends, outdated information. Eventually, it becomes bloated and confused, making worse decisions the longer it runs.
afk solves this with the Ralph Wiggum pattern - a kanban-style approach where each task gets a fresh AI instance with clean context. Think of it like a well-organised team: each developer picks up one ticket, completes it, and moves on. No cognitive overload. No stale context.
The result? AI that can work autonomously for hours without degrading.
The technique is named after Ralph Wiggum from The Simpsons - a character who approaches each moment with fresh-eyed obliviousness, unburdened by what came before.
In AI terms, it works like this:
- Fresh start every iteration - Each loop spawns a brand new AI instance
- One task at a time - Kanban-style: pick up a task, complete it, move on
- Memory through files, not context - Progress persists via git commits, not the AI's memory
This means the AI never runs out of context, never gets confused by old attempts, and can work indefinitely without degradation.
- ๐ Git history - Commits from previous iterations
- ๐ progress.json - Task status and per-task learnings (short-term memory)
- ๐ AGENTS.md - Project-wide conventions and patterns (long-term memory)
- ๐ฐ The Ralph Wiggum Technique by Geoffrey Huntley (the originator)
- ๐ง snarktank/ralph by Ryan Carson (inspiration)
- ๐ Effective harnesses for long-running agents by Anthropic
Create a requirements document describing what you want to build. This can be high-level or as detailed as you'd like. You don't need to break it down into granular tasks yourself:
# Weather Dashboard
A simple web app that shows current weather for a given city.
Users should be able to enter a city name and see the temperature, conditions, and a 5-day forecast. Use the OpenWeather API.
The UI should be clean and mobile-friendly.afk import requirements.mdThis runs your AI CLI to analyse the PRD and break it down into small, AI-sized tasks. The output goes to .afk/tasks.json.
afk tasks # Review the tasks it generated
afk go # Start the autonomous loopThat's it. afk works through the tasks one by one, committing as it goes.
If you've already got tasks in a structured format, skip the import:
afk go TODO.md # Markdown with checkboxes: - [ ] Task name
afk go tasks.json # JSON with `afk-`style tasks array
afk go 20 # Run 20 iterations
afk go -u # Run until all tasks completeNote: These expect task lists, not raw PRDs. Use afk import to parse requirements into tasks.
# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/m0nkmaster/afk/main/scripts/install.sh | bash
# Windows (PowerShell)
irm https://raw.githubusercontent.com/m0nkmaster/afk/main/scripts/install.ps1 | iexInstalls a standalone binary - no dependencies required. Updates with afk update.
git clone https://github.com/m0nkmaster/afk.git && cd afk
cargo build --release
# Binary at target/release/afkcargo install --git https://github.com/m0nkmaster/afk| Command | Description |
|---|---|
afk go |
Zero-config: auto-detect and run |
afk go 20 |
Run 20 iterations |
afk go -u |
Run until all tasks complete |
afk go TODO.md 5 |
Use TODO.md as source, run 5 iterations |
afk go --init |
Re-run setup, then start loop |
afk go --fresh |
Clear session progress and start fresh |
| Command | Description |
|---|---|
afk status |
Show current status and tasks |
afk status -v |
Verbose output with learnings |
afk tasks |
List tasks from current PRD |
afk tasks -p |
Show only pending tasks |
afk task <id> |
Show details of a specific task |
afk done <id> |
Mark task complete |
afk fail <id> |
Mark task failed |
afk reset <id> |
Reset stuck task to pending |
| Command | Description |
|---|---|
afk import <file> |
Import requirements doc into .afk/tasks.json |
afk sync |
Sync from configured sources (alias: afk tasks sync) |
afk source add beads |
Add beads as task source |
afk source add markdown TODO.md |
Add markdown file source |
afk source add github |
Add GitHub issues (current repo) |
afk source add github owner/repo |
Add GitHub issues from specific repo |
afk source add openspec |
Add OpenSpec change proposals |
afk source add gherkin features/ |
Add Gherkin/BDD .feature files |
afk source list |
List configured sources |
afk source remove <index> |
Remove a source by index (1-based) |
GitHub source: Requires the GitHub CLI (gh) to be installed and authenticated. Fetches open issues and converts them to tasks. Priority is inferred from labels (P0/critical โ 0, P1/high โ 1, etc.).
OpenSpec source: Reads tasks from OpenSpec change proposals in openspec/changes/<change-id>/tasks.md. Enriches task context with spec deltas, proposals, and design docs.
Gherkin source: Parses .feature files (Given/When/Then). Each Scenario becomes a task with steps as acceptance criteria. Supports single files or directories.
| Command | Description |
|---|---|
afk verify |
Run quality gates (lint, test, types) |
afk prompt |
Preview next iteration's prompt |
afk prompt -c |
Copy prompt to clipboard |
| Command | Description |
|---|---|
afk init |
Initialise afk (auto-detects project) |
afk init --force |
Re-run setup including AI CLI selection |
afk use |
Interactively switch AI CLI |
afk use claude |
Switch to a specific AI CLI |
afk use --list |
List available AI CLIs with install status |
afk archive |
Archive and clear session (ready for fresh work) |
afk archive list |
List archived sessions |
afk config show |
Show all config values |
afk config get <key> |
Get a specific config value |
afk config set <key> <value> |
Set a config value |
afk config explain |
Show documentation for config keys |
afk update |
Update afk to latest version |
Tip: When you switch git branches, afk go detects the change and prompts to archive the previous session automatically.
afk works with any CLI that accepts prompts as the final argument:
| CLI | Command | Notes |
|---|---|---|
| Claude Code | claude |
Anthropic's terminal agent |
| Cursor Agent | agent |
Cursor's CLI agent |
| Codex | codex |
OpenAI's CLI |
| Aider | aider |
AI pair programming |
| Amp | amp |
Sourcegraph's agent |
| Kiro | kiro |
Amazon's AI CLI |
On first run, afk go auto-detects installed CLIs and prompts you to select one.
Each task must complete in a single AI context window. Tasks that are too large cause context overflow and poor code quality.
Right-sized โ
- Add a database column
- Create a UI component
- Write tests for a module
- Fix a specific bug
Too large โ
- "Build the dashboard"
- "Add authentication"
- "Refactor the API"
When in doubt, split. Five small tasks are better than one large task.
Each iteration:
- Load tasks from configured sources (json, markdown, beads, github, openspec, gherkin)
- Check completion โ if all tasks done, exit
- Generate prompt with next task, context files, and session learnings
- Spawn fresh AI โ a brand new CLI instance with clean context
- AI works autonomously:
- Implements the task
- Runs
afk verify(quality gates: lint, test, typecheck) - Fixes issues until verify passes
- Commits changes
- Marks task complete in
.afk/tasks.json - Records learnings
- Loop โ repeat from step 1
The key point: afk is an orchestrator, not an AI itself. It spawns your chosen AI CLI, gives it a task, and lets it work. Each iteration gets a fresh instance that reads state from files, does the work, and writes state back. No context accumulation, no degradation.
- docs/user-guide.md - Complete command reference and workflow examples
- docs/architecture.md - Technical overview for contributors
- CONTRIBUTING.md - How to contribute
- Ralph Wiggum pattern by Geoffrey Huntley
- snarktank/ralph by Ryan Carson
- Effective harnesses for long-running agents by Anthropic
- Beads by Steve Yegge
MIT