/igittigitt:python-gitignorefrom igittigitt
Provides git-compatible .gitignore parsing and file filtering via the igittigitt library/CLI. Use for checking if paths are ignored, filtering files in copytree, or whitelisting with IncludeParser.
Ships in igittigitt. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The
igittigittrepo is itself a Claude Code plugin/marketplace. Install this skill in any project with/plugin marketplace add bitranox/igittigittthen/plugin install igittigitt. It is also mirrored in the central bitranox marketplace (https://github.com/bitranox/bitranox-skills) ascoding-python-gitignore.
igittigitt is a spec-compliant .gitignore parser for Python - a library and a CLI.
Use it whenever you need to know "would git ignore this path?" or to filter / whitelist a
large set of files using .gitignore-style patterns.
Reach for igittigitt instead of writing your own matcher. Getting .gitignore semantics
right is deceptively hard - negations (!pattern), the rule that a file under an excluded
directory cannot be re-included, per-directory precedence, anchoring, **, trailing-slash
directory-only patterns, character classes. A quick fnmatch/glob/re solution will be
subtly wrong on real repositories.
One example: git reads a path segment made only of three or more asterisks as **. So
***/build matches build, x/build and x/y/build (but not xbuild), exactly like
**/build, and a/****/b and logs/*** behave like a/**/b and logs/**. A run inside
a longer segment is not a globstar: a***b behaves like a*b and never crosses a /.
| Need | Use | Avoid |
|---|---|---|
| Is this path ignored (git-exact)? | igittigitt.IgnoreParser | hand-rolled fnmatch/glob/re; gitignore_parser (incomplete negation/precedence) |
| Copy a tree minus ignored files | IgnoreParser.shutil_ignore as copytree(ignore=...) | manual os.walk + skip lists |
| Keep only matching files (whitelist) | igittigitt.IncludeParser (directory-aware) | inverting a matcher by hand (breaks on parent dirs) |
Filter a huge find stream | igittigitt filter (CLI, streaming) | loading all paths into memory |
pathspec (1.x) matches one .gitignore about 5x faster than igittigitt, with flat memory when
fed a stream, once its optional re2 (google-re2) or hyperscan package is installed: it then
picks that backend by default, or you name one with
GitIgnoreSpec.from_lines(lines, backend="re2"). google-re2 has wheels for CPython 3.10 to
3.14 and hyperscan for 3.10 to 3.15, so on 3.15 only hyperscan installs without a compiler.
With neither installed it falls back to a pure-Python backend about 12x slower than igittigitt.
Both figures come from streaming 105k and 422k paths through one 810-line .gitignore on Python
3.13, where every backend ignored exactly what igittigitt ignored; pathspec still differs from
git in edge cases: after build/ and
!build/keep.txt git keeps build/keep.txt ignored (a file under an excluded directory cannot
be re-included) while pathspec re-includes it, and x/***/y matches only x/a/y in pathspec but
also x/y and x/a/b/y in git. It keeps only the files that match (match_files), or drops
them with negate=True, but it reads no .gitignore files
itself, so nested per-directory files are yours to assemble, and it has no directory-aware
include mode. So for one .gitignore over a stream of files, pathspec with re2 or hyperscan
is the faster choice; use igittigitt when results must match git exactly, when nested .gitignore
files must be found and applied, when the include mode must keep parent directories, or for the
igittigitt filter CLI.
Why igittigitt specifically: it is validated against real git check-ignore (differential
tests), it is memory-bounded (memory scales with the number of rules, not the number of
files), and it has an include/whitelist mode plus a script-friendly CLI. It is pure Python with
no runtime dependency on the git binary.
Large rule sets stay cheap. These patterns are decided by the path's last segment through a dictionary lookup:
* followed by literal text (a *suffix), with no slash except a trailing
one (*.pyc, *.tar.gz, node_modules, build/);**/, or after a fixed path of one or more directories and **/ (**/foo,
a/**/*.log, a/b/**/*.log, and doc/**, which means doc/**/*);!keep.txt).A combined template of hundreds of such rules costs each path about what a handful does. Every
other pattern is still tried one by one, for example /build, src/*.py, **/build/*.log and
*.py[co]: those are the rules whose count adds work per path.
# as a project dependency (preferred)
uv add igittigitt
# as a standalone CLI tool on PATH
uv tool install igittigitt
# run the CLI once without installing
uvx igittigitt --help
# or pip / pipx
pip install igittigitt
pipx install igittigitt
Requires Python 3.10+.
import igittigitt
parser = igittigitt.IgnoreParser()
# discover and parse every .gitignore under base_dir (correct per-directory precedence)
parser.parse_rule_files(base_dir="/path/to/project")
# or add rules explicitly (last matching rule wins, exactly like git)
parser.add_rule("*.py[cod]", base_path="/path/to/project")
parser.add_rule("!keep.pyc", base_path="/path/to/project")
parser.match("/path/to/project/main.pyc") # True -> ignored
parser.match("/path/to/project/keep.pyc") # False -> re-included by the negation
Key methods on IgnoreParser:
parse_rule_files(base_dir, filename=".gitignore", add_default_patterns=...) - recursively
find and parse ignore files.parse_rule_file(rule_file, base_dir=None) - parse one file.add_rule(pattern, base_path) - add a single rule string.match(path, *, is_dir=None) -> bool - True if the path is ignored.match_with_rule(path, *, is_dir=None) -> (bool, rule|None) - also returns the deciding
rule, a negation included; it carries pattern_original, is_negation_rule, source_file
and source_line_number (both None for an add_rule rule).shutil_ignore(base_dir, names) -> set[str] - drop-in ignore= callback for copytree.load_default_patterns(base_dir) - add git's user-level ignore file on its own.IgnoreParser(dir_cache_max=8192) - per-parser directory-decision cache size (0 disables).igittigitt.conf_igittigitt.add_default_patterns = False changes the default that
parse_rule_files uses when its caller does not pass add_default_patterns.
File or directory (is_dir). A rule ending in / (build/) matches directories
only, so match needs the path's type. Left out (is_dir=None), it decides as git does: a
directory when the path is a STRING ending in /, or a real directory on disk (lstat); anything
else is a file - a path that does not exist, and a symlink to a directory. Pass is_dir= when
you already know the type (a find -type f stream, os.scandir entries): no system call is
made, which matters on Windows, where the stat is slow. A given is_dir wins over a trailing
/ and over what is on disk.
import os
parser.match("/path/to/project/build/") # directory: the string keeps the slash
parser.match("/path/to/project/build", is_dir=True) # the same, said explicitly
parser.match("/path/to/project/build/out.o", is_dir=False) # a file, no stat
for entry in os.scandir("/path/to/project"):
parser.match(entry.path, is_dir=entry.is_dir(follow_symlinks=False))
pathlib.Path("build/") drops the trailing slash, so a Path to a directory that is not on
disk counts as a file: pass is_dir=True. Pass follow_symlinks=False from a DirEntry to keep
git's rule that a symlink to a directory is a file.
add_rule, parse_rule_file and parse_rule_files read a rule line exactly as git reads it.
Git cuts only the final run of UNESCAPED spaces; a backslash escapes the character after it, so
\ keeps a space and \\ is one literal backslash. Tabs are never cut, and nothing is cut at the
start of a line: leading spaces belong to the pattern, and only a # in the first column starts a
comment (\# matches a literal leading #), so an indented !keep.log is a pattern for that
name, not a negation. A blank line and a line ending in a backslash that escapes nothing match no
path. pattern_original and check -v show the line with its trailing spaces cut, as git does.
parse_rule_file (or parse_rule_files) rather than reading
its lines yourself: like git, both end a line only at \n, drop one \r before it, and skip
a leading UTF-8 byte order mark. parse_rule_file's base_dir defaults to the directory of
the rule file.add_rule takes ONE line without its line ending and removes nothing beyond git's own cut of
trailing spaces: never .strip() it first, but do remove the whole line ending you read along
with it (\r\n or \n) and a byte order mark on the first line, since a \r or BOM left on
the line becomes part of the pattern.# each comment says what that one rule matches on its own
base = "/path/to/project"
parser.add_rule("*.log ", base_path=base) # the rule is "*.log"
parser.add_rule(r"two \ ", base_path=base) # "two" + 2 spaces; the last 3 are cut
parser.add_rule(r"pair \\\\ ", base_path=base) # "pair", a space, 2 backslashes
parser.add_rule("tab\t", base_path=base) # "tab" + a tab, never plain "tab"
parser.add_rule(" *.log", base_path=base) # " x.log", never plain "x.log"
parser.add_rule(" # note", base_path=base) # a pattern, not a comment: matches " # note"
parser.add_rule(r"\#hash", base_path=base) # "#hash"
parser.add_rule("lone\\", base_path=base) # ends in one unpaired backslash: matches nothing
import shutil, igittigitt
parser = igittigitt.IgnoreParser()
parser.parse_rule_files(base_dir="src_tree")
shutil.copytree("src_tree", "dst_tree", ignore=parser.shutil_ignore)
Patterns describe what to keep; everything else is dropped. It is directory-aware
(rsync-like), so including a deep file keeps its parent directories - which means it works
correctly as a copytree filter. Do NOT try to build this by negating match(); a naive
inversion prunes the parent directories and never reaches the file.
import shutil, igittigitt
inc = igittigitt.IncludeParser()
inc.add_rule("*.py", base_path="src_tree") # keep python files anywhere
inc.add_rule("docs/", base_path="src_tree") # keep the whole docs/ subtree
shutil.copytree("src_tree", "dst_tree", ignore=inc.shutil_include)
inc.match("src_tree/pkg/deep.py") # True -> kept
IncludeParser also has parse_rule_file / parse_rule_files and the dir_cache_max argument,
and its match(path, *, is_dir=None) takes is_dir too: a directory is kept when anything below
it could be, so a directory that is not on disk needs is_dir=True (or a trailing /) to be
kept. Unlike ignore mode it follows a symlink to a directory, as copytree does.
# which of these paths are ignored? (mirrors `git check-ignore`)
igittigitt check -C /path/to/repo a.log src/main.py # exit 0 if any ignored, 1 if none
# show the deciding source:line:pattern (like `git check-ignore -v`), as `src:line:pattern<TAB>path`.
# As in git, -v also lists a path a negation re-includes, and that listing makes the exit 0
# (without -v the same path is not ignored: exit 1). The rule file is named relative to -C;
# with -z every field (source, line, pattern, path) is NUL-terminated
igittigitt check -C /path/to/repo -v a.log
# inline rules and explicit ignore files, reading paths from stdin
igittigitt check -r '*.tmp' -f .gitignore --stdin < paths.txt
igittigitt info # package metadata
igittigitt --version
Other commands: config (show merged config), config-deploy (write editable config files),
config-generate-examples, logdemo. Global options: --profile, --set SECTION.KEY=VALUE,
--env-file, --traceback.
filter is a Unix filter: it reads paths from stdin and prints the survivors, streaming so
it stays memory-bounded even for millions of paths, with clean SIGPIPE handling.
# drop paths ignored by ./.gitignore
find . -type f | igittigitt filter
# keep only what matches the include patterns (whitelist mode)
find . -type f | igittigitt filter --include -r '*.py'
# NUL-separated I/O for paths with spaces or newlines
find . -print0 | igittigitt filter -z | xargs -0 tar czf out.tgz
# stops cleanly when the reader closes the pipe (no traceback, exit 141)
find . -type f | igittigitt filter | head -n 20
# paths can also be arguments instead of stdin
igittigitt filter -C /path/to/repo a.log src/main.py
Shared check/filter options: -C/--base-dir, -f/--gitignore FILE (repeatable),
-r/--rule PATTERN (repeatable), --scan/--no-scan, --default-patterns, -z/--zero;
check adds -v/--verbose and --stdin, filter adds -i/--include.
--default-patterns is OFF on the CLI (the library loads git's user ignore file by default, and
so does git check-ignore): pass it when check must agree with git on this machine./ is taken as a directory, as in git; any other path
is checked on disk, and one that does not exist is a file.filter --include uses only the -r/-f rules and never scans .gitignore files: with neither
it prints nothing. --scan and --default-patterns apply to ignore mode only.Settings merge across layers, later layers winning:
bundled defaults -> app -> host -> user -> .env -> environment variables -> --set
igittigitt configigittigitt config-deploy --target user
(--target is required: app, host or user)igittigitt config-generate-examples --destination ./examples
(--destination is required)The config directories are scanned for config.d/*.toml fragments, merged in filename order.
To override a setting system-wide on Linux, drop a file into the app layer's config.d:
sudo mkdir -p /etc/xdg/igittigitt/config.d
sudoedit /etc/xdg/igittigitt/config.d/50-myperf.toml
# /etc/xdg/igittigitt/config.d/50-myperf.toml
[performance]
dir_cache_max = 32768 # larger directory cache for very deep trees
Per-user, use ~/.config/igittigitt/config.d/50-myperf.toml instead. The same value can be
set ad hoc with igittigitt --set performance.dir_cache_max=32768 ..., in a .env file as
PERFORMANCE__DIR_CACHE_MAX=32768, or as the env var
IGITTIGITT___PERFORMANCE__DIR_CACHE_MAX=32768.
[performance] knobs (speed/memory only - never change matching)Confirm the defaults below against your own install rather than this table:
igittigitt config --section performance prints all four keys as they are in effect (defaults
plus any config.d/.env/env override; add --format json for a script).
| Key | Default | Meaning |
|---|---|---|
dir_cache_max | 8192 | Per-parser directory-decision LRU capacity (0 disables). Main speed-up on trees; memory O(this), not O(#files). |
pattern_cache_max | 4096 | Process-wide compiled-regex cache capacity. |
stdin_chunk_bytes | 65536 | Stdin read granularity for the streaming commands. |
max_token_bytes | 1048576 | Per-path safety bound; a separator-less token larger than this is rejected rather than buffered unbounded. |
Logging is configured under [lib_log_rich] (console level/theme, journald/eventlog/Graylog,
queueing, scrubbing); every key is documented inline in the deployed config.d/90-logging.toml,
e.g. igittigitt --set lib_log_rich.console_level=DEBUG info.
parse_rule_files() also loads git's user-level default ignore file
($XDG_CONFIG_HOME/git/ignore or ~/.config/git/ignore) unless you pass
add_default_patterns=False or set igittigitt.conf_igittigitt.add_default_patterns = False.
The CLI does the opposite: it loads that file only with --default-patterns.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub bitranox/igittigitt --plugin igittigittOther plugins' skills for the same job