SwiftCommitGen is a Swift-based command line tool that inspects your current Git repository, summarizes the staged and unstaged changes, and generates a commit message proposal with Apple's on-device generative model. The goal is to keep human-in-the-loop Git commits fast, consistent, and privacy-preserving by relying on system-provided AI capabilities instead of cloud services.
CommitGen.mov
- Detects dirty Git worktrees and extracts concise change context
- Crafts commit message drafts with Apple's onboard generative APIs
- Provides an interactive acceptance/edit flow before writing the commit
- Persists CLI defaults with an interactive
config
command - Respects local-only privacy requirements (no network calls)
The CLI currently supports end-to-end commit generation, including Git inspection, AI-assisted drafting, interactive editing, optional auto-staging/committing, and persistent configuration defaults. Advanced batching for huge diffs is available and continues to evolve based on real-world feedback.
- macOS 26 (Sequoia) or later with the Apple Intelligence feature set enabled
- Xcode 26 (or newer) with the command line tools installed (
xcode-select --install
) - Swift 6 toolchain (ships with Xcode 26)
- Git 2.40+ available on
PATH
- Full Disk Access enabled for the Terminal (or your preferred shell) so the FoundationModels framework can initialize properly
brew tap Iron-Ham/swift-commit-gen
brew install swiftcommitgen
Or install directly without tapping:
brew install Iron-Ham/swift-commit-gen/swiftcommitgen
- Clone the repository:
git clone https://github.com/Iron-Ham/swift-commit-gen.git cd swift-commit-gen
- Run the bundled install script (installs into
~/.local/bin
by default):Pass a custom destination as the first argument to install elsewhere, e.g.Scripts/install.sh
Scripts/install.sh /usr/local/bin
.
If you prefer manual installation, build and copy the binary yourself:
git clone https://github.com/Iron-Ham/swift-commit-gen.git
cd swift-commit-gen
swift build -c release
install -d "$HOME/.local/bin"
install .build/release/swiftcommitgen "$HOME/.local/bin/"
Add export PATH="$HOME/.local/bin:$PATH"
to your shell profile if needed.
- The first invocation may prompt for Apple Intelligence access; approve the request in System Settings → Privacy & Security → Apple Intelligence.
- If
swiftcommitgen
reports that the model is unavailable, ensure Apple Intelligence is enabled and the device satisfies the on-device requirements.
From the root of a Git repository with pending changes:
swift run swiftcommitgen generate
Or, after installation:
swiftcommitgen generate
You can invoke the tool either with the explicit generate
subcommand or omit it because generate
is the default subcommand.
Primary (shorter) form:
swiftcommitgen [OPTIONS]
Equivalent explicit form:
swiftcommitgen generate [OPTIONS]
- Inspect repository (staged changes only)
- Summarize diff and plan prompt batches if large
- Request draft commit message from on-device model
- Interactive review loop (accept / edit / regenerate)
- Optional auto-commit
Flag | Short | Description | Default | Notes |
---|---|---|---|---|
--format <text|json> |
Output format for the draft | text |
JSON skips the interactive review loop. | |
--commit / --no-commit |
Apply the accepted draft with git commit |
On | --no-commit leaves the draft uncommitted. |
|
--stage |
Stage all pending changes (including untracked) before drafting | Off | Equivalent to git add --all before generation. |
|
--no-stage |
Disable staging, even if configured as a default | - | Wins over stored auto-stage preferences. | |
--verbose |
-v |
Emit detailed prompt diagnostics and debug lines | Off | Shows [DEBUG] messages. Overrides --quiet . |
--no-verbose |
Force verbose output off, even if configured as default | - | Useful for scripts overriding stored settings. | |
--quiet |
-q |
Suppress routine info lines | Off | Hides [INFO] but keeps [NOTICE] , warnings, errors. Ignored if --verbose is present. |
--no-quiet |
Ensure quiet mode is disabled, even if configured | - | Helpful when scripts need full output. |
The logger uses distinct levels to balance clarity and noise:
[ERROR]
: Fatal issues preventing progress[WARNING]
: Non-fatal problems or user action advisories[NOTICE]
: Essential workflow milestones (always shown, even with--quiet
)[INFO]
: Routine progress details (hidden with--quiet
)[DEBUG]
: High-volume diagnostics (only with--verbose
)
Precedence: --verbose
> --quiet
. Supplying both yields verbose output.
Generate and interactively accept a draft (default):
swiftcommitgen
Auto-commit the already staged changes:
swiftcommitgen --commit
Stage everything first, then show verbose diagnostics:
swiftcommitgen --stage --verbose
Minimal essential output (quiet mode) but still commit:
swiftcommitgen --quiet --commit
Produce machine-readable JSON (no interactive loop):
swiftcommitgen --format json
Use the config
subcommand to inspect or update stored defaults. Running it with no flags opens an interactive, colorized editor that walks through each preference:
swiftcommitgen config
Available options:
Flag | Description |
---|---|
--show |
Print the current configuration without making changes. |
--auto-stage-if-clean <true|false> |
Persist whether generate should stage all files when nothing is staged. |
--clear-auto-stage |
Remove the stored auto-stage preference. |
--verbose <true|false> |
Set the default verbose logging preference. |
--clear-verbose |
Remove the stored verbose preference. |
--quiet <true|false> |
Set the default quiet logging preference. |
--clear-quiet |
Remove the stored quiet preference. |
When no options are provided, the command detects whether the terminal is interactive and presents guided prompts with recommended defaults highlighted. Stored settings live in ~/Library/Application Support/swiftcommitgen/config.json
(or the XDG config directory on non-macOS platforms).
For a full list of commands:
swiftcommitgen help # or swiftcommitgen -h
For help with a specific command, such as generate
:
swiftcommitgen help generate # or swiftcommitgen generate -h