Claude Code Glob tool
The built-in tool that finds files in a repository by glob pattern, used by Claude Code to discover relevant code.
What is Claude Code Glob tool?
Claude Code Glob tool is the built-in file pattern matching tool Claude Code uses to find files in a repository. It helps the agent discover relevant code quickly by matching paths against glob patterns instead of scanning the whole tree. (docs.anthropic.com)
Understanding Claude Code Glob tool
In Claude Code, Glob is one of the core built-in tools alongside Read, Grep, and LS. Anthropic’s docs describe it as file pattern matching, which makes it useful when the model needs to narrow its search to paths like source files, tests, configs, or generated artifacts. (docs.anthropic.com)
In practice, the tool sits near the start of an agent workflow. Claude can use Glob to map the codebase, then move to Read or Grep for deeper inspection. That keeps the interaction focused, especially in larger repositories where the right file is often easier to locate by path conventions than by full-text search alone. (docs.anthropic.com)
Key aspects of Claude Code Glob tool include:
- Pattern matching: It finds files by glob syntax, which is ideal for names and path structures.
- Repository discovery: It helps Claude locate likely source, test, and config files before reading them.
- Low-friction usage: Anthropic lists Glob as a built-in tool that does not require explicit permission in the default setup.
- Workflow support: It pairs naturally with Read and Grep for multi-step code exploration.
- Scoped context: It reduces unnecessary file reads by narrowing the search space early.
Advantages of Claude Code Glob tool
- Faster codebase navigation: It can jump straight to files that match known naming patterns.
- Cleaner context: It helps avoid loading irrelevant files into the working set.
- Better agent planning: File discovery makes downstream edits and reads more targeted.
- Works well in large repos: Pattern-based lookup is especially helpful when directory structure is consistent.
- Complements other tools: It fits naturally into Claude Code’s broader toolchain for reading, editing, and searching.
Challenges in Claude Code Glob tool
- Pattern quality matters: A vague glob can return too many files or miss the right ones.
- Naming conventions vary: Repos with inconsistent paths are harder to navigate with patterns alone.
- Not a content search: Glob finds paths, not code semantics, so it often needs Grep afterward.
- Can miss hidden intent: Some important files do not follow obvious naming patterns.
- Best used in sequence: It is strongest when combined with reading and reasoning, not used in isolation.
Example of Claude Code Glob tool in action
Scenario: an engineer asks Claude Code to update every test file related to authentication in a monorepo.
Claude can start with Glob patterns like **/*auth*test*.* or /tests/ to find candidate files, then read the most relevant matches and refine the changes. If the repo uses a strong folder convention, this can cut discovery time dramatically.
In a PromptLayer workflow, that same pattern-based discovery can be logged and evaluated as part of an agent run. Teams can compare which prompts lead to the most accurate file selection, then improve the prompt or agent steps over time.
How PromptLayer helps with Claude Code Glob tool
PromptLayer helps teams track how agentic coding workflows use tools like Glob, Read, and Grep, so it is easier to inspect prompt behavior, compare runs, and improve retrieval patterns over time. That makes it simpler to see whether your agent is finding the right files before it starts editing them.
Ready to try it yourself? Sign up for PromptLayer and start managing your prompts in minutes.