Skip to content

Overview

contox_git_digest reads git commits from the local repository and returns structured commit data for the AI to analyze. This provides enrichment evidence — the AI can see exactly what code changed, which files were modified, and what the commit messages say, enabling more accurate and detailed session saves.

The tool uses SHA-based range tracking (not dates) for reliable incremental digests. The base SHA is read from the last session entry's sourceRef field, so each digest picks up exactly where the last one left off.

Parameters

NameTypeRequiredDefaultDescription
directorystringNoCurrent working directoryAbsolute path to the git repo root
limitnumberNo20Maximum number of commits to return
modeenumNo"first-parent""first-parent": clean shipping journal (skips merge branch commits). "all": exhaustive, including merge commits

Return value

Returns a formatted digest including:

  • Commit data — For each commit: SHA, message, author, date, files changed, diff stats (insertions/deletions), and smart patches (truncated diffs)
  • WIP evidence — Uncommitted changes in the working tree that may be relevant for enrichment
  • Range information — The base SHA (starting point) and HEAD SHA (ending point) of the digest

Usage examples

Reading recent commits before saving

User: Save this session

Claude calls: contox_git_digest()

Response:
## Git Digest (5 commits: abc1234..def5678)

### abc1234 — feat: add JWT authentication
Files: src/lib/auth.ts (+145, -0), src/middleware.ts (+32, -5)

### bcd2345 — fix: handle expired tokens gracefully
Files: src/lib/auth-client.ts (+28, -12)

...

## WIP Evidence
M src/components/login-form.tsx (unstaged)

Claude then calls: contox_save_session({
  summary: "Implemented JWT authentication with token refresh and protected routes.",
  changes: [...],
  headCommitSha: "def5678"
})

Limiting to recent commits

Claude calls: contox_git_digest({ limit: 5 })

Including all merge commits

Claude calls: contox_git_digest({ mode: "all" })

Notes

  • The first-parent mode (default) follows only the first parent of merge commits, providing a clean linear history. Use "all" mode to see every commit including those from merged branches.
  • When the AI saves a session with headCommitSha, the next contox_git_digest call will start from that SHA, providing a true incremental digest.
  • If no previous save exists (no sourceRef on the last session entry), the digest starts from the beginning of the repository history (up to the limit).
  • Smart patches are truncated diffs that show the most relevant code changes without overwhelming the context window.
  • The digest directory defaults to the current working directory. It must be a valid git repository.