Skip to main content

Ignoring Files

TeaRAGs gives you fine-grained control over which files enter the search index. This page explains every ignore mechanism, how they stack, and what happens when ignore rules change between reindexes.

How Ignore Rules Stack​

TeaRAGs loads ignore patterns from multiple sources in order. A match excludes the file. A later ! pattern can include it again.

Loading order​

#SourceSyntaxPurpose
1Built-in defaultsgitignoreAlways first. Includes vendor/, node_modules/, build output (below)
2Git global excludesgitignorecore.excludesfile, or ~/.config/git/ignore when that is unset
3$GIT_DIR/info/excludegitignoreRepo-local excludes that are not the committed .gitignore
4.gitignoregitignoreRespect your existing VCS exclusions
5.dockerignoregitignoreSkip Docker build artifacts
6.npmignoregitignoreSkip npm publish exclusions
7.contextignoregitignoreTeaRAGs-specific project exclusions
8.contextignore.localgitignoreLocal overrides (add the file to .gitignore)
9ignorePatterns paramglob[]Per-call overrides passed to index_codebase

All of these use gitignore syntax. A later source can put a path back with a ! negation. The project ignore files are read from the repository root. The global excludes file and info/exclude are not: a linked worktree's info/exclude is the one in the common git directory.

Ignore Sources in Detail​

.gitignore (automatic)​

Your existing .gitignore is loaded automatically. No configuration needed. If Git ignores a file, TeaRAGs ignores it too.

Git global excludes and info/exclude​

TeaRAGs also reads the exclude files Git applies outside the committed .gitignore:

  • the global excludes file (git config --global --get core.excludesfile, otherwise ~/.config/git/ignore, or $XDG_CONFIG_HOME/git/ignore)
  • $GIT_DIR/info/exclude

They are loaded after the built-in defaults and before the project ignore files. A directory that only appears in one of those files — for example a local worktree checkout — is skipped the same way Git skips it.

vendor/ is a built-in directory pattern (Go modules, Ruby gems, and any other third-party tree of that name). The walker does not descend into it. Re-include a path with ! in a later ignore file when that name is project source.

.contextignore (project-level)​

Create a .contextignore file in your project root for search-index-specific exclusions. Useful when you want files tracked by Git but excluded from semantic search.

# Test files add noise to code search results
**/test/**
**/*.test.ts
**/*.spec.ts

# Generated code — semantically meaningless
*.generated.ts
**/generated/**
**/proto/gen/**

# Fixtures and mocks
**/fixtures/**
**/mocks/**
**/__tests__/**

# Large data files
**/migrations/**
**/seeds/**
tip

.contextignore is the recommended way to customize which files TeaRAGs indexes. It lives in source control and applies to everyone on the team.

.contextignore.local (personal overrides)​

Same syntax as .contextignore, but for personal preferences. Add .contextignore.local to your .gitignore so it stays local:

# .contextignore.local — not committed
# I'm working on auth, exclude everything else to speed up reindexing
src/billing/**
src/notifications/**
src/analytics/**

Built-in defaults​

These patterns are always applied regardless of your configuration:

PatternWhat it excludes
node_modules/**Node.js dependencies
vendor/**Vendored third-party trees (Go modules, Ruby gems)
dist/**, build/**, out/**, target/**Build outputs
coverage/**, .nyc_output/**Test coverage
.git/**, .svn/**, .hg/**Version control internals
.vscode/**, .idea/**IDE configuration
__pycache__/**, .cache/**Runtime caches
*.min.js, *.min.css, *.bundle.jsMinified/bundled assets
*.map, *.logSource maps and logs
.env, .env.*Environment secrets

Some directories are recognised by what they contain rather than by their name, so no pattern can catch them:

Directory holdingWhat it excludes
wpt, lint.ignore, resources/testharness.jsA vendored upstream web-platform-tests suite
.cargo-checksum.json (declared by Rust)A crate vendored by cargo vendor

Languages declare their own build output too: Rust contributes Cargo's target/. A vendor/ directory is ignored as a third-party tree (Go modules, Ruby gems). Re-include it with a later ! pattern when that name is project source. The project root is never excluded by a marker, and a !pattern negation does not re-include a marked directory.

ignorePatterns parameter​

Pass patterns directly to index_codebase for per-call overrides:

{
"path": "/project",
"ignorePatterns": ["**/*.generated.ts", "**/vendor/**", "**/third_party/**"]
}

Useful in CI/CD or when testing different ignore configurations without editing the .contextignore file.

Dynamic Ignore Tracking​

TeaRAGs detects when ignore rules change between reindexes and updates the index accordingly. No manual intervention needed.

How it works​

When you run /tea-rags:index (or call index_codebase directly), TeaRAGs scans files using the current ignore rules and compares with the previous snapshot:

ScenarioDetectionAction
File added to ignoreFile is in snapshot but not in current scanChunks removed from index
File removed from ignoreFile is in current scan but not in snapshotFile chunked and added to index
File deleted from diskFile is in snapshot but not on diskChunks removed from index
New file createdFile on disk but not in snapshotFile chunked and added to index

TeaRAGs distinguishes between files that were truly deleted and files that were newly ignored (still on disk but excluded by updated patterns). Both are reported in the reindex stats:

Incremental re-index complete:
- Files added: 3
- Files modified: 1
- Files deleted: 0
- Files newly ignored: 5
- Files newly unignored: 2
- Chunks added: 12
- Duration: 1.2s

Common workflows​

Adding test files to ignore after initial index:

  1. Index the codebase (test files included)
  2. Add **/*.test.ts to .contextignore
  3. Run reindex — test file chunks are automatically removed
/tea-rags:index [path]

Removing an overly broad pattern:

  1. .contextignore has **/utils/** — too aggressive
  2. Remove or narrow the pattern
  3. Run reindex — previously excluded utils are now indexed

Switching .contextignore between branches:

If branches have different .contextignore files, reindexing after a branch switch will automatically add/remove the right files.

File Extension Filtering​

Beyond ignore patterns, TeaRAGs only indexes files with recognized source-code extensions. Files with unknown extensions are silently skipped.

To add non-standard extensions, pass them to index_codebase:

{
"path": "/project",
"extensions": [".proto", ".graphql", ".prisma", ".hcl"]
}

This is additive — built-in extensions are always included.

Best Practices​

1. Start permissive, then narrow​

Index everything first, evaluate search quality, then add exclusions for noisy results. It's easier to exclude than to discover what you missed.

2. Use .contextignore for team-wide rules​

Commit .contextignore to source control. The whole team gets consistent search results.

3. Use .contextignore.local for personal scope​

Working on a specific feature? Exclude unrelated directories in .contextignore.local to speed up reindexing. Don't commit it.

4. Exclude generated code​

Generated files (protobuf, GraphQL codegen, ORM models) add noise without semantic value. Always exclude them:

# .contextignore
**/generated/**
**/*.generated.*
**/proto/gen/**

5. Don't over-exclude​

Excluding test files improves precision for "how does X work?" queries but loses coverage for "how is X tested?" queries. Consider your use case before excluding entire directories.

6. Rely on incremental reindex​

After changing ignore patterns, a simple reindex picks up the changes automatically. No need for a full reindex.

/tea-rags:index [path]

Troubleshooting​

File I expect is not indexed​

  1. Check if it matches any pattern in .gitignore, .contextignore, or the ignorePatterns parameter
  2. Verify the file extension is supported or added via the extensions parameter
  3. Run index status to confirm the index is up to date

Show me stats for the current index

Run a reindex to apply the updated ignore rules:

/tea-rags:index [path]

The reindex will remove chunks for newly ignored files.

Too many files indexed, slow queries​

Add aggressive exclusions to .contextignore:

**/vendor/**
**/third_party/**
**/migrations/**
**/*.min.js
**/*.bundle.js

Every excluded file reduces index size and improves query speed.

See Also​

  • Skills — /tea-rags:index picks up ignore-rule changes automatically on next call
  • Indexing Repositories — full indexing workflow and configuration
  • MCP Tools Atlas — index_codebase parameters (extensions, ignorePatterns)
  • Filters — narrow search results by metadata after indexing (different from ignoring at index time)