Skip to main content

claude-print-subprocess-error-streams

Fix for opaque `RuntimeError: Claude session failed: ` (or any wrapper-error with empty content) when wrapping `claude --print --output-format json` in Python subprocess. Use when: (1) you wrap `claude --print` (or any `claude` non-interactive CLI invocation) via `subprocess.run` / `subprocess.communicate` to drive batch automation; (2) the subprocess exits with non-zero returncode but `result.stderr` is empty so your error message is empty; (3) you suspect an error happened inside the Claude session but can't see it. Root cause: `claude --print --output-format json` writes its session result — including errors as `{"is_error": true, ...}` JSON — to STDOUT, not STDERR. Wrappers that surface only `result.stderr` lose the actual error. The fix is to surface BOTH streams in the wrapper's RuntimeError, with `result.stdout` taking the larger budget since errors are JSON there.

Jump to install

Source facts

Repository
cajias/claude-skills
Last source activity
July 20, 2026 at 07:29
Detected SKILL.md language
English
Stars
0
Forks
0

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.