[BUG] Slash command autocomplete ignores exact matches and executes wrong command

Resolved 💬 3 comments Opened Jan 24, 2026 by ngphadke Closed Jan 24, 2026

Preflight Checklist

  • [x] I have searched existing issues to ensure this bug hasn't already been reported
  • [x] This is a single bug report, not multiple issues
  • [x] I am using the latest version of Claude Code

## What's Wrong?

The slash command autocomplete ignores exact matches and prioritizes fuzzy/substring
matching instead. When I type /clear completely, the autocomplete still shows
/commit first and pressing Enter executes /commit instead of /clear.

This behavior did not occur earlier when I had fewer slash commands installed.
The bug appears to worsen or only manifest when many custom commands/skills are
available (~31 total in my setup).

## What Should Happen?

The autocomplete ranking should prioritize:

  1. Exact matches (highest priority) - /clear typed fully should match /clear
  2. Prefix matches (high priority) - /cle should match /clear before /commit
  3. Substring/fuzzy matches (lower priority)

When I press Enter, the command that is shown/highlighted should execute, or if I've
typed a complete exact match, that command should execute.

## Steps to Reproduce

  1. In the Claude Code CLI, start typing a slash command: /cle
  2. Observe that /commit appears first in autocomplete (not /clear)
  3. Continue typing the full command: /clear
  4. /commit still appears first in suggestions (not /clear)
  5. Press Enter expecting /clear to execute
  6. /commit executes instead

## Claude Code Version

2.1.19

## Platform

macOS (Darwin 24.4.0)

## Additional Information

Environment:

  • Shell: zsh
  • Installed skills/commands: 31 custom skills (15 user skills + 16 plugin skills)

Regression pattern:

  • Worked correctly with fewer slash commands installed
  • Broke after reaching ~31 total custom commands
  • Suggests autocomplete algorithm degrades with larger command sets

Impact:
This is dangerous - users type one command, see another suggested, and have a third
command execute. Particularly problematic for destructive commands.

Workaround:
Use arrow keys to manually select the correct command instead of pressing Enter on
the first suggestion.

Potential root cause:
May be related to performance optimization that skips proper ranking when command
list exceeds a threshold (possibly SLASH_COMMAND_TOOL_CHAR_BUDGET).

View original on GitHub ↗

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