claude_run
Execute a one-shot Claude Code task with a prompt and get structured JSON output, for non-conversational work such as reviewing diffs, answering questions, or making a single change.
Instructions
Run a one-shot claude -p task and return structured JSON.
Best for work that needs no conversation: review a diff, answer a question, make one contained change. Cheaper and faster than a tmux session.
Pass session_name to resume a managed session's conversation, so one-shot and interactive work share history. A live, busy session is refused (two writers would corrupt the transcript); a live idle one is allowed but the running TUI will not show the turn until restarted. fork=True branches to a new session ID instead, avoiding both issues.
Returns {result, session_id, num_turns, total_cost_usd, duration_ms}.
Always set max_turns to bound cost.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | ||
| fork | No | ||
| model | No | ||
| effort | No | ||
| prompt | Yes | ||
| add_dir | No | ||
| timeout | No | ||
| max_turns | No | ||
| session_name | No | ||
| allowed_tools | No | ||
| permission_mode | No | ||
| disallowed_tools | No | ||
| append_system_prompt | No |