我如何管理持续运行的 Claude Code 循环:Spool
How I manage persistent Claude Code loops: Spool

原始链接: https://github.com/enes-alatas/spool

Spool 是一个 1.0 之前的开源工具,用于创建、管理持久化的 Claude Code 循环,并与之聊天。它让用户给循环分配工作、协调它们,并通过 Web、Telegram 或 Slack 保持参与。循环作为 Claude 子进程运行,具备定时唤醒、可恢复会话、直接集群消息传递和风暴防护。控制室显示实时对话、日程和成本,并让用户暂停、唤醒或终止循环。计划护栏会在用量接近限制时让循环休眠。默认情况下,循环在带有出站允许列表的 Docker 容器中运行;裸模式则在无容器隔离的环境中运行。设置需要 Linux/macOS/Windows WSL2、Docker、git、Go 1.25+、Node 20.19+/22.12+ 和 Claude Code。使用 git clone 和 make build image 构建,运行 ./bin/spool,登录,添加令牌,创建循环,并接入一个机器人。文档涵盖操作、隔离、Slack/Telegram、安全、架构和贡献。

enesalatas 在 Hacker News 上发帖介绍了 Spool(GitHub),一个用于管理持久化 Claude Code 循环的工具。作者构建它是为了让用户能与循环对话,同时避免跟踪多个终端会话。Spool 简化了循环的创建和管理,并让循环能与用户以及彼此通信。该帖子获得 12 分和 3 条评论。评论者 AIorNot 称其有趣,并询问成本管理:每个项目是否需要自己的订阅,以及 Spool 能否合并不同的 Claude 订阅,以控制开发成本,并防止 Claude 编排的代理到子代理调用导致 API 超额。另一位评论者 vdfs 指出,GitHub 终于在移动端显示星标数。页面还包含一则 YC 2027 冬季批次广告。作者邀请大家就其实用性提供反馈。
相关文章

原文

Spool

CI status Go version Apache 2.0 license Pre-1.0 status

Your Claude Code loops, working together and keeping you in the conversation.

Spool makes it easy to create, manage, and talk to persistent Claude Code loops. Give them work, let them coordinate, and stay involved through chat.

spool-demo.mp4

What does Spool make easier?

  • Keep work going. Create and manage persistent loops in one place, with scheduled wakes and resumable sessions.
  • Stay involved. Talk to your loops in the web control room, on Telegram or in Slack, without sitting in their terminal sessions.
  • Coordinate work. Let loops communicate directly in the fleet channel, so you don't have to relay every question, result, or handoff.

Less switching between sessions and carrying messages between loops. More time deciding what they should work on and reviewing what they produce.

Spool is pre-1.0 and developed in the open by a fleet of Claude Code loops and their operator. The four loops in this repo's issues and PRs run on Spool, building Spool. Commits are co-authored by the model that wrote them; every change lands through a pull request that CI gates and a reviewer reads, and the operator is the one who merges it. Found a problem? CONTRIBUTING.md says how to report it and who answers.

You need Linux, macOS or Windows with WSL2, with Docker running, git, Go 1.25+, Node 20.19+ or 22.12+, and Claude Code on a Claude subscription (only to make a token in step 3).

  1. Get Spool and build it.

    git clone https://github.com/enes-alatas/spool && cd spool
    make build image

    That builds bin/spool, the control room inside it, and the two Docker images a loop runs in.

  2. Start it and sign in. Run ./bin/spool. On its first start it prints a one-time password for the user admin. Open http://127.0.0.1:8080, sign in as admin with that password, and choose your own. Missed the password? ./bin/spool user reset admin prints a new one.

    The control room opens on Set up your fleet: three cards, in the order below. Each checks itself and turns done on its own.

  3. Harness. Run claude setup-token, then choose Add token on the card and paste what it printed. Your loops run on your Claude plan through it.

  4. Loops. Choose New loop, and give it a name and a mission. Its first wake builds its workstation, which takes a minute or two the first time; the card is done when that wake's first turn ends.

  5. Chat surface. Choose Attach a bot, then Attach Telegram or Attach Slack.

    • Telegram: send @BotFather /newbot in Telegram, and paste the token it gives you.
    • Slack: follow the dialog's Create app from manifest, then paste the app's two tokens. docs/SLACK.md has the steps.

    Then choose Get a link code, send the code to your bot in a direct message, and reply YES when it asks. That links your account and makes you the loop's owner. Message the bot once more: the card is done when the loop answers you there.

    No chat app? You can talk to a loop on its page in the control room instead. Once the Harness and Loops cards are done, choose Skip for now on the Chat surface card to finish the setup page without one, and attach a bot later on the loop's page.

  • From a release, once there is one after v0.5.1: it carries the built binary and the images, so you need no Go, Node or make. OPERATIONS.md shows the download, the checksum and the image pulls.
  • On a server, as a service, with TLS and backups: OPERATIONS.md.
  • Without Docker. ./bin/spool --runtime bare runs each loop as a plain process under your own account and your own claude login, uncontained. It needs no make image and no step 3. Read What contains a loop before you choose that.
  • Plain claude CLI underneath. Loops are claude subprocesses speaking stream-json over stdin/stdout. Your normal Claude Code login, plan and session limits apply. No API keys, no SDK.
  • Direct coordination. Loops send explicitly addressed messages to the fleet channel or a private conversation. @mention a loop from Telegram, the web, or another loop's message, and Spool delivers it. Final turn replies stay as status notes in the timeline. Loop-to-loop chains are storm-guarded.
  • Wake, sleep and pacing. Idle loops cost nothing: their process exits and resumes later with full context. A loop wakes on its tick interval (30m by default), at once on any message to it, or when it asks with a [next-wake: 45m] trailer, clamped to bounds you set. Paused loops queue their mail.
  • Control room. The hub's web UI, at http://localhost:8080 by default. It shows each loop's conversation live as tokens stream in, its schedule and what each turn and day cost, and it pauses, wakes or kills a loop.
  • Plan guardrails. The Fleet page shows how much of your plan's 5-hour and 7-day windows is used, read from the loops' own streams, and each loop's share of the day's spend. Past a cap, 90% of either window by default, every loop sleeps until that window resets: messages wait, and nothing is lost. Resume now lifts it early, and Settings → Plan guardrails sets the thresholds or turns them off.
  • Contained by default. Each loop runs in its own container with an egress allowlist (Settings → Egress) and no route to your machine but one hub port, which serves the loops' MCP endpoint and nothing else.
  • Uncontained only when you ask. Loops run with permission prompts bypassed. Without Docker, Spool refuses to start rather than run them on your host; --runtime bare runs each one as a subprocess under your own account, with your network and your files, badged uncontained.
  • Signed in. The control room asks for a username and password, and scripts use the operator token (spool token). Binding to localhost is not a boundary on its own.
  • Secrets sealed. Bot tokens, connection secrets and the setup-token are sealed under hub.key in the data directory. Back it up apart from spool.db.

docs/CONTAINMENT.md has the whole picture, including what containment does not do. SECURITY.md says how to report a vulnerability.

A loop starts with the control room only. Attach a bot to reach it from Telegram or Slack too: each loop is its own bot or app, and step 5 of the quick start attaches the first one. docs/TELEGRAM.md covers BotFather, groups and reactions; docs/SLACK.md covers the app manifest, the two tokens, reactions and polls.

Who can talk to your loops

Spool keeps a sender allowlist, and only people on it reach your loops. Anyone else who messages one of your bots is ignored: their message never reaches a loop, they can't bind a group, and /spool_status won't answer them. Linking your account in step 5 put you on it. To let someone else in, add them as a user (spool user add, or Settings → Users and access) and have them link theirs under Settings → Link Telegram or Link Slack. Settings → Users and access lists each user's links and can block a user on every bot, along with anyone an old pairing code allowed without a user; a blocked sender gets no reply at all. A Slack app is already private to the workspace you install it in, and the allowlist applies there too. Loop-to-loop traffic is internal and unaffected.

Flag Default What it sets
--listen 127.0.0.1:8080 where the control room and its API are served
--data-dir ~/.spool the database, hub.key, loop homes and worktrees
--runtime auto docker when the daemon is reachable, else refuse to start; bare runs loops uncontained
--trusted-host none the name a hub behind a TLS proxy is reached as; OPERATIONS.md has a systemd unit and a Caddy recipe
--mcp-listen chosen by the hub the loops' one port; docs/CONTAINMENT.md says how it is chosen

spool --help lists every flag. spool token prints the operator token again.

make server         # Go binary only (uses last-built UI)
make dev            # run backend on :8080
make ui-dev         # vite dev server with /api proxy
make test           # tier 1: unit + architecture tests
make itest          # tier 2: real binary vs fakeclaude (protocol fake), ~10min
                    #         (~7min without a docker daemon; two files skip)
make image          # build the spool-workstation and spool-egress images locally
make lint           # gofmt + vet (as Linux and as macOS) + golangci-lint
make e2e-m1         # tier 3: real claude sessions (spends plan tokens)

Testing is three-tiered (see docs/QUALITY.md): unit and fakeclaude-backed integration tests gate every PR in CI; the real-claude e2e suites (scripts/e2e/) run locally per milestone: session resume across process death and orchestrator restarts (m1), tick scheduling and trailer clamping (m2), mention relay + storm guard (m4), Telegram (m5), worktree isolation (m6).

Running a hub:

  • docs/OPERATIONS.md: install on a server, back up, restore and upgrade
  • docs/CONTAINMENT.md: what contains a loop, and the hub's own secrets
  • docs/TELEGRAM.md, docs/SLACK.md: the chat surfaces in full
  • SECURITY.md: what is supported, how to report a vulnerability privately, and which properties of the design are known rather than bugs

Working on Spool:

  • CONTRIBUTING.md: how to report a problem and who answers
  • docs/VISION.md: product vision and the L0–L7 milestone ladder
  • docs/ARCHITECTURE.md: shape, seams, ubiquitous language
  • docs/CONVENTIONS.md: workflow, style, test tiers
  • docs/QUALITY.md: baselines and CI gates
  • docs/THREAT-MODEL.md: what each boundary holds and does not
  • docs/adr/: decision records
  • AGENTS.md: orientation for AI agents working on this repo (CLAUDE.md is a symlink to it)
联系我们 contact @ memedata.com