Problem
When indexing a repository, MemSearch currently scans all files under the target directory. In practice, repositories often contain directories and files that should not be indexed, such as:
node_modules/
dist/
build/
.next/
coverage/
.venv/
Generated assets
Large binary files
Project-specific cache directories
These unnecessary files increase indexing time, consume additional storage, and may reduce search quality by introducing content that users are unlikely to search.
Additionally, most developers already maintain a .gitignore file that defines which files are not part of the source code. Not respecting these ignore rules means MemSearch performs work that has already been explicitly excluded by the project.
Proposed solution
Add support for configurable exclusion rules, ideally with both automatic .gitignore support and user-defined exclusions.
Possible implementation:
--respect-gitignore
Skip files and directories ignored by .gitignore.
--exclude
Allow multiple exclude patterns from the command line.
Example:
memsearch index .
--respect-gitignore
--exclude "*.min.js"
--exclude "docs/generated"
Optional configuration file (e.g. .memsearchignore or configuration section in the existing config) for persistent project-specific exclusions.
This would give users flexibility while keeping the default behavior unchanged unless the option is enabled.
Alternatives considered
One option would be to delegate file discovery to a mature tool such as fd, which already supports:
.gitignore
.ignore
hidden file handling
efficient directory traversal
glob-based exclusions
Using fd could reduce maintenance by relying on a well-tested implementation of ignore semantics. However, introducing an external dependency may not be desirable for all platforms or installation methods, so implementing native ignore handling may be the better long-term solution.
Either approach would significantly improve indexing performance and relevance for real-world repositories.
Problem
When indexing a repository, MemSearch currently scans all files under the target directory. In practice, repositories often contain directories and files that should not be indexed, such as:
node_modules/
dist/
build/
.next/
coverage/
.venv/
Generated assets
Large binary files
Project-specific cache directories
These unnecessary files increase indexing time, consume additional storage, and may reduce search quality by introducing content that users are unlikely to search.
Additionally, most developers already maintain a .gitignore file that defines which files are not part of the source code. Not respecting these ignore rules means MemSearch performs work that has already been explicitly excluded by the project.
Proposed solution
Add support for configurable exclusion rules, ideally with both automatic .gitignore support and user-defined exclusions.
Possible implementation:
--respect-gitignore
Skip files and directories ignored by .gitignore.
--exclude
Allow multiple exclude patterns from the command line.
Example:
memsearch index .
--respect-gitignore
--exclude "*.min.js"
--exclude "docs/generated"
Optional configuration file (e.g. .memsearchignore or configuration section in the existing config) for persistent project-specific exclusions.
This would give users flexibility while keeping the default behavior unchanged unless the option is enabled.
Alternatives considered
One option would be to delegate file discovery to a mature tool such as fd, which already supports:
.gitignore
.ignore
hidden file handling
efficient directory traversal
glob-based exclusions
Using fd could reduce maintenance by relying on a well-tested implementation of ignore semantics. However, introducing an external dependency may not be desirable for all platforms or installation methods, so implementing native ignore handling may be the better long-term solution.
Either approach would significantly improve indexing performance and relevance for real-world repositories.