git-autocommit

command module
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 4 Imported by: 0

README

git-autocommit

git-autocommit uses an explicitly selected AI provider to turn local changes into reviewable Git commits. Put the git-ac binary on PATH, choose a provider with --provider or trusted configuration, and run git ac. It invokes your installed Git, honors hooks/signing, never pushes or changes branches, and refuses conflicts or an in-progress merge, rebase, cherry-pick, or revert.

Install

go install github.com/markosnarinian/git-autocommit@latest
ln -sf "$(go env GOPATH)/bin/git-autocommit" "$(go env GOPATH)/bin/git-ac"
# or download a Linux, macOS, or Windows archive from GitHub Releases

Release archives include amd64 and arm64 binaries and checksums. Building from source is also supported with go build -o git-ac ..

Usage

git ac --provider amp          # split mode (default)
git ac --provider openai --one # one final add -A snapshot
git ac --provider amp --staged # cached changes only
git ac --provider amp --dry-run
git ac --provider amp --yes --style conventional
git ac --provider anthropic --model claude-sonnet-4-5
git ac --provider amp --prompt 'Mention the issue number'
git ac --provider amp --timings

--split, --one, and --staged are mutually exclusive; an explicit --split overrides a configured mode. Other flags are --config, --provider, --model, --style, --prompt, --dry-run, --timings, --yes, --version, and --help.

No AI provider is selected by default. Select one for each run, set GIT_AUTOCOMMIT_PROVIDER, or persist provider in trusted user or Git-local configuration. The command never infers a provider from API keys, installed CLIs, --model, or the number of configured profiles. Once a provider is configured, the shorter examples such as git ac --one work as expected.

  • Split sends the complete snapshot in one AI request. The model returns an ordered partition of compact change IDs mapped locally to exact base/worktree line ranges; the result is fully validated and preflighted through virtual trees before the first commit. An existing staged snapshot remains a fixed first commit; binary files, renames, symlinks, and mode changes are selected as whole files.
  • One plans in a temporary index, confirms, stages the final snapshot, verifies it still matches the plan, and creates one commit.
  • Staged only writes a message and commits the existing index. It never stages or unstages working-tree changes.
  • Dry run uses temporary indexes and virtual trees to print every proposed commit without changing HEAD, the real index, or the worktree.

Split and one-shot mode only return success after all staged, unstaged, and non-ignored untracked changes have been committed. Split mode re-plans in a bounded number of drain cycles if hooks or concurrent tools create more changes during the run. --staged is the deliberate exception: it leaves unstaged and untracked work alone. Policies such as untracked = "skip" cause a nonzero result while skipped changes remain unless allow_remaining = true is explicitly configured.

Confirmation is once per planned batch by default; each and never are available, and --yes means never. Required confirmation fails on non-TTY input rather than assuming approval. --timings reports time spent in AI requests, commits, confirmation, and other work.

Interactive runs show progress spinners, colored diffs, and structured plan and completion summaries. Redirected output stays stable and contains no ANSI escapes; set NO_COLOR=1 to disable colors explicitly.

Configuration

TOML is merged in this order: defaults, ~/.config/git-autocommit/config.toml, trusted <git-dir>/autocommit.toml, checked-in .git-autocommit.toml, explicit trusted --config, environment, flags. The checked-in file may only supply styles, history settings, and a repository prompt—it cannot select endpoints, executables, providers, or bypass confirmation.

version = 1
mode = "split"
confirmation = "once" # each, once, never
timings = false
provider = "openai"
# model = "gpt-5-mini" # optional; provider default is used when omitted
style = "auto" # auto, concise, conventional, detailed
# prompt = "Keep generated files in a separate commit"

[behavior]
staged_in_split = "commit-first" # commit-first, error, flatten
empty_changes = "success"        # success, error
untracked = "include"            # include, skip, error
binary = "whole-file"            # whole-file, error
renames = "whole-file"           # whole-file, error
large_diff = "error"
max_commits = 50
max_drain_cycles = 3
invalid_response_retries = 2
max_diff_bytes = 1048576
allow_remaining = false

[history]
enabled = true
limit = 5
ignore_merges = true
ignore_reverts = true

[providers.local]
kind = "openai-compatible"
protocol = "chat-completions" # default for openai-compatible; responses is also supported
endpoint = "http://localhost:11434/v1/chat/completions"
# api_key_env = "LOCAL_API_KEY" # omit for an unauthenticated local endpoint
default_model = "model-name"

[styles.team]
base = "conventional"
instructions = """
Use imperative subjects and include ticket IDs when visible.
"""
[[styles.team.examples]]
changes = "Add retry timeout"
message = "feat(network): add bounded retries"

Environment overrides: GIT_AUTOCOMMIT_MODE, GIT_AUTOCOMMIT_CONFIRMATION, GIT_AUTOCOMMIT_PROVIDER, GIT_AUTOCOMMIT_MODEL, GIT_AUTOCOMMIT_STYLE, GIT_AUTOCOMMIT_PROMPT, GIT_AUTOCOMMIT_DRY_RUN, and GIT_AUTOCOMMIT_TIMINGS.

The auto style follows recent non-merge commits and falls back to concise. concise uses a short imperative subject, conventional uses type(scope): subject, and detailed allows an explanatory body. Custom styles can inherit a built-in and add instructions and any number of changes/message few-shot examples.

Providers

The built-in profiles below are available as explicit choices; none is the default.

  • OpenAI: select openai and set OPENAI_API_KEY; uses the Responses API and defaults to gpt-5-mini unless configured otherwise. OpenAI API billing is separate from a ChatGPT subscription.
  • Anthropic: select anthropic and set ANTHROPIC_API_KEY.
  • OpenAI-compatible: define a trusted profile with kind, endpoint, optional protocol, and optional API-key environment variable. There is intentionally no endpoint CLI flag.
  • Amp CLI: select amp. It defaults to a minimal, tool-free completion agent using the fast zhipuai/glm-5.2 model; this avoids loading Amp's full coding-agent prompt. --model accepts another public plugin model ID or a built-in Amp mode (low, medium, high, ultra). The built-in modes are substantially slower because they load the complete coding-agent runtime. Runs are private and isolated, and a persistent streaming process is reused for schema-correction retries. To use eligible ChatGPT access instead, first run amp config model-providers add-chatgpt-subscription, then select an allowed OpenAI model such as --model openai/gpt-5.4.
  • Codex CLI (experimental): select codex; it runs ephemeral and read-only in an empty directory and reuses authentication managed by the official Codex CLI. This is the direct option for an eligible ChatGPT/Codex subscription; git-autocommit never reads Codex auth files itself.

API keys are read only from the configured environment variable and are never persisted.

Security and privacy

Diffs and recent commit messages are sent to the selected provider. Review provider retention policies and do not use this tool on secrets. Diff content is treated as untrusted; the model receives no tools and may only return commit messages and validated selections—not code or commands. Binary patch payloads are omitted from model input. Repository and index snapshots are compared again after planning, and the complete batch is preflighted before any commit. Hooks can still reject or modify a commit according to normal Git behavior; newly created changes are detected and drained rather than silently left behind.

MIT © 2026 Markos Narinian.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
ai
app
git

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL