How to Ignore Files During Validation with no-mistakes: A Complete Guide
To ignore files during validation with no-mistakes, add glob patterns to the ignore_patterns field in .no-mistakes.yaml or rely on your existing .gitignore file, which the tool checks automatically via git check-ignore.
The no-mistakes repository provides a validation pipeline that runs tests, linting, documentation, and code reviews exclusively on changed files. When you need to exclude auto-generated code, vendor directories, or configuration files from these steps, you can define ignore patterns that use standard gitignore semantics.
How no-mistakes Discovers Ignore Patterns
The tool discovers exclusion rules through two distinct mechanisms. Both methods support glob-style patterns with slash anchoring and ** wildcards.
Using .gitignore Integration
The pipeline respects your existing .gitignore file automatically. In internal/pipeline/steps/test.go, the validation step executes git check-ignore --quiet -- <path> against each changed file. If the command succeeds, the file is skipped entirely.
This means any entry in your .gitignore—from *.log to build/—automatically excludes those paths from the validation diff without additional configuration.
Using .no-mistakes.yaml Configuration
For project-specific exclusions that you do not want to commit to .gitignore, use the ignore_patterns field in your .no-mistakes.yaml file. The configuration loader in internal/config/config.go reads this list into the Config.IgnorePatterns slice, which the pipeline applies globally.
Where the Filtering Logic Lives in the Source Code
The actual filtering implementation resides in internal/pipeline/steps/common_diff.go. Here, the filterDiff function iterates through changed files and calls matchIgnorePattern to test against the compiled ignore list. This logic is shared across all validation steps to ensure consistency.
For the review and document steps specifically, the code in internal/pipeline/steps/review.go and internal/pipeline/steps/document.go passes these same patterns to the prompt generator. This prevents the LLM from receiving diffs for ignored files. The document step also uses hasNonIgnoredDocumentChanges to verify whether any relevant files remain after filtering.
Practical Configuration Examples
Define Patterns in .no-mistakes.yaml
Create or edit your .no-mistakes.yaml to include an ignore_patterns list:
# .no-mistakes.yaml
ignore_patterns:
- "vendor/**" # ignore everything under vendor/
- "*.md" # ignore all markdown files
- "generated/**" # ignore generated source trees
When you run no-mistakes run, the validator will skip tests, linting, and documentation checks for any paths matching these globs.
Leverage Existing .gitignore Rules
Standard .gitignore entries work immediately:
# .gitignore
*.log
secret_config.yaml
build/
Because the tool invokes git check-ignore internally, these entries automatically exclude files from the validation diff.
Running Validation with Ignores Applied
Execute your validation command as normal:
no-mistakes run --branch feature/foo
The output summary will indicate that no findings were produced for ignored paths. Removing a pattern from either source will re-include those files on the next run.
How Ignored Files Are Excluded from LLM Prompts
During the review and documentation generation phases, the pipeline ensures that ignored files never reach the LLM. In internal/pipeline/steps/review.go, the ignore_patterns are read from the step context and injected into the review prompt construction. Similarly, internal/pipeline/steps/document.go uses the same filtering logic when building documentation prompts, ensuring that generated or vendor code does not pollute AI-generated documentation.
Summary
- Two methods exist: Use
.gitignorefor git-tracked exclusions orignore_patternsin.no-mistakes.yamlfor project-specific rules. - Git integration: The tool calls
git check-ignoreininternal/pipeline/steps/test.goto respect your existing ignore files. - Core logic: File filtering happens in
internal/pipeline/steps/common_diff.goviafilterDiffandmatchIgnorePattern. - LLM protection: The review and document steps explicitly exclude ignored files from prompts to prevent analysis of generated code.
Frequently Asked Questions
Can I use negative patterns (negation) in ignore_patterns?
Yes. Since no-mistakes uses gitignore semantics as implemented in internal/pipeline/steps/common_diff.go, you can use negation patterns like !important.log to re-include specific files after a broader ignore rule. The matchIgnorePattern function handles these according to standard glob matching rules.
Does ignoring files in .no-mistakes.yaml affect git status?
No. The ignore_patterns field in .no-mistakes.yaml only affects the no-mistakes validation pipeline. It does not modify git behavior or your working directory. The tool maintains this separation by keeping its configuration in Config.IgnorePatterns separately from git's internal ignore mechanisms.
Why are my files still being validated after I added them to .gitignore?
Ensure that the files are actually tracked by git's ignore system by running git check-ignore <path> manually. The pipeline in internal/pipeline/steps/test.go relies on this command's exit status. If git does not ignore the file (for example, if it was already committed), no-mistakes will still process it. Use ignore_patterns in .no-mistakes.yaml instead for files that must remain in git but excluded from validation.
Are ignore patterns applied to all validation steps?
Yes. The filterDiff logic in internal/pipeline/steps/common_diff.go applies to test, lint, review, and document steps. Additionally, the hasNonIgnoredDocumentChanges helper in the document step ensures that documentation generation only proceeds when non-ignored files have changed.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →