claude-code - 💡(How to fix) Fix [BUG] Slash commands/skills in .claude/commands/ not discovered when using symlinks (regression) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45547Fetched 2026-04-09 08:02:50
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×5commented ×1

Symlinked .md files and directories inside .claude/commands/ are not discovered as slash commands. This is a regression -- symlinks were followed correctly in earlier versions (confirmed working in 2.1.87) but fail silently in 2.1.89.

Error Message

Symlinks are silently ignored during command discovery. No error message is shown. Commands only work when files are real (non-symlinked).

Root Cause

Symlinked .md files and directories inside .claude/commands/ are not discovered as slash commands. This is a regression -- symlinks were followed correctly in earlier versions (confirmed working in 2.1.87) but fail silently in 2.1.89.

Code Example

mkdir -p ~/my-shared-commands/mytools
   echo "Do something useful." > ~/my-shared-commands/mytools/hello.md

---

mkdir -p .claude/commands/mytools
   ln -sf ~/my-shared-commands/mytools/hello.md .claude/commands/mytools/hello.md

---

file .claude/commands/mytools/hello.md
   # Reports: Unicode text, UTF-8 text
   cat .claude/commands/mytools/hello.md
   # Shows content correctly

---

rm .claude/commands/mytools/hello.md
   cp ~/my-shared-commands/mytools/hello.md .claude/commands/mytools/hello.md
RAW_BUFFERClick to expand / collapse

Summary

Symlinked .md files and directories inside .claude/commands/ are not discovered as slash commands. This is a regression -- symlinks were followed correctly in earlier versions (confirmed working in 2.1.87) but fail silently in 2.1.89.

Reproduction Steps

  1. Create a directory with command files elsewhere on the filesystem:

    mkdir -p ~/my-shared-commands/mytools
    echo "Do something useful." > ~/my-shared-commands/mytools/hello.md
  2. Symlink into your project's .claude/commands/:

    mkdir -p .claude/commands/mytools
    ln -sf ~/my-shared-commands/mytools/hello.md .claude/commands/mytools/hello.md
  3. Verify the symlink resolves:

    file .claude/commands/mytools/hello.md
    # Reports: Unicode text, UTF-8 text
    cat .claude/commands/mytools/hello.md
    # Shows content correctly
  4. Start Claude Code -- the command /mytools:hello does not appear in the slash command list.

  5. Remove the symlink and copy the file instead:

    rm .claude/commands/mytools/hello.md
    cp ~/my-shared-commands/mytools/hello.md .claude/commands/mytools/hello.md
  6. Restart Claude Code -- the command now appears correctly.

Also affects directory symlinks

Symlinks pointing to directories containing nested .md command files also fail discovery.

Expected Behavior

Symlinked .md files in .claude/commands/ (and .claude/skills/) should be discovered and loaded as slash commands, just as regular files are. This worked in version 2.1.87.

Actual Behavior

Symlinks are silently ignored during command discovery. No error message is shown. Commands only work when files are real (non-symlinked).

Use Case

Shared command libraries across multiple projects. A common pattern is to maintain a central repository of reusable commands and symlink them into each project's .claude/commands/ directory. This avoids duplication and keeps commands in sync across projects.

Environment

  • Claude Code 2.1.89 (broken)
  • Claude Code 2.1.87 (working)
  • macOS Darwin 24.5.0 (Apple Silicon)
  • Symlink targets are on the same filesystem (not cross-mount)

Suggested Fix

The file discovery mechanism for commands/skills should follow symlinks (e.g., use fs.stat instead of fs.lstat, or pass appropriate flags to the directory walker). Since the Read tool already follows symlinks correctly, this appears to be an inconsistency in the discovery code path.

extent analysis

TL;DR

The issue can be fixed by modifying the file discovery mechanism to follow symlinks, potentially by using fs.stat instead of fs.lstat or passing appropriate flags to the directory walker.

Guidance

  • Review the code changes between versions 2.1.87 and 2.1.89 to identify the specific modification that caused the regression.
  • Verify that the fs module is being used correctly, and consider using fs.stat instead of fs.lstat to follow symlinks.
  • Test the discovery mechanism with different types of symlinks (e.g., file and directory symlinks) to ensure it works correctly in all cases.
  • Consider adding error handling or logging to detect and report issues with symlink resolution during command discovery.

Example

// Example of using fs.stat to follow symlinks
const fs = require('fs');
fs.stat('.claude/commands/mytools/hello.md', (err, stats) => {
  if (err) {
    console.error(err);
  } else {
    console.log(stats);
  }
});

Notes

The suggested fix assumes that the issue is due to the file discovery mechanism not following symlinks. However, without access to the code, it's difficult to provide a more specific solution. Additionally, the fix may require modifications to the directory walker or other parts of the code.

Recommendation

Apply a workaround by using a script to copy the symlinked files into the .claude/commands/ directory, rather than relying on symlinks. This will ensure that the commands are discovered correctly, although it may not be the most elegant solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING