[BUG] Undefined slash commands are silently sent to the model as plain text — no feedback, inconsistent with malformed-command handling

Resolved 💬 1 comment Opened Jun 10, 2026 by realdeal88 Closed Jun 10, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet (closest are #13757 / #16623, which are about defined commands erroring — this is the opposite: undefined commands not erroring; #8273 is about queued commands and is closed)
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code (2.1.170)

What's Wrong?

Slash-command parsing handles near-identical inputs in three different ways, and the most common failure mode is completely silent:

  1. /foo args where foo is a defined command → expands and runs. Correct.
  2. /foo args where foo is not defined → the whole line is silently forwarded to the model as plain text. No "unknown slash command" feedback, nothing in the UI indicates the command didn't exist. The model usually improvises and sort of obeys the text, so the user fully believes the command executed.
  3. / foo args (accidental space after the slash) → hard-rejected by the parser with `Commands are in the form /command [args] ` — the message is never sent at all.
  4. some text… /foo args (slash token mid-message) → treated as prose. (Probably by design, but combined with the above it adds to the "formatting roulette" feel.)

Case 2 is the bug. I used a /goal <directive> prefix across many sessions, convinced it was a command — it intermittently "worked" because the model happened to play along with the raw text, and intermittently didn't. There was no signal at any point that no command named goal existed. So from the user's seat, the same command "sometimes works, sometimes doesn't" depending on invisible factors, when in reality it never ran as a command even once.

The inconsistency makes it worse: a one-character formatting slip (/ foo) gets loud, immediate parser feedback, while a missing/mistyped command name (/fooo, /goal before the file exists, a plugin command that failed to load) gets zero feedback and silently degrades to model-interpreted prose.

What Should Happen?

Unknown slash commands should be handled explicitly and consistently with the malformed-command path — either:

  • reject with the existing "Unknown slash command: foo" feedback (the behavior older versions had, per #13757 / #16623), or
  • visibly annotate that no command matched and the input is being sent as a plain prompt (e.g. a dim notice line), so the user can tell "command executed" apart from "model improvised over my raw text".

Whichever direction, interactive mode and -p mode should agree.

Error Messages/Logs

# undefined command — no error, silently sent as prose:
$ claude -p '/foo reply with exactly: RECOGNIZED-AS-COMMAND'
RECOGNIZED-AS-COMMAND

# same input, one extra space — hard parser rejection:
$ claude -p '/ foo reply with exactly: RECOGNIZED-AS-COMMAND'
Commands are in the form `/command [args]`

Steps to Reproduce

  1. Make sure no command named foo exists (~/.claude/commands/, project .claude/commands/, plugins).
  2. Run:

``bash
claude -p '/foo reply with exactly: RECOGNIZED-AS-COMMAND'
`
Observed: prints
RECOGNIZED-AS-COMMAND. The line was handed to the model as plain text with no indication that /foo` is not a command.

  1. Run the same thing with a space after the slash:

``bash
claude -p '/ foo reply with exactly: RECOGNIZED-AS-COMMAND'
`
Observed:
Commands are in the form /command [args] ` — rejected before sending.

  1. Now create ~/.claude/commands/foo.md with any template containing a marker phrase and $ARGUMENTS, and run:

``bash
claude -p '/foo If this message contains the phrase "<marker>", reply exactly EXPANDED. Otherwise reply exactly RAW.'
`
Observed:
EXPANDED` — so the defined-command path works, confirming the contrast: defined → executes, malformed → loud error, undefined → silent passthrough.

The same silent passthrough happens in interactive mode, which is where it's most misleading — long multi-line directives pasted after an undefined /command are submitted as ordinary prompts with no feedback.

Environment

  • Claude Code: 2.1.170
  • OS: macOS 26.0 (Darwin 25.0.0)
  • Shell: zsh
  • Terminal: cmux (Ghostty-based)

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗