Skip to main content

Git Module

Fast native git operations via pygit2 (libgit2 C bindings) with async subprocess fallback. Includes a 500ms TTL cache for repeated read-only calls.

Performance

Operationpygit2subprocessMCP ServerCache hit
status3.5ms4ms~300ms0.013ms
log (5)0.4ms15ms~150ms0.013ms
branches0.3ms10ms~100ms0.013ms
diff-7ms~200ms0.013ms

The module is 60-150x faster than MCP git servers for read operations, and cached reads are ~25,000x faster.

Configuration

modules:
git:
config:
workspace: "{{execution.workspace}}" # git repo directory
default_remote: origin # default remote for push/pull
github_token: "{{env.GITHUB_TOKEN}}" # for PR creation (optional)
sign_commits: false # GPG signing

Actions (17)

Read-only (risk: low)

ActionDescriptionParameters
statusBranch, staged, unstaged, untracked files-
diffChanges between working tree, index, or refstarget? (staged/unstaged/ref), file?
logCommit historylimit (default 20), branch?, file?, oneline
blameWho modified each linefile, start_line?, end_line?
showCommit detailsref (default HEAD), stat_only
branch_listLocal and remote branchesall (include remote)

Write (risk: medium)

ActionDescriptionParameters
addStage filesfiles (list)
commitCreate commitmessage, amend
branch_createCreate branchname, start_point?, checkout
checkoutSwitch branch/reftarget
stashSave/restore changesaction (push/pop/list/drop), message?
tagCreate/list/delete tagsaction, name?, message?, ref?
pullPull from remoteremote?, branch?, rebase

Dangerous (risk: high)

ActionDescriptionParameters
pushPush to remoteremote?, branch?, force, set_upstream
resetReset branch statemode (soft/mixed/hard), ref
mergeMerge branchbranch, no_ff

GitHub (risk: medium)

ActionDescriptionParameters
pr_createCreate pull requesttitle, body, base?, draft

Requires the gh CLI tool installed. Uses GITHUB_TOKEN from config for authentication.

Caching

Read-only operations are cached for 500ms. Any write operation invalidates the entire cache. This means:

  • Sequential status + diff + log calls within 500ms hit the cache after the first call
  • After commit or add, all cached data is invalidated immediately
  • Cache is per-module-instance (no cross-agent pollution)

Examples

# A coding assistant with git access
modules:
git:
config:
workspace: "{{workspace}}"
filesystem:
config:
checkpoint: true

agents:
- id: coder
brain:
provider: deepseek
model: deepseek-chat
system_prompt: |
You are a coding assistant with git access.
Always check git status before and after making changes.

Implementation Details

  • pygit2 is used for status, log, branch_list (C library calls, no process spawn)
  • async subprocess is used for diff, blame, show, and all write operations
  • All subprocess calls use asyncio.create_subprocess_exec (non-blocking)
  • Output is parsed from --porcelain format where available (machine-readable, faster)