[BUG] Glob tool ignores literal path prefixes when searching in additional directories

Resolved 💬 2 comments Opened Feb 17, 2026 by rafalry Closed Mar 18, 2026

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?

The Glob tool fails to resolve literal directory path prefixes in patterns when the path parameter points to an additional directory added via --add-dir or additionalDirectories. Only patterns starting with glob wildcards (*, **) return results. The same literal-prefix patterns work correctly when searching in the primary working directory.

This also affects Claude's internal Search tool during skill discovery and general file lookups, producing Found 0 files for files that provably exist.

What Should Happen?

Glob(pattern: "apps/webapp/package.json", path: "/path/to/additional-dir") should find the file, just as it would if the same directory were the primary working directory.

Steps to Reproduce

Setup:

# Primary working directory
~/code/claude-root/          # launched claude from here

# Additional directory (via additionalDirectories in settings.local.json)
~/code/webapp/               # added via --add-dir
~/code/webapp/scripts/build.sh         # exists
~/code/webapp/apps/webapp/package.json # exists
~/code/webapp/apps/webapp/.claude/skills/writing-tests/SKILL.md  # exists

Test from additional directory (~/code/webapp):

| Pattern | Path | Result |
|---------|------|--------|
| scripts/* | ~/code/webapp | No files found |
| apps/webapp/package.json | ~/code/webapp | No files found |
| apps/webapp/.claude/skills/writing-tests/**/* | ~/code/webapp | No files found |
| libraries/**/* | ~/code/webapp | No files found |
| README.md | ~/code/webapp | Finds only deeply nested files, misses root README.md |
| **/build.sh | ~/code/webapp | Found scripts/build.sh |
| **/.claude/skills/writing-tests/**/* | ~/code/webapp | Found all 5 files |
| * | ~/code/webapp | Found files recursively |
| **/*.md | ~/code/webapp/.../writing-tests | Found all files |

Test from primary directory (~/code/claude-root) — works correctly:

| Pattern | Path | Result |
|---------|------|--------|
| scripts/* | ~/code/claude-root | Found 3 files |
| tmp/* | ~/code/claude-root | Found 15 files |

Pattern

Literal path components at the start of a pattern fail in additional directories. Patterns that begin with * or ** work because they bypass whatever path resolution is broken. The same literal-prefix patterns work fine against the primary working directory.

Observed in the wild

Claude's internal search during skill discovery:

Search(pattern: "apps/webapp/.claude/skills/writing-tests/**/*", path: "~/code/app/webapp")
  Found 0 files

Correction: The nested skill files (apps/webapp/.claude/skills/writing-tests/) are actually not loaded by the skill discovery mechanism either when webapp is an additional directory. Only root-level skills (e.g., webapp/.claude/skills/ux-writing/) are loaded from additional directories — recursive skill discovery is exclusive to the primary working directory. This means agents cannot discover these nested skills via the Glob/Search tool (due to this bug) or via the skill loader (due to the lack of recursive discovery in additional directories).

Likely root cause

The Glob tool appears to resolve literal path components in the pattern against the primary working directory rather than the specified path parameter. So scripts/* with path=/additional/dir may internally resolve to <primary-cwd>/scripts/*, which doesn't exist.

Wildcard-first patterns (**, *) work because they trigger a recursive file walk starting from the correct path directory and then filter matches.

Error Messages/Logs

Glob(pattern: "scripts/*", path: "/Users/user/code/webapp")
→ No files found

Glob(pattern: "**/build.sh", path: "/Users/user/code/webapp")
→ /Users/user/code/webapp/scripts/build.sh   (file exists, found only via ** prefix)

Related issues

  • #25143 (closed) — Same symptom for dot-directory literals, but scoped to .-prefixed dirs and tested in primary directory only
  • #17302 — dot: true not passed to glob, related but different
  • #7412 — @ mentions don't work in additional directories (possibly same underlying path resolution bug)
  • #25562 — Path-based rules only match under primary working directory (same pattern of primary-dir-only resolution)

Claude Model

claude-opus-4-6

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.44

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

zsh (ghostty)

Additional Information

The bug was discovered while investigating why skill discovery logs show Found 0 files for skills in nested subdirectories of additional directories. Further testing confirmed that nested subfolder skills are not loaded from additional directories — only root-level .claude/skills/ are discovered. Recursive skill discovery only applies to the primary working directory. This is a separate issue from the Glob bug but compounds the problem: agents can neither find these files via Glob (this bug) nor rely on the skill loader to surface them.

View original on GitHub ↗

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