Skip to main content

Parse and match .llmignore files — the .gitignore for AI. Supports .cursorignore, .aiignore, .aiexclude, .claudeignore, .codeiumignore, .geminiignore, .aiderignore, .clineignore, .rooignore, .augmentignore, .copilotignore, .repomixignore.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llmignore-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llmignore-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file llmignore-0.1.0.tar.gz.

File metadata

  • Download URL: llmignore-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for llmignore-0.1.0.tar.gz
Algorithm Hash digest
SHA256 95a77ab1527a1d0f44a351a6478cb90e2423faa6c9012cdc71269ef2e03e0851
MD5 4d22415031f2b6c310c1731e67d18937
BLAKE2b-256 164b9fc90ee08a1d3653b96d33c01f63d11b934ca4a00891de0c70d7dceb67e5

See more details on using hashes here.

File details

Details for the file llmignore-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: llmignore-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for llmignore-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94e8e35f899a1cf4ab29dd287e324b16b64ee3c12f12cd5ce30c6e2f3ed06ff6
MD5 46871c94f91031eb0c5c58c48eeefb80
BLAKE2b-256 b7b8da188c65677ed69635ea289dcd3faaaa8512478a94ccc9913605e7a1a79a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page