[BUG] Model incorrectly believes it's in interactive mode when using -p flag
Resolved 💬 2 comments Opened Jan 12, 2026 by ilyagr Closed Feb 26, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When running Claude Code in non-interactive print mode (-p), the model believes it's running interactively. This prevents users from providing mode-specific instructions (e.g., in CLAUDE.md) that should only apply to -p mode output.
What Should Happen?
The model should be aware it's running in -p mode, either via system prompt context or environment information.
Error Messages/Logs
Steps to Reproduce
$ claude -p 'Are you running interactively or non-interactively (in -p mode)?'
I'm running interactively. You're communicating with me through an interactive CLI session, not in non-interactive `-p` (print) mode. In `-p` mode, I would receive a prompt and produce output without back-and-forth conversation, but here we can have a dialogue.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.5 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
I ran into this because I wanted to provide conditional instructions like "when in -p mode, output strict CommonMark markdown", to work around #17554 (which I only care about when I pipe the output to pandoc)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗