feature request: exec --output-last-message to stdout
Resolved 💬 3 comments Opened Jul 24, 2025 by MauScheff Closed Oct 3, 2025
💡 Likely answer: A maintainer (bolinfest, collaborator)
responded on this thread — see the highlighted reply below.
I would like to be able to easily build a command that automatically writes commit messages because I don't like writing them. Ideally I could use bash string interpolation to pipe the output of codex exec "Write a good commit message for the current changes" and construct commands based on the output from codex. Right now the closest way to do this is to write to a file. Would it be possible to just output to stdout the last message when doing codex exec?
3 Comments
I think something in this direction makes sense, but I'm not sure it should be the default because for an interactive user, they would currently see the message twice: once as streamed to stderr and then again for stdout.
We could of course introduce a new flag, though I suppose it also raised the question of whether
--output-last-messageshould _go away_ and that users should docodex exec --new-flag PROMPT > OUTPUT_FILEinstead, though I think--output-last-messagestill has merit in that case since we may want to provide other options in the future to print other things to stdout?Thoughts?
In the meantime, fwiw, there is
git commit --filethat uses the specified file contents as the commit message if you want to build your own little wrapper script for now.hmmm...
Thanks! I didn't know about
git commit --file.. That's better than copy+paste every time.If I didn't read the docs and I had to guess what --output-last-message does based on the name, my intuition would tell me it prints to stdout. For me, the linux way would be to do one thing and do it well: and then compose (eg. with redirection
>).It could be another flag name but I would kind of expect to be able to do this from a cli tool. It could also help in simple onboarding new users by providing examples that are read-only and output only for understanding the code base. For example, on the main README.md there could be one line use case examples like
codex "What would you improve in this codebase?" ----one-message/--respondthis could be a risk-free and simple way to get started. When I first used codex I was worried about it changing the code (not knowing how it works) so I had to dig in and read before I could start playing with it.I don't know what's the best way to handle stderr, in some use cases, like these you only care about the last message. If it errors I guess getting an empty output isn't that bad (1% of the times).
I'd question what use case does --output-last-message solve? (and if this can be consolidated in one flag or needs two).
It makes sense that most of the usefulness comes from interactive mode and being able to iterate, and if you output only you can't follow-up, but sometimes you want just one response (not often, but sometimes).
Hope this helps somehow.
👍🏿
I also would like to be able to pipe
codex -execoutput to other commands, particularly using structured output.