llmignore
Parse and match .llmignore files — the .gitignore for AI.
Prevent AI coding tools from ingesting secrets, credentials, large binaries, and sensitive data into LLM context windows. Works with all 13 known AI ignore formats.
Spec: rival.tips/llmignore
Installation
Add to your Cargo.toml:
[]
= "0.1"
Usage
Parse and match
use ;
let content = r#"
# Secrets
.env
.env.*
**/*.pem
**/*.key
# Large binaries
**/*.wasm
**/node_modules/**
# But keep the example
!.env.example
"#;
let patterns = parse;
assert!; // ignored
assert!; // ignored
assert!; // negation re-includes it
assert!; // ignored
assert!; // not matched
Debug which patterns match
use ;
let content = ".env.*\n!.env.example";
let patterns = parse;
let matching = match_all;
for pat in &matching
// Output:
// line 1: .env.*
// line 2: !.env.example
Read from file
use ;
use fs;
if let Ok = read_to_string
Explore supported formats
use FORMATS;
for fmt in FORMATS
Supported Formats
| File | Tool | Official | Negation | Cascading |
|---|---|---|---|---|
.llmignore |
Universal | Yes | Yes | Yes |
.cursorignore |
Cursor | Yes | Yes | No |
.aiignore |
JetBrains | Yes | Yes | No |
.aiexclude |
Google Gemini | Yes | No | Yes |
.claudeignore |
Claude Code | No | Yes | Yes |
.codeiumignore |
Windsurf | Yes | Yes | No |
.geminiignore |
Gemini CLI | Yes | Yes | No |
.aiderignore |
Aider | Yes | Yes | No |
.clineignore |
Cline | Yes | Yes | No |
.rooignore |
Roo Code | Yes | Yes | No |
.augmentignore |
Augment | Yes | Yes | No |
.copilotignore |
GitHub Copilot | No | No | No |
.repomixignore |
Repomix | Yes | Yes | No |
Glob Syntax
The syntax is identical to .gitignore:
| Pattern | Matches |
|---|---|
*.log |
Any .log file at any depth |
**/*.pem |
Any .pem file in any subdirectory |
**/node_modules/** |
Everything inside any node_modules directory |
build/ |
The build directory and all its contents |
!important.log |
Re-includes important.log even if *.log excludes it |
src/secrets/** |
Everything inside src/secrets/ (anchored) |
??.txt |
Any two-character .txt filename |
[abc].txt |
a.txt, b.txt, or c.txt |
API Reference
parse(content: &str) -> Vec<Pattern>
Parse ignore file content into a list of Pattern structs. Handles comments, blank lines, negation, and escaped characters.
matches(patterns: &[Pattern], path: &str) -> bool
Check whether a path should be ignored. Evaluates patterns in order with last-match-wins semantics. Negation patterns (!) re-include previously excluded files.
match_all(patterns: &[Pattern], path: &str) -> Vec<&Pattern>
Return all patterns that match a path (both inclusions and negations). Useful for debugging ignore rules.
FORMATS: &[Format]
All 13 known AI ignore file format definitions with metadata about tool support, negation, and cascading behavior.
Pattern
Format
Zero Dependencies
This crate uses only the Rust standard library. No external crates required.
Links
License
MIT