Coding

Autonomous Skill

Try it

Execute long-running, multi-session tasks autonomously using Claude Code headless mode or in-session hook-based loops. Supports structured task decomposition...

What it does

Autonomous Skill - Multi-Session Task Execution

The skill document

Autonomous Skill - Multi-Session Task Execution

Execute complex tasks across multiple Claude Code sessions with automatic continuation, progress tracking, and two completion mechanisms (promise tags + checkbox counting).

Two Execution Modes

Headless Mode (default)

Spawns claude -p child sessions in a bash loop. Best for background/unattended work.

bash /scripts/run-session.sh "Build a REST API" --max-sessions 10

Hook Mode (in-session)

Uses a Stop hook to intercept session exit and feed the prompt back. Runs inside the current interactive session — no nesting issues.

bash /scripts/setup-loop.sh "Build a REST API" --max-iterations 10

Two Task Strategies

Structured (default)

Full task decomposition: Initializer creates task_list.md with phased sub-tasks, Executor picks up and completes them one by one. Best for complex, multi-phase projects.

bash /scripts/run-session.sh "Build a REST API for todo app"

Lightweight (--lightweight)

Ralph-style iteration: same prompt repeated each session, no task decomposition. Best for iterative tasks with clear success criteria (TDD, bug fixing, refactoring).

bash /scripts/run-session.sh "Fix all failing tests in src/" --lightweight

Completion Detection

Two complementary mechanisms — whichever triggers first wins:

  1. Promise tags (both modes): The agent outputs DONE when work is genuinely complete. Default promise is DONE; customize with --completion-promise. The agent is instructed to only output the promise when the work is truly finished — not to escape the loop.

  2. Checkbox counting (structured mode only): All [ ] items in task_list.md are marked [x].

Directory Layout

project-root/
├── .autonomous/
│   └── /
│       ├── task_list.md      # Master checklist (structured mode)
│       ├── progress.md       # Per-session progress log
│       ├── .mode             # "structured" or "lightweight"
│       ├── sessions/         # Transcript logs per session
│       │   ├── session-001.log
│       │   └── session-002.log
│       └── run.lock          # Prevents concurrent runs
└── .claude/
    └── autonomous-loop.local.md  # Hook mode state (when active)

Headless Mode — CLI Reference

bash /scripts/run-session.sh "task description" [OPTIONS]
FlagDescriptionDefault
--lightweightRalph-style iteration (no task decomposition)structured
--task-name Explicit task nameAuto-generated
--continue, -cContinue most recent or named task
--list, -lList all tasks with progress
--completion-promise TEXTPromise phrase for completionDONE
--max-sessions NStop after N sessionsUnlimited
--max-budget N.NNPer-session dollar budget5.00
--model Model alias or full namesonnet
--fallback-model Fallback if primary overloaded
--effort Thinking effort (low/medium/high)high
--no-auto-continueRun one session only
--permission-mode Permission modeauto
--add-dir Extra directories to allow

Hook Mode — Setup

For in-session loops (no child process spawning):

bash /scripts/setup-loop.sh "task description" [OPTIONS]
FlagDescriptionDefault
--mode structured|lightweightTask strategystructured
--max-iterations NMax loop iterationsUnlimited
--completion-promise TEXTPromise phraseDONE
--task-name NAMEExplicit task nameAuto-generated

The hook is registered in hooks/hooks.json. When active, the Stop hook reads .claude/autonomous-loop.local.md and blocks exit until the promise is detected or max iterations reached.

To cancel an active hook-mode loop: rm .claude/autonomous-loop.local.md

Workflow Detail

Structured Mode

  1. Initializer Agent — analyzes task, creates phased task_list.md, begins work
  2. Executor Agent — reads task list + progress, verifies previous work, completes next task
  3. Auto-Continue — checks promise tags + checkboxes; if not done, spawns next session

Lightweight Mode

  1. Same prompt fed each iteration
  2. Agent sees its previous work in files and git history
  3. Iterates until work is complete and promise tag is output
  4. No task_list.md — completion is purely promise-based

When to Use Which

ScenarioStrategyMode
Build a full applicationStructuredHeadless
Fix all failing testsLightweightEither
Refactor a moduleLightweightEither
Multi-phase projectStructuredHeadless
Quick iterative fixLightweightHook
Overnight batch workStructuredHeadless

Important Constraints

  1. task_list.md is append-only for completions: Only change [ ][x]
  2. One runner per task: Lock file prevents concurrent sessions on same task
  3. Project files stay in project root: .autonomous/ is only for tracking
  4. Promise integrity: The agent must not output DONE until genuinely complete
  5. Cost awareness: Default per-session budget is $5. Adjust with --max-budget

Troubleshooting

IssueSolution
"Lock file exists"Previous run crashed. Remove .autonomous//run.lock
Session keeps failingCheck sessions/session-NNN.log for errors
Nested session errorScript auto-unsets CLAUDECODE; use hook mode as alternative
Hook loop won't stopDelete .claude/autonomous-loop.local.md
Task not foundRun --list to see available tasks
Want to restartDelete the task directory and start fresh
Cost too highLower --max-budget or use --model sonnet

Related skills

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai21 installs8 stars

Read and write Excel workbooks, worksheets, ranges, tables, and charts in OneDrive through Microsoft Graph with managed OAuth.

by byungkyu800 installs42 stars

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván1 installs

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván1 installs

More from feiskyer

Browse all skills

深度调研的多Agent编排工作流:把一个调研目标拆成可并行子目标,用 Claude Code 非交互模式(`claude -p`)运行子进程;联网与采集优先使用已安装的 skills,其次使用 MCP 工具;用脚本聚合子结果并分章精修,最终交付"成品报告文件路径 + 关键结论/建议摘要"。用于:系统性网页/资料调...

by feiskyer39 installs1 stars

Use when user asks to leverage codex, gpt-5, or gpt-5.1 to implement something (usually implement a plan or feature designed by Claude). Provides non-interac...

by feiskyer38 installs1 stars

Use when user asks to leverage claude or claude code to do something (e.g. implement a feature design or review codes, etc). Provides non-interactive automat...

by feiskyer35 installs1 stars

Use xfetch CLI to fetch X/Twitter data - tweets, user profiles, search results, timelines, lists, DMs, and notifications. Use this skill whenever you need to...

by feiskyer30 installs1 stars

Extract subtitles/transcripts from YouTube videos. Triggers: "youtube transcript", "extract subtitles", "video captions", "视频字幕", "字幕提取", "YouTube转文字", "提取字幕".

by feiskyer34 installs2 stars

Generate or edit images using Google Gemini API via nanobanana. Triggers: "nanobanana", "generate image", "create image", "edit image", "AI drawing", "图片生成",...

by feiskyer57 installs1 stars