enthropeek
v0.1.0
Published
Run Claude Code interactive mode, capture one response, and exit.
Maintainers
Readme
clawp
Run Claude Code in interactive mode, capture a single assistant response, exit, and print that response as normal CLI output.
clawp intentionally does not use claude -p. It starts claude "<prompt>" with a real pseudo-terminal, waits for Claude Code to write the completed assistant turn to its session transcript, sends /exit, and prints only the assistant text.
Why
Claude Code's official non-interactive mode is claude -p, but sometimes you want the behavior of interactive Claude Code while still using it from scripts. clawp keeps the interactive startup path and turns the final assistant response into clean stdout.
Requirements
- Node.js 20+
- Claude Code CLI installed as
claude expectavailable onPATH
On macOS, expect is usually available by default. On Debian/Ubuntu:
sudo apt-get install expectInstall
npm install -g enthropeekOr run from this repo:
npm install
npm run build
node dist/cli.js "Reply with exactly OK."For local development:
npm link
clawp "Reply with exactly OK."Usage
clawp [claude flags...] "<prompt>"Examples:
clawp "Reply with exactly OK."
clawp --model sonnet "Summarize this repository."
clawp --permission-mode dontAsk --model opus "Review the current directory."All flags are passed directly to claude, except -p and --print, which are rejected because clawp is specifically for interactive mode.
Permissions
Claude Code's default permission mode can show an interactive approval picker for tool calls:
Do you want to proceed?
1. Yes
2. Yes, allow ...
3. Noclawp normally hides Claude Code's UI so stdout stays clean. That means a hidden approval picker would look like a hang. To avoid that, clawp exits with a clear error when it detects a permission prompt.
Use one of these patterns for tool-using prompts:
clawp --permission-mode dontAsk "Can you read ~/Documents?"Returns a normal Claude response, but denied tools stay denied.
clawp --clawp-auto-approve "Can you read ~/Documents?"Presses Enter when Claude shows a permission prompt, choosing Claude's default Yes option.
clawp --dangerously-skip-permissions "Can you read ~/Documents?"Passes Claude Code's full bypass flag through. Use only in environments where that is acceptable.
Environment
CLAWP_DEBUG=1 clawp "Reply with exactly OK."Mirrors Claude Code's raw interactive UI to stderr while still printing the captured response to stdout.
CLAWP_TIMEOUT_MS=120000 clawp "Do a bounded task."Overrides the default 10 minute timeout.
CLAWP_AUTO_TRUST=0 clawp "Reply with exactly OK."Disables automatic confirmation of Claude Code's workspace trust prompt. By default, clawp confirms that prompt so one-shot CLI usage can continue.
CLAWP_AUTO_APPROVE=1 clawp "Can you read ~/Documents?"Environment-variable equivalent of --clawp-auto-approve.
How It Works
- Generates a Claude session id.
- Starts
claude --session-id <id> ... "<prompt>"throughexpect, giving Claude Code a real pseudo-terminal. - Polls Claude Code's transcript at
~/.claude/projects/.../<session-id>.jsonl. - Waits for the completed assistant turn.
- Sends
/exit. - Prints the captured assistant text to stdout.
Development
npm install
npm run build
npm pack --dry-runLicense
MIT
