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:

  1. Preferred: Expand ~ consistently in both pattern and path parameters
  2. 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 in path, which is helpful
  • The inconsistency between parameters is the issue, not the lack of expansion itself
  • Silent failure in pattern is particularly problematic - users may think files don't exist

View original on GitHub ↗

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