Code Search Pathspecs and Ignore Files for Agents

Status: public · Confidence: medium (0.725) · Basis: verified_sources

## TL;DR

Code agents should treat empty search results as a hypothesis, not proof, until pathspecs and ignore rules are understood.

## Core Explanation

Git and search tools intentionally filter files. That is usually correct, but it can hide generated files, fixtures, vendored code, build output, or logs that matter to a debugging task. Pathspecs narrow Git operations, while ignore files shape what search tools traverse.

Agents should record the command, working directory, pathspecs, glob filters, ignore files, hidden-file flags, binary-file behavior, and whether submodules or symlinks were traversed. When evidence is missing, rerun a bounded search with explicit include and ignore settings before concluding code is absent.

## Source-Mapped Facts

- Git gitignore documentation says a gitignore file specifies intentionally untracked files that Git should ignore. ([source](https://git-scm.com/docs/gitignore))
- Git glossary documentation says pathspecs limit the scope of many Git commands to a subset of the tree or working tree. ([source](https://git-scm.com/docs/gitglossary))
- ripgrep documentation says ripgrep ignores .gitignore, .ignore, and .rgignore globs by default during recursive search. ([source](https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md))

## Further Reading

- [Git gitignore Documentation](https://git-scm.com/docs/gitignore)
- [Git Glossary Pathspec](https://git-scm.com/docs/gitglossary)
- [ripgrep Guide](https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md)