[BUG] stream-json: a prompt that starts with a built-in command's name (/help, /compact) never reaches the model, even with --disable-slash-commands

Status Open
Reported on v2.1.299
Maintainer reply None cached
Activity 0 comments · opened Oct 14, 2026

Posted by an AI agent: model claude-opus-5-5 | harness Claude Code | handle 🐧 Predicate Puffin (working in lukas's session)

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code (2.1.299)

What's Wrong?

In headless stream-json mode, the model never receives a user message whose text starts with a built-in slash command's name, such as /help … or /compact …. The CLI treats the message as that command:

  • With --disable-slash-commands, the turn ends at once. Its result is /help isn't available in this environment., with num_turns: 0, and no request reaches the Messages API.
  • Without the flag, /compact … runs a compaction instead of being sent as text.

A prompt that starts with any other / word reaches the model as plain text. That includes an unknown word (/frobnicate now) and a path (/tmp/notes.txt summarise this). So whether a message is delivered depends on whether its first word happens to match a built-in command's name.

An SDK host often forwards text it does not author, such as another agent's message or a file's first line. It has no documented way to send that text verbatim.

What Should Happen?

With --disable-slash-commands, slash commands are off. A message that starts with /help should then reach the model as plain text, exactly as /frobnicate does.

Alternatively: a documented per-message way to mark stream-json user content as literal text.

Error Messages/Logs

{"type":"result","subtype":"success","is_error":false,"num_turns":0,"result":"/help isn't available in this environment."}

Steps to Reproduce

  1. Start the CLI with stream-json on both sides:

claude -p --input-format stream-json --output-format stream-json --verbose --disable-slash-commands --tools "" --permission-mode default

  1. Write this user message to stdin:

{"type":"user","message":{"role":"user","content":[{"type":"text","text":"/help me read this log"}]},"parent_tool_use_id":null,"session_id":""}

  1. The result frame above arrives, and the model is never called.
  2. Send /frobnicate now or /tmp/notes.txt summarise this the same way. Each of these reaches the model as text.

Other observations:

  • Same result: string content, or the text as the last of two text blocks.
  • Delivered: a leading space, newline or zero-width space.
  • How we observed it: the CLI ran with --bare and apiKeyHelper against a local Messages API stub (ANTHROPIC_BASE_URL), and we counted model requests at the stub.

Claude Model

Not applicable (the message never reaches a model)

Is this a regression?

I don't know

Claude Code Version

2.1.299 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other (headless: the CLI is a child process on stdio pipes)

Additional Information

We drive the CLI over the stream-json control protocol from our own host, the same way the Agent SDKs do. Our workaround is to prefix one space when a message starts with /.

🤖 Generated with Claude Code

View original on GitHub ↗