Skip to content

Support piping from claude CLI --output-format stream-json #45

@golergka

Description

@golergka

Feature Request

Add support for piping live output from claude -p --output-format stream-json directly into claude-code-log for real-time log processing.

Context

This is a follow-up to #43, which added text/markdown/chat output formats. During implementation, we discovered that the stream-json format from Claude Code's live output has a different schema than saved transcript files:

Stream-json format (from claude -p):

  • Missing fields: parentUuid, isSidechain, userType, cwd, version, timestamp
  • Different structure optimized for streaming

Saved transcript format (from ~/.claude/projects/):

  • Complete metadata fields
  • Full session information
  • What claude-code-log currently supports

Proposed Solution

Add a --stream-json mode that:

  1. Accepts piped input from claude -p --output-format stream-json
  2. Handles the different schema (missing metadata fields)
  3. Outputs formatted text in real-time or buffers until completion
  4. Works with existing format options (text, markdown, chat)

Example Usage

# Real-time CI/CD log formatting
claude -p "Review this code" --output-format stream-json | claude-code-log --stream-json --format chat

# Or capture to file
claude -p "Build project" --output-format stream-json | claude-code-log --stream-json --format markdown > build-log.md

Benefits

  • Enables CI/CD integration as originally requested in Plain text output? #43
  • Real-time log visibility for long-running Claude operations
  • Complements existing saved transcript processing

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions