Skip to main content

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

pip install llmignore

Usage

Parse and match

from llmignore import parse, match

content = """
# Secrets
.env
.env.*
**/*.pem
**/*.key

# Large binaries
**/*.wasm
**/node_modules/**

# But keep the example env
!.env.example
"""

patterns = parse(content)

match(patterns, ".env")              # True  (ignored)
match(patterns, ".env.local")        # True  (ignored)
match(patterns, ".env.example")      # False (negation re-includes it)
match(patterns, "certs/server.pem")  # True  (ignored)
match(patterns, "src/index.ts")      # False (not matched)

Debug which patterns match

from llmignore import parse, match_all

patterns = parse(open(".llmignore").read())
matching = match_all(patterns, "secrets/api-key.pem")

for p in matching:
    prefix = "!" if p.is_negation else " "
    print(f"  line {p.line_number}: {prefix}{p.pattern}")

Read from file

from pathlib import Path
from llmignore import parse, match

llmignore_path = Path(".llmignore")
if llmignore_path.exists():
    patterns = parse(llmignore_path.read_text())
    # Use patterns to filter files...

Explore supported formats

from llmignore import FORMATS

for fmt in FORMATS:
    negation = "yes" if fmt.supports_negation else "no"
    official = "official" if fmt.official else "community"
    print(f"  {fmt.filename:<20} {fmt.tool:<16} negation={negation}  ({official})")

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) -> list[Pattern]

Parse ignore file content into a list of Pattern objects. Handles comments, blank lines, negation, and escaped characters.

match(patterns: list[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: list[Pattern], path: str) -> list[Pattern]

Return all patterns that match a path (both inclusions and negations). Useful for debugging ignore rules.

FORMATS: list[Format]

All 13 known AI ignore file format definitions with metadata about tool support, negation, and cascading behavior.

Pattern

Dataclass with fields: pattern (str), is_negation (bool), line_number (int).

Format

Dataclass with fields: id, filename, tool, tool_url, description, official, supports_negation, supports_cascading, docs_url, notes.

Zero Dependencies

This library uses only the Python standard library. No external packages required.

Links

License

MIT

Metadata

Release files for llmignore 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llmignore 0.1.0
File Size Uploaded Provenance
llmignore-0.1.0.tar.gz 8.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llmignore 0.1.0
File Interpreter ABI Platform
llmignore-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.5 kB

Release files / llmignore-0.1.0.tar.gz

Download URL llmignore-0.1.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
95a77ab1527a1d0f44a351a6478cb90e2423faa6c9012cdc71269ef2e03e0851
BLAKE2b-256 checksum
How to use checksums
164b9fc90ee08a1d3653b96d33c01f63d11b934ca4a00891de0c70d7dceb67e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Release files / llmignore-0.1.0-py3-none-any.whl

Download URL llmignore-0.1.0-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94e8e35f899a1cf4ab29dd287e324b16b64ee3c12f12cd5ce30c6e2f3ed06ff6
BLAKE2b-256 checksum
How to use checksums
b7b8da188c65677ed69635ea289dcd3faaaa8512478a94ccc9913605e7a1a79a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Security for llmignore 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page