Claude Corner

Lost in a Long Build Log? Feed It to claude -p and Keep the Answer in a File.

By ยท 17 Nov 2026

A developer seen from behind at a pale maple desk looks at a landscape monitor with a tall cream panel and three stacked blank tiles against a bright rose wall, with a blank white keyboard on the desk.

At a glance

  • claude -p reads a build log on stdin and prints its answer, so you can save the explanation to a file.
  • --continue sends a second question to that same conversation without opening a session.
  • --output-format json adds the session ID and an estimated cost next to the answer.

Your build fails with three hundred lines of output. You could paste the log into a Claude Code chat and scroll back later, or you could ask from the shell and keep the answer in a file next to the log. For naming and resuming an interactive session, see our Oct 26 Corner on naming and resuming sessions.

Why it matters

Anthropic's docs describe print mode, started with -p, as a way to use Claude like any other command line tool. A log can go in on stdin, and the response can be redirected to a file. The docs use this example: explain the root cause of a build error and write it to a file. --continue then picks up the most recent conversation.

How to explain a build log with print mode

We built these steps from Anthropic's docs and have not run them in a live session.

  1. Save the failing build output to a file in your project folder, for example build-error.txt.
  2. Run claude -p with a short question, send the log in on stdin, and redirect the answer to a file.
  3. Ask a follow up with --continue from the same folder.
  4. Add --output-format json when you want the answer in a result field, plus the session ID and a total_cost_usd estimate.
  5. Open the files and read the answers.
# We have not run this script end to end on every platform.
# Run it from your project folder after saving your failing build output to build-error.txt.

claude --version

# Ask for the root cause. The log goes in on stdin and the answer goes to a file.
claude -p 'concisely explain the root cause of this build error' < build-error.txt > explanation.md

# Follow up in the same conversation.
claude -p 'Which files should I open first to fix it?' --continue > next-steps.md

# Optional JSON with the session ID and an estimated cost.
claude -p 'Summarize the fix in three lines' --continue --output-format json > summary.json

cat explanation.md next-steps.md summary.json

Gotchas

  • Plain claude --continue skips these runs. An interactive --continue skips sessions created with claude -p, while claude -p --continue includes them. To continue a specific print mode conversation, pass its session ID from the JSON output to claude -p --resume, as the docs show.
  • Prompts are denied, not asked. With Claude Code v2.1.302 or later, a claude -p run starts in Manual mode when nothing sets a permission mode, and a call that needs approval is denied unless something approves it. File reads in your working directories need no approval.
  • Trust the folder first. A -p session runs the hooks in a project's .claude/settings.json and connects the servers in its .mcp.json, even in a folder you never trusted, with no trust dialog. Only run it in repositories you trust.
  • Stdin stops at 10MB. Piped stdin is capped at 10MB, and Claude Code exits with an error and a nonzero status above that. For a bigger log, name the file path in your prompt instead.
  • The cost is an estimate. total_cost_usd is a client side estimate and can differ from your bill. After --continue, it reports the whole conversation's total, earlier runs included.

Sources:

Recommended AI prompt

Copy this paragraph into ChatGPT, Claude, Gemini, Grok, or whatever AI you use.

Prompt

Using only Anthropic's Claude Code docs for claude -p and the CLI reference, show me how to send a log file in on stdin, save the answer to a file, ask follow up questions with continue, and read the JSON output. Give a short checklist covering permissions, folder trust and the 10MB stdin cap. Ask which shell and build tool I use before suggesting commands.