claude-code - 💡(How to fix) Fix [Bug] Skill discovery and @path resolution fail in git worktrees with new files

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…

When developing a new skill or referencing a new doc inside a git worktree (files that exist on a feature branch but not yet on main), Claude Code's skill catalog and @path/to/file reference expansion both silently fail to resolve those files — even when the session is launched with the worktree as CWD.

Expected behavior

When Claude Code is launched with CWD inside a git worktree, skill discovery and @path resolution should use the worktree's working tree. New skill files at <worktree>/.claude/commands/<name>.md should appear in the skill catalog, and @<worktree-relative-path> references should expand to the file's current on-disk contents.

Error Message

The user has no indication the command they invoked isn't the command that ran. A clean Unknown skill: /<name> error would be the safer default.

Root Cause

When a slash command doesn't resolve to a registered skill, the CLI appears to substitute a different skill rather than erroring. This silent substitution is dangerous for destructive skills. Concrete example: a user types /my-new-readonly-skill, which isn't registered because it's worktree-only, and the session instead launches a registered skill that performs branch-merging, cleanup, or other non-reversible actions.

RAW_BUFFERClick to expand / collapse

[Bug] Skill discovery and @path references don't resolve files introduced in a git worktree

Summary

When developing a new skill or referencing a new doc inside a git worktree (files that exist on a feature branch but not yet on main), Claude Code's skill catalog and @path/to/file reference expansion both silently fail to resolve those files — even when the session is launched with the worktree as CWD.

Expected behavior

When Claude Code is launched with CWD inside a git worktree, skill discovery and @path resolution should use the worktree's working tree. New skill files at <worktree>/.claude/commands/<name>.md should appear in the skill catalog, and @<worktree-relative-path> references should expand to the file's current on-disk contents.

Actual behavior

  1. New skill files in the worktree are invisible to the skill catalog. A skill committed on a feature branch but not yet merged to main isn't registered. Typing /<new-skill-name> either errors, silently falls through, or — most dangerously — resolves to a different registered skill whose name happens to be close enough for the fuzzy matcher.
  2. @path/to/new-file.md references fail to expand when the path points to a file introduced on the feature branch and not present on main.

Why this is painful

It creates a chicken-and-egg problem for skill authoring. The natural iteration loop is:

  1. Create worktree + branch
  2. Draft new skill file
  3. Invoke the skill to observe behavior
  4. Iterate
  5. Merge when satisfied

Step 3 is impossible without shipping first. Authors can't dogfood new skills before merge, forcing blind PRs or awkward manual invocation ("read the skill file yourself and follow its steps"). The same applies to drafting documentation that the skill references — you can't preview the @path expansion until the file is on main.

Safety-relevant sub-issue

When a slash command doesn't resolve to a registered skill, the CLI appears to substitute a different skill rather than erroring. This silent substitution is dangerous for destructive skills. Concrete example: a user types /my-new-readonly-skill, which isn't registered because it's worktree-only, and the session instead launches a registered skill that performs branch-merging, cleanup, or other non-reversible actions.

The user has no indication the command they invoked isn't the command that ran. A clean Unknown skill: /<name> error would be the safer default.

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.114
  • Feedback ID: 7dc3ff91-4937-4548-8db3-d686a8c3b02f

Note: Content was truncated.

extent analysis

TL;DR

To resolve the issue, modify the skill discovery and @path resolution logic to account for files introduced in a git worktree.

Guidance

  • Review the current implementation of skill discovery and @path resolution to understand how it handles files in a git worktree.
  • Consider adding a check to include files from the worktree's working tree in the skill catalog and @path resolution.
  • Update the fuzzy matcher to handle cases where a skill is not registered, and instead of silently falling through or resolving to a different skill, return an "Unknown skill" error.
  • Investigate the possibility of using git worktree APIs to detect and include files from the worktree in the skill catalog and @path resolution.

Example

No code snippet is provided due to the lack of specific implementation details in the issue.

Notes

The issue seems to be related to the way Claude Code handles files in a git worktree. The provided information is not sufficient to give a complete solution, but the above guidance should help in resolving the issue. The problem might be specific to the darwin platform and iTerm.app terminal.

Recommendation

Apply a workaround by modifying the skill discovery and @path resolution logic to account for files introduced in a git worktree, as this seems to be the root cause of the issue. This will allow skill authors to test and iterate on their skills without having to merge them to the main branch first.

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

claude-code - 💡(How to fix) Fix [Bug] Skill discovery and @path resolution fail in git worktrees with new files