[BUG] Built-in CLI commands passed to AI as regular messages, causing unintended actions

Resolved 💬 3 comments Opened Feb 15, 2026 by mtskf Closed Feb 18, 2026

Bug Description

Built-in CLI commands (like /rename) are being passed to the AI as regular user messages, causing the AI to interpret and take unintended actions.

Steps to Reproduce

  1. Start a Claude Code session
  2. Execute a built-in command, e.g., /rename new-session-name
  3. Observe that:
  • The command is passed to AI as a regular message
  • AI attempts to interpret it (e.g., as a file rename request)
  • AI takes unintended actions (e.g., renaming files instead of the session)
  • The built-in command is eventually processed correctly, but after the AI has already acted

Expected Behavior

Built-in CLI commands should be intercepted and processed by the CLI before being passed to the AI. The AI should never receive these commands as regular messages.

Actual Behavior

  1. /rename chrome-issue is received by AI as a regular user message
  2. AI interprets it as a file rename request
  3. AI executes: mv /path/to/file.md /path/to/chrome-issue.md
  4. Then the built-in command is processed: Session and agent renamed to: chrome-issue

Impact

Critical: This can cause unintended file system modifications, data loss, or other destructive actions when AI misinterprets built-in commands.

Examples of potential issues:

  • /clear might cause AI to delete files
  • /help might trigger unexpected actions
  • Any built-in command could be misinterpreted

Environment

  • Claude Code Version: 2.1.42
  • OS: macOS (Darwin 25.3.0)
  • Shell: zsh

Evidence

The AI received the command with this system reminder:

The user sent a new message while you were working:
/rename chrome-issue

IMPORTANT: After completing your current task, you MUST address the user's message above.

Then later, the command was processed:

<command-name>/rename</command-name>
<command-args>chrome-issue</command-args>
<local-command-stdout>Session and agent renamed to: chrome-issue</local-command-stdout>

Related Issues

  • #18754 (Slash commands not working)
  • #16072 (System prompt conflates skills and slash commands)

Suggested Fix

Built-in CLI commands should be:

  1. Intercepted by the CLI parser before being sent to AI
  2. Processed immediately without AI involvement
  3. Never appear in AI context as user messages

Only user-defined skills should be passed to AI via the Skill tool.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗