Glob tool inconsistently handles tilde (~) expansion between path and pattern parameters
Resolved 💬 3 comments Opened Jan 20, 2026 by Efithor Closed Jan 24, 2026
Description
The Glob tool expands ~ to the home directory when used in the path parameter, but not when used in the pattern parameter. This inconsistency is confusing and leads to silent failures.
Environment
- Claude Code version: 2.1.12
- OS: Ubuntu Linux (6.14.0-37-generic)
Reproduction Steps
# Test 1: ~ in pattern parameter - FAILS silently
Glob(pattern="~/Documents/*.md")
→ "No files found"
# Test 2: ~ in path parameter - WORKS
Glob(pattern="*.md", path="~/Documents")
→ Returns matching files
# Test 3: Absolute path in pattern - WORKS
Glob(pattern="/home/user/Documents/*.md")
→ Returns matching files
Observed Behavior
| Parameter | ~ | Absolute path | $HOME |
|-----------|-----|---------------|---------|
| pattern | Silent fail | Works | Silent fail |
| path | Works | Works | Explicit error |
Expected Behavior
Either:
- Preferred: Expand
~consistently in bothpatternandpathparameters - Or: Don't expand
~in either, but provide a clear error message instead of silent "No files found"
Additional Context
- Standard glob libraries (e.g., Python's
glob.glob()) don't expand~since it's a shell feature - Claude Code chose to add
~expansion as a convenience inpath, which is helpful - The inconsistency between parameters is the issue, not the lack of expansion itself
- Silent failure in
patternis particularly problematic - users may think files don't exist
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗