Claude Corner
Lost in a Long Build Log? Feed It to claude -p and Keep the Answer in a File.
By Steven Sorensen ยท 17 Nov 2026

At a glance
claude -preads a build log on stdin and prints its answer, so you can save the explanation to a file.--continuesends a second question to that same conversation without opening a session.--output-format jsonadds 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.
- Save the failing build output to a file in your project folder, for example
build-error.txt. - Run
claude -pwith a short question, send the log in on stdin, and redirect the answer to a file. - Ask a follow up with
--continuefrom the same folder. - Add
--output-format jsonwhen you want the answer in aresultfield, plus the session ID and atotal_cost_usdestimate. - 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 --continueskips these runs. An interactive--continueskips sessions created withclaude -p, whileclaude -p --continueincludes them. To continue a specific print mode conversation, pass its session ID from the JSON output toclaude -p --resume, as the docs show. - Prompts are denied, not asked. With Claude Code v2.1.302 or later, a
claude -prun 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
-psession runs the hooks in a project's.claude/settings.jsonand 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_usdis 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.
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.