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)

Full walkthrough: quickstart.

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
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

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. This repo also ships a set of Claude Code skills that make Claude itself an effective contributor to this specific codebase — see CLAUDE.md.

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.4.0.tar.gz (146.2 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.4.0-py3-none-any.whl (60.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for claudeloop-0.4.0.tar.gz
Algorithm Hash digest
SHA256 aa143ccee4aeb75ebf1893419d403f33d0947151cd7c9adaf15feb3ac7ea36ce
MD5 fa2e1cc58e03a19fce9fde058cccc3ab
BLAKE2b-256 bfab1b7e2e183329001db68acff6470e045a805ab7289891d32a63ac8549bca0

See more details on using hashes here.

Provenance

The following attestation bundles were made for claudeloop-0.4.0.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.4.0-py3-none-any.whl.

File metadata

  • Download URL: claudeloop-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 60.0 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a06eeb0e736a626169c21607a87a166fa8994e4ccc94c53c2a74b52bd0482ac
MD5 543bed552b4315d000e97516e2d093d5
BLAKE2b-256 72800c3412c7396a62b4337e8c0968a2a76cb132869704abd39976aeed9de3b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for claudeloop-0.4.0-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 Pingdom Monitoring Sentry Error logging StatusPage Status page