Auto-commit per turn
Every turn that touches files lands as its own attributed git commit.
When to use it
Auto-commit-per-turn is the default for a reason: it gives every charm a clean, attributed history without the human in the loop having to remember to commit. Three concrete moments where it earns its keep:
- Reviewing the agent's work.
git log --onelinereads as the session's summary; each commit's body carries the user prompt that triggered the edits. - Reverting one bad turn without losing the rest.
git revert HEADtargets just the most recent agent commit; earlier good work stays put. - Sharing progress.
git pushafter a session ships a clean history rather than a single sprawling "agent did stuff" commit.
How it works
Two hooks fire around every conversation-loop turn when
state.git_auto_commit is on (the default):
- Pre-cantrip commit. If the working tree
is dirty when the user types, Cantrip commits the dirty
state first as
chore(pre-cantrip): save in-progress work. This means your hand-edits never get squashed into the agent's commit. Untracked files participate too — the pre-commit runsgit add -A. - Agent commit. After the final assistant
message lands, Cantrip walks the turn's tool calls for
write_file/edit_file/multi_edit, stages the touched paths explicitly viagit add -- <paths>(no catch-alls), and commits with a Cantrip co-author trailer. The subject line is generated by the light provider when one is configured; without one we fall back toagent: <truncated user message>.
Commit message shape
feat(charm): add ops-tracing integration
Prompt: Add ops-tracing to src/charm.py so we can trace hook execution
in the dev model.
Touched:
- src/charm.py
- charmcraft.yaml
Co-Authored-By: Cantrip <noreply@aotearoa.dev>
Subject line is capped at 72 characters, prompt is capped at ~280 characters, the touched-file list truncates after 20 entries with a "and N more" hint.
Disabling auto-commit
Three ways:
- One session:
cantrip run --no-auto-commit . - Mid-session:
/auto-commit off - Re-enable mid-session:
/auto-commit on
When auto-commit is off, agent edits stay in the working tree until you commit them yourself. The pre-cantrip dirty-commit also skips, so a turn that starts with a dirty tree just runs the agent against that state.
Interaction with /undo
/undo
restores the working tree from the snapshot taken just before
the user turn. Because snapshots and the user's repo are
independent, the auto-commit's contents are still in
git log after /undo — HEAD points
at the agent commit but the working tree no longer matches it.
To reconcile, run one of:
git reset --soft HEAD~1— drop just the Cantrip commit from history; the working tree (already restored from the snapshot) becomes the new tip.git revert --no-commit HEAD— preserve the commit in history but stage its inverse, ready for you to commit as a "revert agent change" entry.
What auto-commit is not
- Not a push. Cantrip never runs
git push; the user pushes when they're ready. - Not a snapshot replacement.
/undosnapshots still fire — the snapshot system runs in a hidden parallel git repo independent of your charm's repo. - Not a remote-history rewriter. Auto-commit creates new commits on the current branch; it never amends, force-pushes, or rewrites published history.
- Not a GPG signer. The commits run with
--no-gpg-signso an unattended session never blocks on a passphrase prompt. SetCANTRIP_GPG_SIGN=1to re-enable signing.