[BUG] Slash command autocomplete ignores exact matches and executes wrong command
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:
- Exact matches (highest priority) -
/cleartyped fully should match/clear - Prefix matches (high priority) -
/cleshould match/clearbefore/commit - 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
- In the Claude Code CLI, start typing a slash command:
/cle - Observe that
/commitappears first in autocomplete (not/clear) - Continue typing the full command:
/clear /commitstill appears first in suggestions (not/clear)- Press Enter expecting
/clearto execute /commitexecutes 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).
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗