Stopgap for Claude -p before Anthropic's June 15 billing split

hammer-mei1 pts1 comments

Minimal claude -p alternative for CI/CD tasks — subscription billing, no daemon, no MCP · GitHub

/" data-turbo-transient="true" />

Skip to content

-->

Search Gists

Search Gists

Sign in

Sign up

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

Instantly share code, notes, and snippets.

HammerMei/gist:8ceef2740cf094188e1383fce014861a

Created<br>May 17, 2026 20:30

Show Gist options

Download ZIP

Star

(0)

You must be signed in to star a gist

Fork

(0)

You must be signed in to fork a gist

Embed

Select an option

Embed<br>Embed this gist in your website.

Share<br>Copy sharable link for this gist.

Clone via HTTPS<br>Clone using the web URL.

No results found

Learn more about clone URLs

Clone this repository at &lt;script src=&quot;https://gist.github.com/HammerMei/8ceef2740cf094188e1383fce014861a.js&quot;&gt;&lt;/script&gt;

" readonly="readonly" data-autoselect="true" data-target="primer-text-field.inputElement " aria-describedby="validation-33aa0221-646d-4648-b0c0-df2403e87361" class="form-control FormControl-monospace FormControl-input FormControl-small rounded-left-0 rounded-right-0 border-right-0" type="text" name="gist-share-url-sized-down" />

Save HammerMei/8ceef2740cf094188e1383fce014861a to your computer and use it in GitHub Desktop.

Embed

Select an option

Embed<br>Embed this gist in your website.

Share<br>Copy sharable link for this gist.

Clone via HTTPS<br>Clone using the web URL.

No results found

Learn more about clone URLs

Clone this repository at &lt;script src=&quot;https://gist.github.com/HammerMei/8ceef2740cf094188e1383fce014861a.js&quot;&gt;&lt;/script&gt;

" readonly="readonly" data-autoselect="true" data-target="primer-text-field.inputElement " aria-describedby="validation-0d47967d-804b-4a18-a660-b6595dafa75a" class="form-control FormControl-monospace FormControl-input FormControl-small rounded-left-0 rounded-right-0 border-right-0" type="text" name="gist-share-url-original" />

Save HammerMei/8ceef2740cf094188e1383fce014861a to your computer and use it in GitHub Desktop.

Download ZIP

Minimal claude -p alternative for CI/CD tasks — subscription billing, no daemon, no MCP

Raw

gistfile0.txt

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.<br>Learn more about bidirectional Unicode characters

Show hidden characters

#!/usr/bin/env python3

"""

Minimal claude -p alternative for one-shot CI/CD tasks.

Uses interactive mode (subscription billing) instead of claude -p (API billing).

Usage:

python3 claude_task.py "review this diff and summarize changes"

Requires:

- Claude Code installed (https://docs.anthropic.com/en/docs/claude-code)

- Logged in with subscription account

Part of the poor-claude project:

https://github.com/HammerMei/poor-claude

https://dev.to/hammermei/how-i-kept-my-ai-family-alive-after-anthropics-claude-p-billing-change-k1i

"""

import os

import signal

import subprocess

import sys

import time

import uuid

from pathlib import Path

def run_claude(prompt: str, timeout: int = 120, retries: int = 2) -> str:

"""Run a one-shot Claude task using interactive mode (subscription billing)."""

for attempt in range(retries + 1):

resp_file = Path(f"/tmp/claude-resp-{uuid.uuid4().hex}.txt")

full_prompt = (

f"{prompt}\n\n"

f"Write your final response to: {resp_file}\n"

f"Then exit by running in bash: kill $PPID"

proc = subprocess.Popen(

["claude", "--permission-mode", "bypassPermissions", full_prompt],

start_new_session=True,

try:

deadline = time.time() + timeout

while time.time() deadline:

if resp_file.exists():

return resp_file.read_text()

time.sleep(0.5)

# Timeout — kill the process

try:

os.killpg(proc.pid, signal.SIGTERM)

except (ProcessLookupError, PermissionError):

proc.terminate()

finally:

resp_file.unlink(missing_ok=True)

proc.wait()

if attempt retries:

print(f"Timeout — retrying ({attempt + 1}/{retries})...", file=sys.stderr)

raise TimeoutError("claude did not respond in time")

if __name__ == "__main__":

if len(sys.argv) 2:

print("Usage: python3 claude_task.py ", file=sys.stderr)

sys.exit(1)

print(run_claude(" ".join(sys.argv[1:])))

Sign up for free<br>to join this conversation on GitHub .<br>Already have an account?<br>Sign in to comment

You can’t perform that action at this time.

claude gist clone time billing github

Related Articles