What are you using print mode (`claude -p`) for? We want to hear your use cases!

Status Fixed / completed
Maintainer reply None cached
Activity 6 comments · opened Apr 10, 2025 · closed May 8, 2025

Share your favorite use cases for using print mode in Claude Code!

For context, print mode is a way to use Claude Code as a Unix-style utility.

View original on GitHub ↗

6 Comments

wanderingnature · 1 year ago

Well, I can add more later - but for now here's my recent issue (just logged a bug). Claude just keeps plowing along and eating up tokens and my $$$ when it does not have appropriate permissions. I was just experimenting with letting claude run wild with a feature request and all the implementation details to complete it. I had allowed FileWriteAccess and FileEditAccess (after seeing messages that it could not do either). That prompt cost about $1, but Claude never failed it just kept plowing along eating up tokens and generated a bunch of code it wanted me to copy/paste. Not what I use claude -p for...

After adding those permissions I find Claude also wants permission for 'Replace' (see the bug I just submitted about that) which is an undocumented permission. So again it just eats up tokens and doesn't perform the requested task, giving me a response with code I need to copy/paste.

In such a case 'claude -p' needs to fail gracefully with an appropriate message so I do not waste MORE MONEY and I can actually FIX the problem. Something like 'The User request required me to replace file contents but I do not have permission to do so, please update my permissions to allow me to replace file content if you need me to complete this request' and then it might even offer some hints about how to resolve the issue.

Here's an example:

"content": [
{
"type": "text",
"text": "It seems I still don't have the necessary permissions. Let me request them and continue with the implementation."
},
{
"type": "tool_use",
"id": "toolu_012ZeHMpXqz4sE4BdDR3rCA5",
"name": "dispatch_agent",
"input": {
"prompt": "Look for existing radio button or similar components in the codebase. I need to see how form controls are implemented since we'll need a radio button component for the export modes. Check base components directory or any UI library being used."
}
}
],

It makes no sense that Claude is running with -p but thinks it can request missing permissions.

danny-hunt · 1 year ago

Print mode is awesome! Using it primarily for automating unit test writing & fixing, as well as resolving linting errors. Basically specific tasks where there is a bash command you can run that tells you whether the changes are working or not (some automated source of truth)

tsplude · 1 year ago

I want to be able to benchmark the impact a particular MCP server has on claude code's analysis, and print mode is the easiest way to collect usage stats (with --output-format "json")

HOWEVER, I would ideally be able to get tokens in and tokens out counts. Why can't we access those at all? It's frustrating that I only get usage reported as dollars spent in claude code but the anthropic console usage page only reports in tokens in and tokens out.

tino · 1 year ago

Analysing (breaking) changes for dependabot (grouped) package updates in the CI. Given the output from the PandaBot is quite terse and never shows the full changelog, we're having Claude fetch the actual changelog and then go through our code and see whether things that are changed are used, which is helpful.

However, also see #949, which echo's @wanderingnature's comment.

Connoropolous · 1 year ago

@ashwin-ant print mode is AMAZING. I am using the stream-json output, as well as --continue. If you don't have a claude max subscription you can actually get per issue cost tracking which is wild.
We're using it at Ceedar to automate PR creation as our own "Devin"
I integrated it with Linears agent api to assign tasks in Linear, and it can run as many tasks in parallel as we want.
https://github.com/ceedario/secret-agents

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.