gptodo

v0.1.0 Task management and work queue generation utilities for gptme agents packages/gptodo View on GitHub

gptodo

A file-based task manager and work-queue CLI for autonomous AI agents. Tasks are Markdown files with YAML frontmatter in a git repository, so an agent's to-do list survives across sessions, shows up in diffs, and can be edited by humans and agents alike. gptodo answers the question a long-running agent asks at the start of every session: what should I work on next?

Status: beta. Used daily by production gptme agents. The core task commands (status, ready, next, show, edit, claim, add, lint) are stable; the sub-agent and worktree commands are more experimental.

gptodo is optional. gptme does not require it, and an agent can track work in GitHub Issues, Linear, a single TODO.md, or anything else. gptodo is one well-integrated option, and it can import from GitHub and Linear if you want both.

Contents

Why gptodo

An agent that runs for weeks across hundreds of sessions has no memory between sessions except what it writes down. Keeping task state as plain files in the agent's own repo means:

How it fits with gptme

Piece Role
gptme-agent-template The agent workspace template. Its TASKS.md and tasks/ directory follow gptodo's conventions out of the box.
gptme-gptodo A gptme plugin that wraps the gptodo CLI as Python functions so a "coordinator" agent can delegate work to sub-agents.
gptme-coordination SQLite-based multi-agent coordination. gptodo ready --skip-claimed reads its claims from state/coordination/coord.db. Without that database, the flag has no effect.
gptmail The companion communication package (email and agent-to-agent messaging). It is independent of gptodo.

Install

gptodo requires Python 3.10 or newer. Install it from the gptme-contrib repository:

# As a standalone CLI (recommended)
uv tool install git+https://github.com/gptme/gptme-contrib#subdirectory=packages/gptodo
# or
pipx install git+https://github.com/gptme/gptme-contrib#subdirectory=packages/gptodo

From a checkout of gptme-contrib (it is a uv workspace member):

uv sync --all-packages            # whole workspace
uv pip install -e packages/gptodo # just gptodo

python -m gptodo works the same as the gptodo entry point.

Some features need extra tools:

Feature Needs
GitHub features (generate-queue, fetch, sync, import --source github, check-waiting, worktree pr) gh, authenticated
import --source linear LINEAR_API_KEY
spawn (background sub-agents) tmux, plus gptme or claude on PATH
browse fzf (optional; falls back to a pager)

Quickstart

mkdir my-agent && cd my-agent && git init

# Create tasks. The filename (and task ID) is a slug of the title.
gptodo add --priority high --tags docs "Write project README"
echo "Run lint and tests on every push." | gptodo add "Set up CI"

# Overview of everything vs. what is actually workable
gptodo status
gptodo ready
gptodo next                 # the single best task to pick up

# Make one task depend on another
gptodo edit set-up-ci --add requires write-project-readme

# Claim, work, finish
gptodo claim write-project-readme --agent alice   # state: active, assigned_to: alice
gptodo edit write-project-readme --set state done # set-up-ci is now ready

The first gptodo add creates tasks/write-project-readme.md:

---
state: backlog
created: 2026-01-01T12:00:00.000000+00:00
priority: high
task_type: action
assigned_to: agent
tags: ["docs"]
---

# Write project README

To defer a task at creation, use gptodo add --wait 2099-01-15 "Later task". --wait accepts a date or ISO datetime (for example 2099-01-15T09:30), keeps the task out of ready until that date/time, and does not change the task's state. Datetimes accept an uppercase T or a space separator and an optional timezone offset; malformed values are rejected before task creation. --wait is rejected with --state ready_for_review, because review tasks bypass wait gates. Use --state todo for deferred work instead.

A wait: date on a task that is still blocked (waiting_for or state: waiting) is a re-check date, not a release. gptodo ready --overdue lists blocked tasks whose wait: date or typed gate.deadline has passed, oldest first, without releasing them; --json/--jsonl rows name the field in gated_by and the gate's gate_kind.

Piped input is body text, not frontmatter. A leading --- block whose keys are task fields (state, wait, priority, ...) is refused with exit 2, because they would be stored as inert body text; a block of unknown keys warns and is kept as body. Set metadata with command flags or gptodo edit --set instead, or pass --allow-frontmatter-body to keep the block as text.

Task files

A typical task:

---
state: todo
created: 2026-01-01
priority: high              # high | medium | low
task_type: project          # project (multi-step) | action (single-step)
assigned_to: alice
tags: [infra, ci]
requires:                   # blocks readiness until each one is done/cancelled
  - write-project-readme
  - https://github.com/owner/repo/issues/42   # a closed issue counts as resolved (needs `fetch` + `--use-cache`)
next_action: "Draft the workflow file"
success_criterion: "CI green on master for 3 consecutive pushes"
tracking: [https://github.com/owner/repo/issues/42]
pool: general               # general | frontier, see --pool on ready/next
---
# Set up CI

## Subtasks
- [x] Pick a CI provider
- [ ] Add workflow file

Behaviour attached to particular fields:

Task states

Each state has a specific meaning, and that meaning is enforced. Problems start when an agent uses active to mean "recently touched".

State Meaning In ready/next?
draft An in-progress plan, filed so it isn't lost but not released to agents. No
backlog Queued, not yet triaged. Default for new tasks. Yes
todo Triaged, unclaimed, and nothing blocks it. Yes
active Someone is working on it right now. Should have assigned_to and assigned_at (set by gptodo claim). Yes (already owned)
waiting Blocked on an external event such as a date, reply, approval, or merge. Should have wait: and/or waiting_for:. No
ready_for_review The work is done and awaits sign-off. No (ready --state ready_for_review)
someday A parked idea that may never be picked up (GTD "someday/maybe"). No
done Terminal. The work is merged or the criterion is met. No
cancelled Terminal. Won't be done; the reason goes in the body. No
expired Soft-terminal, set by gptodo expire. Can be revived to backlog/todo. No

new and paused are deprecated aliases that are still accepted with a warning. Both normalize to backlog. paused does not hold a task: agents will claim it. File unreleased plans as draft.

Common confusions:

This diagram mirrors gptodo transitions --json (VALID_TRANSITIONS in checker.py). Regenerate it from that output when the table changes.

stateDiagram-v2
    [*] --> backlog
    [*] --> draft
    backlog --> todo
    backlog --> active
    backlog --> waiting
    backlog --> done
    backlog --> draft
    backlog --> someday
    backlog --> cancelled
    backlog --> expired : auto-reap
    todo --> active
    todo --> waiting
    todo --> done
    todo --> ready_for_review
    todo --> backlog
    todo --> draft
    todo --> someday
    todo --> cancelled
    todo --> expired : auto-reap
    active --> ready_for_review
    active --> waiting
    active --> draft
    active --> someday
    active --> done
    active --> cancelled
    ready_for_review --> active : review fails
    ready_for_review --> todo
    ready_for_review --> waiting
    ready_for_review --> someday
    ready_for_review --> done
    ready_for_review --> cancelled
    waiting --> active : blocker resolved
    waiting --> todo
    waiting --> backlog
    waiting --> done
    waiting --> ready_for_review
    waiting --> someday
    waiting --> cancelled
    draft --> backlog : released
    draft --> todo : released
    draft --> cancelled
    someday --> backlog : revived
    someday --> todo : revived
    someday --> waiting
    someday --> done
    someday --> cancelled
    someday --> expired : auto-reap
    expired --> backlog : revived
    expired --> todo : revived
    expired --> cancelled
    done --> [*]
    cancelled --> [*]
    expired --> [*]

gptodo transitions (or --json) prints this table. gptodo edit --set state X enforces it at three levels:

  1. Reopening done or cancelled is refused unless you pass --force.
  2. Any other illegal transition (for example active → todo) prints a warning and goes ahead. With GPTODO_STRICT_TRANSITIONS=1, it is refused instead unless you pass --force.
  3. Legal transitions go through silently, subject to the completion check below.

Moving into done requires every checklist item to be completed or intentionally skipped. The entire edit batch is checked before any file is written, including checkbox changes supplied by --set-subtask in the same command. Fenced examples and checkbox-like prose are excluded. Existing done tasks and cancellation are unaffected. --allow-pending explicitly overrides this check with a warning; it does not bypass repository commit hooks. --force only overrides transition legality.

gptodo edit also maintains bookkeeping fields. Entering waiting stamps waiting_since, first_waiting_since and waiting_spell_count. Moving to done or cancelled clears stale waiting_for/wait/next_action and sets completed.

Typed wait gates

A free-text waiting_for can wait forever: nothing reads it as a contract. A gate block states what the task waits on, who must act and what happens at the deadline:

state: waiting
gate:
  kind: decision          # decision | pr | issue | task | time | event
  actor: erik             # who must act; gate_actor(meta) == "erik" is the predicate
  question: "Rotate the API key now? y/n"
  default: "rotate on the deadline"
  deadline: 2026-11-26T18:00:00+00:00
  on_timeout: escalate    # default | escalate | drop
  reversible: false       # false forbids on_timeout: default

The schema is checked by gptodo check and on every write through the shared lifecycle. Existing malformed gates do not block unrelated edits, but a write cannot introduce a new gate error.

Command reference

Every command has --help. The top-level options are -v/--verbose and --tasks-dir PATH.

Viewing and selecting work

Command What it does
status [--compact] [--summary] [--issues] [--json] [--github] Overview grouped by state. --compact shows only backlog/todo/active/ready_for_review. --type / --all also cover the tweets and email directory types.
list [--sort state|date|name|completion] [--active-only] [--context @tag] [--json|--jsonl] Table of tasks.
ready [--state ...] [--json|--jsonl] [--skip-claimed] [--use-cache] All unblocked tasks. --state takes backlog, todo, active, ready_for_review, someday, draft, both (the default: backlog+todo+active) or actionable.
next [--limit N] [--order priority|unblock] [--json] The highest-priority ready task, or a simulated sequence of N tasks (see below).
show <id> [--render] One task's metadata and body.
browse [--all] [--state S] [--project P] [--no-fzf] Interactive browser (fzf, or a pager).
tags [--state S] [--list] [TAG...] Tag counts and the tasks under each tag.
stale [--days 30] [--state active|backlog|waiting|all] Tasks not modified recently.
effective <id> / explain <id> Why a task is or isn't ready: its effective state, and each readiness filter in turn.
plan <id> What finishing this task would unblock.

list, ready, next and loop show only the general pool by default. Pass --pool all or --pool frontier, or --exclude-pool frontier. A task is in the frontier pool if it sets pool: frontier, has a frontier- ID prefix, or has a frontier tag.

Editing

Command What it does
add "Title" [--priority] [--tags a,b] [--state] [--type action|project] [--assigned-to] Create a task. Text piped on stdin becomes the body.
edit <id>... --set F V | --add F V | --remove F V | --set-subtask "text" done|todo [--force] [--allow-pending] Change frontmatter or checkboxes. Several IDs can be given at once. Repeat --set-subtask for a batch: each selector must match exactly one checkbox in every target, and no two selectors may address the same checkbox. Invalid selectors or unresolved checkboxes on a done transition reject the whole invocation with nonzero status before any file is written. Partial text matches remain supported. --set F none clears a field, and tag/dep are shorthands for tags/depends.
claim <id> [--agent NAME] Set active, assigned_to and assigned_at. Running it again with the same owner does nothing.
subtask <parent> -n a -n b [--mode parallel|sequential|fan-out-fan-in] Split a task into child task files (spawned_from / spawned_tasks).
expire [--days N] [--state S] [--dry-run] [--json] Auto-expire long-quiet tasks (see below).
archive [--older-than N] [--state S] [--limit N] [--dry-run] [--json] Move old done/cancelled/expired tasks to tasks/archive/ (see below).

Integrity

Command What it does
check [--fix] [FILES...] Check integrity and relationships, such as broken references and unparseable frontmatter.
lint [--json] [--strict] [FILES...] Find frontmatter schema errors and unknown or deprecated fields.
transitions [--json] The state-transition table.
dep tree <id> [-f ascii|mermaid] [-d up|down|both], dep check, dep dag [--no-power] Dependency trees, cycle detection, and the whole-workspace graph with unblocking-power scores.
checker <id> [--poll] Verify subtask completion, dependency resolution and state validity for a task.

External trackers

Command What it does
fetch [--all] [URL...] Cache issue/PR states in state/issue-cache.json. ready, next and sync read the cache with --use-cache.
sync [--update] [--light|--full] [--changes-only] Compare task states with their linked GitHub issues and optionally update the tasks.
import --source github --repo owner/repo [--label L] [--assignee me] / import --source linear --team KEY Create placeholder tasks from issues. Issues that already have a task are skipped.
check-waiting [--fix] / watch [--interval 300] [--once] Resolve structured waiting_for: conditions, once or as a loop.
generate-queue [--workspace .] [--github-username U] [--user U] Write state/queue-generated.md: the 5 top high/urgent tasks plus high/urgent GitHub issues (priority:high / priority:urgent labels).

Multi-agent and sub-agents (experimental)

Command What it does
lock <id> [--worker W] [--timeout H], unlock <id>, locks [--cleanup] File locks in state/locks/ that expire after a timeout.
agents [--all] [--cleanup] [--json] Agents registered in state/agents/, by heartbeat.
run <id> / spawn <id> [--backend gptme|claude] [--type general|explore|plan|execute] [--model M] [--prompt P] Run a sub-agent on a task, in the foreground or in the background (tmux). Session records go in state/sessions/.
sessions [--status S], output <session>, kill <session>, cleanup-sessions Manage spawned sessions.
loop [-n 5] [--parallel N] [--dry-run] Work through ready tasks with sub-agents.
worktree create <id> [--base origin/master], list, status, pr, merge, remove, cleanup Per-task git worktrees under .worktrees/ for isolated agent work.

Machine-readable output

Scripts should parse --json rather than the rendered output, because the emoji and formatting may change. Most commands accept --json, including status, list, ready, next, stale, plan, fetch, sync, import, expire, archive, lint, transitions and edit. list, ready and stale also accept --jsonl (one task per line).

# Is any task active?
gptodo status --json | jq -e 'any(.tasks[]; .state == "active")'

# Per-state counts
gptodo status --json | jq '.summary.by_state'

status --json returns:

{
  "type": "tasks",
  "tasks": [ { "id": "...", "state": "active", "priority": "high", "...": "..." } ],
  "summary": { "total": 12, "by_state": { "active": 1, "backlog": 11 }, "issues": 0, "untracked": 0 }
}

With --all, the results are grouped under types, keyed by directory type, and each group has the same {type, tasks, summary} shape.

edit --json — mutation result

# Capture the new state after a mutation
gptodo edit my-task --set state active --json

Success response (exit 0):

{
  "tasks": [
    {
      "id": "my-task",
      "changes": {
        "state": { "from": "backlog", "to": "active" }
      }
    }
  ],
  "exit": 0
}

Error response (exit 1, JSON still on stdout):

{ "id": "my-task", "error": "terminal state reopen requires --force", "exit": 1 }

changes is a dict of fields that actually changed; it is empty when the edit was a no-op (the field was already at the requested value). Human-facing warnings and state-transition notices still go to stderr. Edit-level validation and lifecycle refusals use the error response above; id is the failing task id (or the sole requested selector), or null when a batch-wide refusal cannot identify one task. Click argument/option parsing errors happen before the edit callback, exit 2, and use the usual stderr diagnostics rather than JSON. Unexpected exceptions are not converted into refusal responses.

YAML values outside JSON's type system are normalized for the response: dates and other non-JSON scalars become strings, non-finite floats become "nan", "inf", or "-inf" strings, and mapping keys become strings. Finite numbers remain numbers. If distinct keys would collide (for example, integer 1 and string "1"), that mapping is represented as {"$yaml_mapping": [[key, value], ...]} instead, preserving every entry in order. Keys in this pair list use the same scalar normalization, so the response is a JSON diff, not a lossless YAML round-trip format. These conversions apply recursively and do not change the stored frontmatter.

For a recurring task that resets on done, the per-task result also includes "recurred": true and "next_wait": "YYYY-MM-DD...".

add — id echo contract

gptodo add prints the new task id (the filename stem) on stdout and the confirmation line on stderr, so the id can be captured directly:

TASK_ID=$(gptodo add "My task title" </dev/null)
gptodo edit "$TASK_ID" --set priority high

Always pass </dev/null from automation to prevent stdin-read hangs.

Exit codes

Exit Meaning
0 Success (mutation applied, or clean no-op)
1 Refusal or not-found (invalid value, unknown field, missing task, terminal reopen without --force, no mutation args)
2 Click usage error (unknown option, missing argument, invalid option choice, or invalid add waiting options)

These are expected statuses for add, edit, and show, not a classification of unexpected failures: an unhandled exception can also exit 1. In particular, gptodo add "Later" --state waiting </dev/null exits 2 when --waiting-for is missing. Scripts can use && chaining (gptodo edit … && <next-step>) to require success, but must inspect diagnostics (or the edit --json error object) rather than treating every nonzero status as fatal.

Sequential planning (next --limit)

ready and a bare next answer a parallel question: what is unblocked right now. If task A unblocks task B, B is invisible to both until A is done, so a deep queue can look one task deep.

gptodo next --limit N answers the sequential question instead. It simulates completing each pick in memory (task files are never written), recomputes the ready set, and lets newly unblocked tasks join the list:

gptodo next --limit 5                 # next 5, in unblocking order
gptodo next -n 5 --order unblock      # take the task that unblocks the most first (critical path)
gptodo next --limit 5 --json          # ordered array; each item says what unblocked it

Auto-expire

Without cleanup, the queue keeps growing. gptodo expire finds tasks in backlog/todo/someday whose created date is older than --days (default 90, or GPTODO_EXPIRE_DAYS) and moves them to expired. It stamps expired_from and expired_at on each one.

gptodo expire --dry-run                    # preview
gptodo expire --days 60 --state backlog    # tighter window, backlog only
gptodo edit <task> --set state backlog     # revive (no --force needed)

It skips:

Age is measured from created, not file mtime, so edits from lint or reformatting don't make a task look active.

Archiving finished tasks

Finished tasks pile up in tasks/ and slow down every scan. gptodo archive moves terminal tasks (done, cancelled, expired) that finished at least --older-than days ago (default 7, or GPTODO_ARCHIVE_DAYS) into tasks/archive/. Tracked files are moved with git mv, others with a plain rename. Nothing is committed.

gptodo archive --dry-run                          # preview
gptodo archive                                    # move everything eligible
gptodo archive --older-than 30 --state done --limit 200
gptodo archive --json

Age is measured in UTC from completed, which gptodo stamps when a task becomes done or cancelled (expired_at for expired tasks). Date-only and naive values count as UTC; a value that doesn't parse keeps the task in place. Older tasks without that field use their last change instead: the latest of the modified field, file mtime and last git commit. Creation age is never used. A fresh clone resets mtimes, so such tasks wait a full window.

Archived tasks keep working as dependencies: check, ready, next, explain, checker and auto-unblock resolve tasks/archive/** by name, and show <name> falls back to the archive. They no longer appear in status, list or ready.

A task stays in place when:

requires/depends don't keep a task in place, since they resolve from the archive. Relative links inside a moved file are rebased so they still resolve from tasks/archive/, and links in files already under tasks/archive/ that point at a task moved now are repointed (and staged if tracked). Links in other files are not rewritten. Running it again only picks up newly eligible tasks. --json reports archived, skipped (with reasons), relinked and errors; the exit code is 1 if any move failed.

Frontmatter schema and lint

The supported fields are listed in KNOWN_FRONTMATTER_FIELDS in src/gptodo/utils.py. gptodo lint warns about anything outside that set and about known bad fields such as modified, updated_at, owner (use assigned_to) and discovered_from (use discovered-from). Each warning names the alternative.

gptodo lint                  # all tasks
gptodo lint tasks/foo.md     # one file
gptodo lint --strict         # non-zero exit on warnings (for CI / pre-commit)

For pre-commit, pass the staged filenames to a single schema hook (no separate gptodo check scan of unrelated tasks). From an agent workspace with the contrib submodule:

- id: validate-task-frontmatter
  name: Lint staged task frontmatter
  entry: uv run --no-project --with ./gptme-contrib/packages/gptodo gptodo lint
  language: system
  types: [markdown]
  files: ^tasks/(archive/)?[^/]+\.md$
  exclude: ^tasks/(templates|video-scripts|agent-setup-interview)/
  pass_filenames: true

This installs gptodo from the workspace's submodule pin instead of relying on a possibly stale global installation. Structural errors (including malformed YAML) fail the hook; unknown/deprecated fields remain warnings unless --strict is requested. The legacy scripts/precommit/validate_task_frontmatter.py entry point remains supported and delegates task validation to this same schema.

A modified: timestamp is deliberately not part of the schema. Every edit path would have to keep it up to date, and the same information is free from git log -1 --format=%ai tasks/foo.md. Warnings never reject a task. The linter only pushes towards the schema.

Workspace-specific fields. Fields specific to one workspace can be registered so they lint clean and can be set with gptodo edit. Use either of these:

# pyproject.toml at the workspace root
[tool.gptodo]
extra_frontmatter_fields = ["review_owner", "premise_check"]
export GPTODO_EXTRA_FRONTMATTER_FIELDS="review_owner,premise_check"

Configuration

Variable Effect
GPTODO_TASKS_DIR / --tasks-dir Use this tasks directory. Its parent becomes the workspace root.
TASKS_REPO_ROOT Start root detection from this path. The lock, unlock, locks and agents commands use it directly as the root, defaulting to the current directory.
GPTODO_AGENT_NAME Default owner for claim and add. Without it, gptodo uses [agent].name from gptme.toml, then agent.
GPTODO_STRICT_TRANSITIONS=1 Refuse illegal state transitions instead of warning.
GPTODO_EXPIRE_DAYS Default --days for expire.
GPTODO_ARCHIVE_DAYS Default --older-than for archive.
GPTODO_EXTRA_FRONTMATTER_FIELDS Extra allowed frontmatter fields, comma- or space-separated.
HOOK_TASK_DONE Executable run when a task is marked done.
GITHUB_USERNAME Assignee boost for generate-queue.
LINEAR_API_KEY Required for import --source linear.

gptodo writes its runtime state under state/ in the workspace: issue-cache.json, locks/, agents/, sessions/ and queue-generated.md. Add the volatile parts to .gitignore.

Development

cd packages/gptodo
make test        # pytest
make typecheck   # mypy

scripts/tasks.py at the root of gptme-contrib is a deprecated wrapper around this CLI. Replace calls to it with gptodo; the commands are the same.

Shared lifecycle mutations (Python)

gptodo.lifecycle.mutate_task(path, patch={...}) is the writer used by edit, utils.update_task_state, external sync, fan-in, claim and expiry. It returns MutationResult with old/requested/effective states, changed metadata, the resulting Post and whether bytes were written. update_task_state(path, state) retains its boolean compatibility contract: a missing file, invalid state or rejected write returns False.

Initial creation/import is outside this mutation facade. Reasserting a legacy terminal task does not fabricate completed; no historical backfill is performed. External script writer migrations remain separate from these internal adapters.