agentq

A background task scheduler for Claude Code

agentq is a background task scheduler for Claude Code. It hands the to-do items in each project's docs/BACKLOG.md to separate Claude Code processes, then merges the work to the local default branch once tests and a review pass.

curl -fsSL https://github.com/dodo258/agentq/releases/latest/download/install.sh | sh

The script downloads a prebuilt binary and checks its SHA256. It needs Git, but not sudo or Go. Running the same command on an existing install upgrades it and keeps your configuration and task data.

v0.1.0 · MIT · Single Go binary · macOS · Linux

View source on GitHubInstall guide

trial-launchd
$ curl -fsSL https://github.com/dodo258/agentq/releases/latest/download/install.sh | sh
✓ 下载 agentq_darwin_arm64.tar.gz
✓ 校验通过
✓ 安装程序和技能
agentq 装好了。
· 你交代的任务由官方 CLI 的独立进程完成,它们能读写这个用户的所有文件(包括本地密钥)、运行命令。
· 任务内容会发给你所用的模型服务,用你自己的账号额度。agentq 本身不收集数据。
· 没有待做时什么都不做,不消耗额度。
按回车同意并启动,输入 n 只安装不启动:⏎
✓ 后台已启动,每 5 分钟看一次待做。

$ agentq add "做一个单页的产品介绍网页(大方向) —— 给一个叫「加法匠」的小工具做介绍页"

$ agentq status
调度:正常
额度:会话 42%;本周 72%
运行中(1/2):trial-greeting「实现 Greeting(name string) string」

门:trial-launchd「做一个单页的产品介绍网页(大方向)」过门合并,合并提交 72f2bffb8398
Fig. 1Terminal record of a trial run: install, queue one task, check the status, pass the gates and merge. Output is in Chinese for now.

Install and usage

After installing, it says what tasks can do and whose quota they use, and starts only once you agree.

At the end of the install, the program states three things and asks whether to start:

  1. Tasks can read and write every file your OS user can.
  2. Task content goes to the model service you use, on your own quota.
  3. With nothing to do, no quota is used.

Press Enter to agree and start, or type n to install only. With no terminal (CI, or an agent installing for you) it installs only and never agrees on your behalf. Run agentq start later to start it.

After you agree, the script runs the official installer and claude auth login if the Claude Code CLI is missing or signed out. The desktop app can't run background tasks, so the CLI is needed even if the app is installed.

To have an agent install it, send it this line:

Read https://github.com/dodo258/agentq/blob/main/llms.txt and install agentq for me

Usage

Open Claude Code in your project (the CLI or the desktop app) and say what you want done:

派活:Retry an export 3 times when it fails, and show the retries in a log when offline

派活 ("assign this") triggers the dispatch skill. It writes the request as an item with acceptance criteria, commits it to docs/BACKLOG.md and starts the background task. The project must be a Git repository. It doesn't have to sit under ~/projects.

You can also work from the terminal:

agentq add "..."
# add an item to this project's queue; the first one brings the project in
agentq run my-app
# start one of the project's items now
agentq new "..."
# create a new project and build its first version from one line
agentq status
# quota, running tasks, each project's queue, recently finished tasks
agentq stop 1105-211629-shop-api
# stop a task and keep its changes
agentq pause
# stop starting new tasks; agentq resume undoes it
agentq doctor
# read-only check of install, CLI and config

Every command is listed in the command reference (in Chinese).

How it works

agentq schedules, runs the gates and merges. Claude Code writes the code.

agentq picks items, starts and monitors processes, runs the quality gates, merges and keeps records. It writes no product code. Claude Code does the implementation and self-testing, following the bundled agent-task skill, and a separate Claude Code process does the review.

You say it, and it goes into docs/BACKLOG.md. agentq tick checks conditions and starts a separate claude -p process in its own worktree, which builds, self-tests and writes ready.json. agentq runs the gates (tests, review); when they pass, the engine merges and wraps up. A failed gate sends the work back to the task, and if it still fails it waits for you. Interrupted or limited work resumes in the same session. Results go to the daily digest and morning report.
  1. You say itA Claude Code session, Telegram or agentq add
  2. docs/BACKLOG.mdOne per project, worked top to bottom, committed with the repo
  3. agentq tickEvery 5 min and after each jobChecks pause, quota, breaker, concurrency, sign-in
  4. claude -pOwn process, own worktreeClaim, build, self-test; writes ready.json, exits
  5. GatesRuns .agentq/verify on the merge; a separate process reviewsAll pass: engine merges to main
  6. Wraps up, tells youDaily digest, morning report, Telegram (optional), agentq status
  • Interrupted or limited: back to step 4, the same session resumes.
  • Not passed: sent back to step 4. Still failing, or can't tell: your call (Telegram card (optional) or agentq gate pass).
Fig. 2From one line to a merge: six steps, two loops. From docs/brand/readme/ in the agentq repository.
Every 5 min
The scheduler runs every 5 minutes and again whenever a task ends, so a queued item starts within seconds.
2 / 1
By default 2 tasks run at once, with at most 1 per project.
No push
The scheduler never runs git push. Merges happen on the local default branch, and pushing to a remote needs separate authorization.
Stays on
Tasks don't depend on a terminal or client, but the machine has to stay on.

Full rules: scheduling (in Chinese).

Quality gates

A task only gets its branch ready to merge. Five gates decide whether it merges.

A task can only get its branch ready to merge and write .agentq/ready.json. agentq decides whether to merge using the five gates below, which run on the branch merged with the latest default branch.

GateWhen it runsWhat it checksDefault level
TestEvery timeRuns the project's .agentq/verifyBlocks the merge
ReviewSkipped for markdown-only changesA separate process reviews the change. A blocking finding needs a file, line, evidence and reproduction stepsBlocks the merge
PatchWhen the change is a fixA third fix to the same module within 30 days. Set to error, it sends the task back to rewrite that moduleRecords only
UIWhen UI files changeA project script takes screenshots, agentq checks they aren't blank, and a review process blocks only on broken rendering, overflow, unreadable text or filler contentRecords only
ProductOn the first version from agentq new and items marked (成品)Runs the project's smoke test .agentq/smoke and produces a handoff sheet if it passesRecords only

A project can change the levels in .agentq/gates.json. On the first agentq init or agentq add, the program generates .agentq/verify from the project's files. If it can't tell what to run, the task has to add the script while implementing.

When a gate fails, the reason goes back to the task and the same session continues, for at most 2 rounds. If it still fails or the result can't be determined (for example, the script reports it can't run this time), the item is marked stuck and waits for you:

agentq gate report <job id>
# see why
agentq gate pass <job id> --reason "..."
# let this one through
agentq gate rerun <job id>
# run the gates again without code changes
agentq gate abandon <job id>
# give up and keep the branch

A task that merges by itself around the gates doesn't count as passed. agentq flags it and notifies you. The gates guard against a model cutting corners or making mistakes. They are not a security boundary, because tasks have full access to your machine.

Details: quality gates and engine merge (in Chinese).

Picks up where it stopped

A process exits, a limit is hit, the state file breaks: each has a fixed response.

SituationResponse
A process exits midway, or the machine rebootsChecks the BACKLOG and resumes the same session. Merged work isn't redone
A usage limit is hitCools down until the reset time, then resumes the same session
Quota is nearly goneStarts no new tasks at 90%. agentq run is refused at 98%
Tasks fail right after startingThree tasks exiting within 3 minutes trip a breaker that stops new starts for 30 minutes. Another failure doubles that, up to 4 hours
A task runs awayEach run has a budget cap, subagent runaway stops it automatically, and the default timeout is 4 hours. Its changes are kept
The state file breaksUnreadable: nothing is wrapped up or started. Corrupt: the bad file is backed up, state is rebuilt from task records, and no new task starts that round
Run data growsTask records are kept 90 days by default, and logs are trimmed

These paths are covered by a fake CLI and a stress test. A real usage limit has not been run yet. The stress test kills processes, corrupts state files, forces concurrency, fills the disk and jumps the clock, all with fake dependencies, and has only run on macOS so far. Method: CONTRIBUTING (in Chinese). Rules: scheduling (in Chinese).

Telegram

Optional. Message the bot with requests, answer decisions, and get told about merges and failures.

Telegram is optional. Once it's set up, you can message the bot with requests and screenshots.

  • Reply to a "decide" message or tap a button. The decision is written back to the item and the task continues.
  • Reply to a task alert to pick that task back up.
  • 状态, 额度, 暂停 and 恢复 (status, quota, pause, resume) are answered by code and use no quota.
  • With router_enabled on, send one line describing a new project. agentq creates it, builds the first version and reports the result after the merge. This round trip has not been verified on real Telegram.

At most 10 notifications go out a day. Messages between 23:00 and 08:00 wait for the morning, and messages of one kind within 30 minutes are combined. A merged task sends its merge commit, and failures, interruptions and stuck items are reported too. Without Telegram, agentq uses local desktop notifications.

Completion notices and decision card buttons work on real Telegram. Reply threads and full conversation round trips have only been tested against a fake service. Setup (in Chinese).

A Telegram conversation: the bot asks what feel the page should have and offers directions A, B and C; B is picked; when done it reports the merge and the merge commit. Messages are in Chinese for now.
Fig. 3A Telegram conversation from a real trial run: pick a direction, then the merge notice. Screenshot from docs/brand/readme/ in the agentq repository. Messages are in Chinese for now.

Support

What has reached a merge for real, what only cross-compiles, and what has never run.

ItemStatus
Claude Code CLIDefault backend. 2.1.316 has reached a merge for real on macOS, including the review gate, the UI gate, agentq new, the launchd background and assigning work from the desktop app
Codex CLIChoose it by hand. codex-cli 0.166.0 has reached a merge and resumed after SIGTERM for real on macOS. Router, suggestions, sensing and release prep do not start on it, and it has no dollar cap
opencodeExperimental. The real opencode has never been run
macOSarm64 is the main platform. amd64 cross-compiles and has not run on an Intel Mac
LinuxNeeds systemd --user. amd64 runs the tests and a real systemd acceptance in CI, with no real task run. arm64 cross-compiles
WSL, WindowsWSL is unverified. Windows is not supported

Not yet verified for real

  • A usage limit and an expired token
  • Assigning work from the Codex desktop app
  • Real tasks and stress tests on Linux
  • Any opencode run
  • The gates compared with a bare CLI on real projects

Details for each item are in the support matrix.

Permissions and limits

  • Unattended coding needs bypassPermissions. A task runs as your OS user with all your file permissions, can read local secrets (including App Store Connect private keys and SSH keys), and can run any command. Prompts and deny rules are not a security boundary. agentq guards against a model cutting corners or making mistakes, not against deliberate damage.
  • On a sensitive machine, run it under a separate OS user or in a container, give feedback sensing a read-only App Store Connect key, and keep production credentials off it. Details: SECURITY (in Chinese).
  • The machine has to be on. Tasks continue after sleep or a reboot, but nothing runs while it's off.
  • Command output, notifications and BACKLOG section headings are in Chinese for now (## 待做 means "to do"). Item text can be in any language. Most guides are in Chinese.

Pick a backend at install time with --backend codex or --backend opencode (... | sh -s -- --backend codex). The interface for new tools is described in docs/backends.md (in Chinese). The prebuilt binary needs only Git, and building from source uses only the Go standard library.