Skip to main content

claudeloop

PyPI Python versions CI License: MIT

Onion-architected, autonomous Claude Code session runner and full Anthropic SDK CLI — never blocks on a human, distinguishes an exhausted rate-limit window from exhausted credits, and resumes safely across usage windows.

What problem this solves

Claude Code sessions hit usage limits. A claude -p invocation ending doesn't tell you whether the task finished or just that turn did. And when a rate limit rejects you, you can't tell from the outside whether waiting will ever help — a five-hour window resets on its own; an exhausted credits balance never will, no matter how long you wait.

claudeloop exists to get all three of those distinctions right, automatically, so you can hand it a plan and walk away — including handling the case where you top up your account's credits while it's mid-wait, which it notices on the next probe rather than at some fixed deadline.

This project began as legacy/claude_autoresume.py, a single-file script that did this by shelling out to claude -p and regex-scraping its output. claudeloop replaces that with a tested, typed, onion-architected package built on the official claude-agent-sdk. See the architecture decision records for why each specific change was made.

Install

pipx install claudeloop

See the installation guide for requirements and a from-source setup.

Quickstart

claudeloop run handoff.md      # seed a session from a plan file and run to completion
claudeloop resume               # resume whatever you were last working on
claudeloop resume --session-id <id>
claudeloop doctor                # pre-flight checks before a long unattended run
claudeloop api models list       # any Anthropic SDK endpoint (generated; see docs)

# Mid-run control (second terminal, same cwd):
claudeloop status
claudeloop snapshot              # handoff JSON under .claudeloop/runs/<id>/snapshots/
claudeloop logs -f --chatter
claudeloop prompt --now "Also cover the error path"
claudeloop preset high           # or: model / effort
claudeloop permission-mode plan  # mid-run; default at start is always bypass
claudeloop attach ./notes.md
claudeloop response retry
claudeloop watch --stream        # Textual live stream; --replay for history
claudeloop stop                  # soft-stop → stop-summary.md (exit 130)
claudeloop savepoints
claudeloop unwind --to 1         # after stop; git save-point restore

Ops surface (attachments, skills/MCP, memories, chat metadata, slash commands): run resources and chat ops.

Why it's different from just retrying on 429

Naive retry claudeloop
Sees an HTTP 429 Sleeps a fixed duration, retries Classifies why — a waitable rate-limit window, or exhausted credits that only a human can fix
Credits exhausted Sleeps forever, no reset time exists Probes on a bounded backoff and tells you it needs you
A credit top-up arrives mid-wait Not noticed until the fixed sleep ends Noticed on the next scheduled probe
Turn ends vs. task ends No structured signal — a marker string, easily confused with a truncated limit message Structured per-turn JSON verdict, with the legacy marker kept only as a fallback
Asked a clarifying question Hangs waiting for stdin, or fabricates an answer Denies the tool call with guidance, so the model proceeds on a stated, auditable assumption

See rate limits vs. credits and never blocking on a human for the full reasoning.

Documentation

Full docs (built with MkDocs Material) live at https://adammatthewsteinberger.github.io/claudeloop/. The same content is in the docs/ directory on GitHub.

Getting started Install, quickstart, configuration
Guides How autonomous runs work, rate limits vs. credits, never blocking, completion detection, logging, run resources and chat ops
Architecture The onion layers, the domain model, the run-loop state machine
Decision records Why each hard call was made
Contributing Development setup, testing philosophy, release process
Plans The original approved plans this project was built from

Logging

claudeloop run / resume always log to stderr twice for the same events: a human-readable stream and a JSON line stream ("transport": "console_json"), controlled by --log-level. Per-run events.jsonl / audit.jsonl and optional --log-file are separate transports. Details: logging and observability.

Project status

Pre-1.0, but functional through milestone M5. The CLI above genuinely works — run/resume drive Claude Code through claude-agent-sdk, sessions and doctor run against your environment, and claudeloop api exposes a generated 1:1 Anthropic SDK REST surface with a CI drift gate. domain/application carry a CI-enforced 100% test-coverage gate, with a live test suite (tests/live/) exercising the installed console script. See the architecture roadmap.

Contributing

Contributions are welcome — see CONTRIBUTING.md for the gitflow branch model, Conventional Commits requirement, and how to run every quality gate locally. Agent guidance is mirrored across:

Security

This tool bypasses Claude Code's interactive permission prompts by design (that's what makes autonomous operation possible) and handles API credentials. See SECURITY.md for the threat model and how to report a vulnerability.

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claudeloop-0.5.2.tar.gz (281.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claudeloop-0.5.2-py3-none-any.whl (148.2 kB view details)

Uploaded Python 3

File details

Details for the file claudeloop-0.5.2.tar.gz.

File metadata

  • Download URL: claudeloop-0.5.2.tar.gz
  • Upload date:
  • Size: 281.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for claudeloop-0.5.2.tar.gz
Algorithm Hash digest
SHA256 b2bc78d8221a4cdcc6d4cc6084f653965946fce1097f65aa09d85b799f660a8c
MD5 26f48777b7872dc1fd2537c76bffd9c1
BLAKE2b-256 9bd17030598d78dd9587bca41a0241a7db5f84679aac001d1494a7d1200b8a41

See more details on using hashes here.

Provenance

The following attestation bundles were made for claudeloop-0.5.2.tar.gz:

Publisher: publish-to-pypi.yml on adammatthewsteinberger/claudeloop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claudeloop-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: claudeloop-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 148.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for claudeloop-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ac73d809089b19e4e81347201819dac82a451e5a6797584d773cd345538a5f0d
MD5 e6129cb01a573a2ca3e606abfce64939
BLAKE2b-256 c35a7431be754271ee54568c9df6b139001d8dedf786ad1d9470e4ce3e922e5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for claudeloop-0.5.2-py3-none-any.whl:

Publisher: publish-to-pypi.yml on adammatthewsteinberger/claudeloop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page