Claude Headless
One-shot LLM calls from scripts and hooks via headless claude -p, with a recursion guard, JSON envelope parsing, tool restriction and spend logging.
$3
Works with the AI Agents you already use
Claude Headless
Example session with this skill installed
python3 claude_cli.py "reply with exactly: pong" --model haiku
- Read your context and instructions
- Compiled the claude headless
pong
Connects securely to your tools. The creator never sees your data.
About this skill
Need a model call inside a hook or script (summarize, classify, score, extract JSON) without adding an SDK or API key? Claude Headless shells out to claude -p, so it uses whatever auth and provider Claude Code is already set up with.
What you get
claude_cli.py:ask(),ask_json(),is_child()and a small CLI (python3 claude_cli.py "prompt" --model haiku, or-to read the prompt from stdin).- Recursion guard.
claude -pstarts a real session that fires your hooks, so a Stop hook that callsclaude -pwould loop forever. Every call setsCLAUDE_KIT_CHILD=1; model-calling hooks start withif is_child(): sys.exit(0). - Runs
--no-session-persistence --output-format json: no transcript is written, and the result envelope (result,is_error,usage,modelUsage,total_cost_usd,session_id) is parsed. Envelope fields verified against current Claude Code. - Optional tool restriction (
allowed_tools) and working directory (cwd). CLAUDE_KIT_PIN_ANTHROPIC=1to drop base-URL and key variables from the child when your main session points at a local model server.- Bundled
spend_tracker.pylogs every call's usage and cost so the Spend Tracker skill can report background spend.
Tested: ask, ask_json with fenced JSON, stdin prompt, recursion flag and spend logging, against a live claude install.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.
Each call pays Claude Code's startup context, so a trivial call costs a few cents uncached; do not call per keystroke. ask_json fails if the model wraps the JSON in prose, so ask for only JSON and catch json.JSONDecodeError. Needs claude on PATH and a working login. ask() raises RuntimeError on non-zero exit, empty output or an error envelope.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 13 days ago
- Accounts
- claude CLI on PATH with a working login
- Software
Python 3.9+
Permissions
Allowed Hosts
File Scopes
Spawns the claude CLI as a subprocess. Does not read credentials itself; with CLAUDE_KIT_PIN_ANTHROPIC=1 it only removes ANTHROPIC_* variables from the child environment.