[BUG] Slash Commands Fail to Load Due to Race Condition in Ripgrep Command Discovery (Windows)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
This is an issue for Claude Code for VS Code
Slash commands in .claude/commands/ intermittently fail to load on Windows. When opening a new Claude Code (VS Code Extension) chat, sometimes all commands load correctly, and sometimes only the first command alphabetically (/advanced-elicitation) appears only the first few, etc...random..
The issue is caused by two problems:
- Ripgrep abort race condition: The ripgrep scan of
.claude/commands/is aborted before completing, resulting in partial command discovery.
- First-result-wins parallelization bug: Multiple agents run in parallel and report different command counts. The UI binds to whichever agent reports first, even if a complete result arrives milliseconds later.
Debug logs show two agents reporting within 8ms of each other:
- Agent A reports 1 command at 22:12:23.231 → UI uses this (incomplete)
- Agent B reports 29 commands at 22:12:23.239 → Ignored!
Shell snapshot creation also consistently fails with SIGTERM after ~19 seconds, which may contribute to the timing issues.
What Should Happen?
All slash commands in .claude/commands/ should load reliably every time a new chat is opened, regardless of:
- System load or I/O contention
- Which parallel agent finishes first
- Shell snapshot creation timing
The command discovery should either:
- Wait for all parallel agents to complete before binding to UI
- Take the result with the highest command count
- Merge results from all agents
- Not race against shell snapshot creation
Error Messages/Logs
# Ripgrep abort errors (appear in every session):
2025-12-05T22:08:17.549Z [DEBUG] rg error (signal=undefined, code=ABORT_ERR, stderr: ), 1416 results
2025-12-05T22:08:17.549Z [ERROR] AbortError: The operation was aborted.
# Shell snapshot SIGTERM (appears in every session):
2025-12-05T22:08:17.550Z [DEBUG] Shell snapshot creation failed
2025-12-05T22:08:17.550Z [DEBUG] - Error signal: SIGTERM
2025-12-05T22:08:17.550Z [DEBUG] - Error killed: true
# First-result-wins race condition (8ms apart, wrong result used):
2025-12-05T22:12:23.231Z [DEBUG] Slash commands included in SlashCommand tool: /advanced-elicitation
2025-12-05T22:12:23.240Z [DEBUG] Slash commands included in SlashCommand tool: /advanced-elicitation, /analyst, /create-epics-and-stories, ... (all 29 commands)
# Ripgrep test results vary between agents:
2025-12-05T22:08:17.537Z [DEBUG] Ripgrep first use test: PASSED (agent with all commands)
2025-12-05T22:08:22.520Z [DEBUG] Ripgrep first use test: FAILED (agent with 1 command)
Steps to Reproduce
- Create a
.claude/commands/directory with multiple.mdcommand files (I have 29 commands including a subdirectory with 4 agents)
- Open VS Code with the Claude Code extension
- Open a new Claude Code chat (click the Claude Code icon or use command palette)
- Check the slash command list by typing
/in the input
- Observe that sometimes all commands appear, sometimes only 1(or more--but not all) (
/advanced-elicitation)
- Close the chat and open a new one - repeat steps 4-5 multiple times
- Notice the inconsistent behavior - opening 5 new chats might result in 1 loading all commands and 4 loading only 1
- Check the extension logs (Developer: Open Extension Logs) to see the race condition in action
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.0.45 maybe? i ran into it when i upgraded last time, then gave up and downgraded back to 45...was hoping it was fixed by now...worked for a w hile then started again/randomly/intermittently
Claude Code Version
2.0.59
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
Terminal/Shell
Git Bash (C:\Program Files\Git\bin\bash.exe)
Factors that affect success rate:
- Number of commands: More commands = higher chance of incomplete scan
- Subdirectories in .claude/commands/: May contribute to timing issues
Workarounds tried (may or may not help....intermittent so totally random):
- Pause OneDrive sync for the project directory
- Close Claude desktop app and other Claude Code windows
- Keep opening new chat windows until one succeeds
- Flatten command structure (avoid subdirectories) -- this is the biggest thing...if we flatten everything into just the commands path, it seems to fail WAY LESS, once we start having more commands in subdirectories, the rate of failure goes up considerably
Root cause analysis:
The bug has two components:
- Ripgrep timing: The
rgscan is aborted before completing. When it gets 1416+ results before abort, commands load. When it gets 0 results, only the first few alphabetical command loads.
- Parallel agent race: Two agents run simultaneously and report different results. The UI binds to the first reporter regardless of completeness:
- 22:12:23.231 → 1 command (UI uses this)
- 22:12:23.239 → 29 commands (ignored, only 8ms later!)
Suggested fixes:
- Don't abort ripgrep prematurely - let command scan complete
- Wait for all parallel agents OR take the result with highest count
- Decouple shell snapshot creation from command discovery
- Add retry mechanism if ripgrep returns 0 results
- Surface errors to user instead of silent failure
- Increase timeout on Windows (slower I/O than Unix)
Environment details:
- Windows 11
- VS Code (latest)
- Claude Code Extension 2.0.59
- Git Bash as default shell
- Project has 29 slash commands (25 in root, 4 in agents/ subdirectory)
- .bashrc is minimal (only 7 lines)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗