Skip to main content

runspec-claude

Drives the Claude Code CLI (claude) headlessly as a runspec runnable — so the runspec-console agent (itself Claude) can delegate a bounded sub-task and resume the same worker on a later turn. "Claude driving Claude." pip install it into a venv and it's discoverable by runspec local, runspec serve (MCP), and runspec-console.

One runnable — claude-run — with four verbs. Each shells out to claude -p … --output-format json and returns {result, session_id, num_turns, total_cost_usd, is_error, raw}. runspec serve flattens it into one leaf MCP tool per verb (claude-run_ask, _continue, _resume, _sessions).

Requires the claude CLI on the host. The entry point is claude-run, not claude, so it never shadows the real CLI. Zero extra runtime dependencies.

Install

pip install runspec-claude

Verbs

Verb Autonomy What it does
ask confirm A fresh headless turn (claude -p).
continue confirm Continues the most-recent session (claude --continue).
resume confirm Resumes --session <id> (claude --resume).
sessions autonomous Lists ~/.claude/projects/<encoded-cwd>/*.jsonl (CLAUDE_CONFIG_DIR-aware, best-effort titles).

Safe-by-default, operator-governed. The delegate's power (--permission-mode / --model / --dir / --allowed-tools / --append-system-prompt / --bare) lives in inherited global args — operator/run-form controlled, not set by the autonomous agent (whose tools take only a prompt + session/limit). Defaults are --permission-mode default + --max-turns 12; opt up explicitly:

claude-run ask "Summarise the failing tests in this repo"
claude-run --permission-mode acceptEdits --dir /srv/app ask "Fix the lint errors"
claude-run resume --session 4f3c… "Now add a test for that fix"
claude-run sessions --limit 10

Public Python API

from runspec_claude import run_claude, list_sessions, ClaudeError

result = run_claude(prompt="Summarise the diff", permission_mode="default", max_turns=12)
print(result["session_id"], result["result"])

run_claude / list_sessions / encode_project_dir are exported for corporate-wrapper packages; failures raise ClaudeError (or ClaudeNotFoundError when the claude CLI is missing).

Development

python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
ruff check . && ruff format --check .
pytest

Metadata

Release files for runspec-claude 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for runspec-claude 0.1.1
File Size Uploaded
runspec_claude-0.1.1.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for runspec-claude 0.1.1
File Interpreter ABI Platform
runspec_claude-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.4 kB

Release files / runspec_claude-0.1.1.tar.gz

Download URL runspec_claude-0.1.1.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
14d7a611443c471037db87b4def9f18ba4e55f33fd90c9dfbba1e30bed0b2c92
BLAKE2b-256 checksum
How to use checksums
2af2889d5beee117f802bf5c4cc5dd87a88cce59c28c146516def540f789f1b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / runspec_claude-0.1.1-py3-none-any.whl

Download URL runspec_claude-0.1.1-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f65ecd81ca3bab5473a57fb473eba5df0526aac19b9b3617b20a0f74ad99bfa5
BLAKE2b-256 checksum
How to use checksums
3ed4b47f95689b40cb2d71a8d7658dc643788909a39be30d1d2383a4cc1ad5b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page