Skip to content
Reference

CLI & Python API

Every command, flag and function in one place. cz is a short alias for contextzip, and -h works on every command.

Command builder

Toggle flags to compose a command and preview its output.

Scope
Flags

Live preview

$ contextzip

✓ Detected Next.js + Node.js · high confidence

✓ Scanned 2,752 files & Packed 44 files · 185 KB → 63 KB, ↓66% smaller

✓ Saved to · .contextzip/output/codebase/codebase.zip · snapshot #14 (k3f9a2)

✓ Ready to paste

Run flags

These work on contextzip, include and exclude, placed after the verb.

FlagWhat it does
-i, --include PATHOnly include files under these paths. Naming an excluded path brings it back. Repeatable.
-e, --exclude PATTERNExtra exclusion patterns, gitignore syntax. Repeatable.
-p, --prompt TEXTLet Gemini pick the files relevant to this task.
--git-changesOnly staged, unstaged and untracked files. Needs a git repository.
-n, --dry-runShow what would be included; write nothing.
-o, --output FILEWrite the ZIP to this exact path, bypassing .contextzip/.
--no-clipboardDon't put the ZIP on the clipboard.
--no-gitignoreIgnore .gitignore and use only the built-in rules.
-v, --verboseList every included and excluded file.
--hereOnly package the folder you're in. Paths stay relative to the project root.
--versionPrint the installed version.

Commands

Where files go

.contextzip/
.contextzip/├── output/│   ├── codebase/      codebase.zip  + .report.txt   (latest only)│   ├── git-changes/   changes.zip   + report│   ├── prompt/        vibe.zip      + report│   └── watch/         debug-context.zip├── snapshots/         #1, #2, … — what you sent, kept for merging├── inbox/             drop AI-returned ZIPs here│   └── applied/       archived after apply-zip└── config.json        project config (optional)

Lives at your git root by default — see workspace location. Old outputs are cleaned up automatically.

Python API

Everything the CLI does is a plain function underneath — no Click, no Rich output, no SystemExit. Functions return objects and raise typed exceptions.

round_trip.py
from contextzip import get_files, get_git_changes, create_zip, apply_zip # Every project file that passes the rules — plain pathlib.Path objectscollection = get_files(include=["src/"], exclude=["*.log"])for path in collection.files:    print(path) # Only what changed, zipped (with a local manifest beside it)pkg = create_zip(get_git_changes(), output="/tmp/changes.zip")print(f"Packed {pkg.file_count} files -> {pkg.zip_path}") # Later: apply the ZIP an AI tool returnedresult = apply_zip()print(f"Wrote {len(result.written)} files")
FunctionReturns
get_files(path=None, *, include, exclude, use_gitignore=True, use_project_config=True)FileCollection of project files after the rules
get_git_changes(path=None, *, use_project_config=True)FileCollection of staged, unstaged and untracked files
create_zip(collection, output=None)PackageResult — zip_path, file_count, sizes, redacted, skipped_in_zip, snapshot
apply_zip(zip_path=None, *, project_dir=None, manifest=None, include_risky=False)ApplyResult — written, skipped, removed, applied_zip_path, zip_kept
detect_ecosystem(path=None)DetectionResult — the detected stacks

All exceptions inherit from ContextzipError: NotARepositoryError, GitNotFoundError, GitCommandError, NoFilesError and ZipNotFoundError. Source and docstrings are on GitHub.