claude-print-subprocess-error-streams

Fix Python subprocess wrappers to surface stdout and stderr errors.

Updated Nov 18, 2025
One-click install
npx skills add https://github.com/cajias/claude-skills --skill claude-print-subprocess-error-streams
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-print-subprocess-error-streams
Source: https://github.com/cajias/claude-skills/tree/main/plugins/cc-authoring/skills/claude-print-subprocess-error-streams
Command: npx skills add https://github.com/cajias/claude-skills --skill claude-print-subprocess-error-streams

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill fixes Python wrappers that return an empty or misleading error when a Claude non-interactive subprocess fails, especially when the real failure message is hidden in standard output instead of standard error.

Core Features & Use Cases

  • Dual-stream error reporting: Captures both stdout and stderr so Claude session failures are visible.
  • JSON error handling: Handles --output-format json and checks for is_error payloads explicitly.
  • Batch automation debugging: Helps diagnose broken CLI wrappers, transient failures, and hidden session errors in scripted workflows.
  • Use case: If a subprocess call to Claude exits non-zero with an empty stderr, this Skill shows how to surface the actual session error from stdout.

Quick Start

Update your Claude subprocess wrapper so that any non-zero return code raises an error including both stdout and stderr, with extra attention to parsing JSON output for an is_error flag.

Frequently Asked Questions about claude-print-subprocess-error-streams

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my Python subprocess wrapper return an empty error when Claude CLI fails?

When a Claude CLI subprocess fails non-zero, the actual session error is often hidden in stdout instead of stderr. You need to capture both streams and validate JSON output for is_error payloads to surface the real failure message.

How do I capture stderr and stdout from a Claude CLI subprocess in Python?

To capture stderr and stdout from a Claude CLI subprocess in Python, update your wrapper to raise an error including both streams on any non-zero return code. This dual-stream error reporting ensures hidden session failures become visible during batch automation.

How do I handle JSON error envelopes from Claude CLI in Python scripts?

To handle JSON error envelopes from Claude CLI in Python scripts, parse the stdout payload when using the --output-format json flag. You must explicitly check the output for an is_error flag to identify and extract the actual session failure details.

What is the best way to debug empty stderr from a Claude CLI batch automation script?

The best way to debug empty stderr from a Claude CLI batch automation script is to inspect stdout. Claude session failures often appear only in standard output, so surfacing and parsing both streams reveals the hidden transient failures or broken wrapper errors.

Can I use Python subprocess to diagnose transient failures in Claude CLI workflows?

Yes, you can use Python subprocess to diagnose transient failures in Claude CLI workflows by capturing both stdout and stderr. This approach exposes hidden session errors and validates JSON output to pinpoint the exact failure cause in scripted invocations.