This example blocks risky git operations when the working tree is dirty.
It combines two extension patterns:
- a slash command for quick inspection
- a
tool_callguard that blocksbashcommands when policy says they are unsafe
uv run agent run -e examples/extensions/commit-guard.py/dirtyShow the currentgit status --porcelainresult in a short human-readable form.
When the extension sees a bash tool call containing:
git commitgit push
it runs git status --porcelain.
If the tree is dirty, the command is blocked and the reason is returned to the main thread.
This is a compact example of an extension that mixes command registration with a runtime policy guard.