Commands Reference

June 29, 2026 · View on GitHub

Complete reference for all git-courer MCP tools and CLI subcommands.

Overview

git-courer exposes 13 MCP tools for AI assistants. Every tool returns structured JSON — no unstructured text to parse, no pager hangs, no guessing.

ToolCategoryPurpose
statusUnique / ReadComplete repository state in one call
diffUnique / ReadAST-labeled diffs with semantic tags
commitUnique / WriteLLM-powered 3-phase commit pipeline (PREVIEW → APPLY → STATUS)
pr-reviewUnique / ReadPre-PR gate: runs tests, checks conflicts and divergence
backupUnique / UtilityManage backups and undo mutations
sessionUnique / WriteManage isolated sessions (git worktrees) for parallel agents
branchReplacement / WriteBranch lifecycle and Switch (with auto-stash)
stageReplacement / WriteStage, unstage, or clean untracked files
stashReplacement / WriteSave, pop, and show stashed changes
historyReplacement / ReadCommit log, reflog, and per-line blame
rewriteReplacement / WriteAmend, revert, soft reset, and hard reset
integrateReplacement / WriteMerge, rebase, cherry-pick, and abort/continue
syncReplacement / WritePush, pull, and fetch remote changes

In addition to the MCP tools above, git-courer ships CLI subcommands that support the MCP workflow but are not themselves MCP tools: doctor, hook-check (and its session-start-hook / subagent-start-hook / pre-invocation-hook variants), and release. See CLI Subcommands at the end of this document.


Core Unique Tools

These tools represent capabilities that are either impossible or highly complex to achieve with raw CLI git commands.

status

Returns the COMPLETE repo state in a single call, combining ahead/behind count, staged/unstaged/untracked files, stashes, conflict list, and user configuration.

  • Nudge: Call this BEFORE any write operation to ensure you know the repo state.
ParameterTypeRequiredDescription
filterstringNoFile path pattern to filter results
limitnumberNoMax file entries to return (pagination)
offsetnumberNoStart index for pagination

diff

Returns AST-labeled diffs. Hunks are semantically annotated (e.g., [NEW_FUNC], [MOD_SIG ⚠BREAKING], [DEPS], [DEL]) using Tree-sitter.

  • Nudge: Call this before committing or pushing to review changes.
ParameterTypeRequiredDescription
target_pathsstringNoSpace-separated file paths to diff
stagedbooleanNoShow staged changes (--cached)
branchstringNoCompare against a branch name (symmetric diff branch...HEAD)
filterstringNoFile path pattern to filter diff output
limitnumberNoMax diff lines to return
offsetnumberNoStart line offset for pagination
include_untrackedbooleanNoInclude untracked files in the diff output

commit

Handles the multi-phase commit pipeline. In the default (LLM-enabled) mode it uses a local/remote LLM to analyze the diff and generate the commit message. When llm.enabled: false, the pipeline runs offline and the commit message is supplied manually via the message parameter.

Workflow (PREVIEW → APPLY):

  1. command="PREVIEW" + why="..." → analyze the staged diff and generate a commit plan. Fast path (<45s) returns the plan directly; slow path returns a job_id to poll via STATUS.
  2. Review the plan with the user.
  3. command="APPLY" → execute the plan. With job_id, uses git plumbing (commit-tree + update-ref) to create an atomic commit from the PREVIEW tree snapshot. Without job_id, executes the pending plan from the ConfirmStore.
  4. (Optional) command="STATUS" + job_id="..." → poll a slow PREVIEW job.

why is required for PREVIEW. Describe the why — the real problem, symptom, or limitation that motivated the change — NOT what the code does (the LLM reads the diff to derive the what).

Offline mode (llm.enabled: false): PREVIEW accepts message instead of why and infers the conventional-commit type prefix from the staged files when one is missing.

ParameterTypeRequiredDescription
commandstringYesPREVIEW, APPLY, or STATUS (poll job state)
whystringYes (PREVIEW, LLM mode)The REAL reason for this change — the problem/symptom/limitation that motivated it. Do NOT describe what the code does.
messagestringYes (PREVIEW, offline mode)Manual commit message (only when llm.enabled: false).
target_pathsstringNoSpace-separated paths to stage before preview (use . for all). PREVIEW only.
job_idstringNoJob ID for STATUS polling or plumbing-based APPLY execution
push_afterbooleanNoAuto-push commits after successful APPLY
typestringNoCommit type prefix override (e.g., feat, fix, chore). APPLY only. Valid: feat, fix, chore, docs, refactor, test, perf, style.

pr-review

A pre-PR validation gate that runs the project's test_command, detects merge conflicts with the target branch, shows diff stats, and checks branch divergence.

  • Nudge: Call this BEFORE creating a PR. No exceptions.
ParameterTypeRequiredDescription
tostringNoTarget branch to compare against (default: main)

backup

Manages automated git state backups. Every write operation automatically creates a backup.

ParameterTypeRequiredDescription
commandstringYesRESTORE (undo last mutation) or LIST (list backups)
refstringNoTarget backup reference for RESTORE. Defaults to latest

session

Manages isolated git worktrees and branches to allow agents to work in parallel on the same repository without conflicts.

  • Workflow: start (creates worktree + branch) → select (redirects all MCP tools to the session's worktree) → work → finish (removes the worktree, leaves the branch alive for manual integration).
  • finish behavior: finish runs a light preview-validation (aborts only on uncommitted/untracked changes — a data-loss guard) and then removes the worktree. The session branch is intentionally NOT deleted so you can merge it, open a PR, or discard it later. No merge is attempted by finish.
ParameterTypeRequiredDescription
commandstringYesstart, finish, status, select, discard
agentstringNoAgent name (required for start)
goalstringNoGoal description (required for start; used to name the branch)
branchstringNoCustom branch name (optional; used for start)
session_idstringNoSlug identifier (required for finish, select, discard; optional for status)
confirmedbooleanNoAuthorize destructive operations (required for discard)

Replacement Tools

These tools serve as structured replacements for standard git commands. They output clean, parseable JSON and build safety nets around mutations.

branch

Branch management tool. Switch operation automatically stashes and unstashes a dirty working tree.

ParameterTypeRequiredDescription
commandstringYesCREATE, DELETE, RENAME, SWITCH, LIST
branch_namestringNoBranch name (required for CREATE, DELETE, RENAME, SWITCH)
new_branch_namestringNoNew name (required for RENAME)
forcebooleanNoForce operation (caution: bypasses safety checks)
confirmedbooleanNoRequired for DELETE
switchbooleanNoIf true, CREATE switches to the new branch immediately
filterstringNoFilter for LIST: LOCAL, REMOTE, or ALL

stage

Stages (add), unstages (restore), or cleans untracked files.

  • Nudge: Do NOT use this for committing; use the commit tool.
ParameterTypeRequiredDescription
commandstringYesRM (remove from index), RESTORE (unstage), CLEAN (remove untracked)
target_pathsstringNoSpace-separated file paths (required for RM and RESTORE)
dry_runbooleanNoPreview files affected before executing
confirmedbooleanNoRequired for CLEAN

stash

Saves, pops, or shows stashes.

ParameterTypeRequiredDescription
commandstringYesSAVE, POP, SHOW
commit_messagestringNoStash description (used with SAVE)
stash_indexstringNoReference (e.g., stash@{0}) (used with POP and SHOW)
include_untrackedbooleanNoStash untracked files alongside modifications
diffbooleanNoSHOW returns diff content instead of a summary

history

Commit history, operation reflogs, and line-by-line file attribution.

ParameterTypeRequiredDescription
commandstringYesLOG, REFLOG, BLAME
target_commitstringNoStarting commit hash or reference (defaults to HEAD)
target_pathsstringNoPaths to filter history, or target file to blame (required for BLAME)
patternstringNoFilter commit messages (LOG only)
filterstringNoFilter file paths (LOG only)
limitnumberNoMax entries to return
offsetnumberNoPagination offset

rewrite

Destructive history modifications. Every rewrite creates a backup first.

ParameterTypeRequiredDescription
commandstringYesAMEND (amend last commit), REVERT (revert a commit), SOFT (soft reset HEAD), HARD (hard reset, discards all modifications)
commit_messagestringNoNew commit message (AMEND only)
target_pathsstringNoPaths to include in amend (AMEND only)
target_commitstringNoCommit hash (required for REVERT, SOFT, HARD)
confirmedbooleanNoRequired to execute (always required for HARD)
dry_runbooleanNoPreview changes without modifying state

integrate

Executes integrations (merge, rebase, cherry-pick) and resolves conflicts.

  • Workflow on Conflict: Returns {status: "conflict", conflicted_files: [...]}. Resolve files, stage them, then call integrate command="CONTINUE".
ParameterTypeRequiredDescription
commandstringYesMERGE, UPDATE (rebase), PICK (cherry-pick), CONTINUE, ABORT
branch_namestringNoTarget branch name (required for MERGE and UPDATE)
target_commitstringNoCommit hash (required for PICK)
into_branchstringNoSwitch to this branch before merging (MERGE only)
delete_sourcebooleanNoDelete branch after successful merge (MERGE only)
push_afterbooleanNoAuto-push to remote after success (MERGE only)
new_branchstringNoCreate and switch to this branch after success (MERGE only)
ontostringNoBase branch to rebase onto (UPDATE only)

sync

Pushes, pulls, or fetches from remotes.

ParameterTypeRequiredDescription
commandstringYesPUSH (send local commits), PULL (fetch and merge), FETCH (download changes, safest)
confirmedbooleanNoRequired for PUSH
dry_runbooleanNoPreview changes before pushing/pulling
remote_namestringNoRemote name (defaults to origin)
branchstringNoSpecific branch to sync

Error Codes

When a safety check blocks an operation, one of the following codes is returned:

CodeTriggerSolution
SECRET_DETECTEDCredentials or keys found in the diffRemove secrets before staging or committing
INTEGRITY ALERTWorkspace files changed between PREVIEW and APPLYStart the commit process again (PREVIEW → APPLY)
plan expiredThe PREVIEW commit plan timed outRun commit command="PREVIEW" again

Mutating operations that require confirmation return a blocked status in the JSON response rather than a dedicated error code — read the message/hint field and pass confirmed=true after explaining the impact to the user.


CLI Subcommands

These subcommands are invoked from the shell (git-courer <subcommand>), not over MCP. They support the MCP workflow (diagnostics, hooks, releases).

doctor

git-courer doctor

Runs read-only diagnostics on every MCP client detected on the system and prints a human-readable health report: config path, whether the MCP server is configured, whether the prompt block is injected, and the hooks installation status (per client). All diagnostic logic lives in the installer package; doctor is a thin CLI adapter.

Use it when something feels off with a client's git-courer integration — it surfaces exactly which piece (config, prompt block, or hooks) is missing or misconfigured.

hook-check

git-courer hook-check <shell-command>
# or, in Codex hook mode: reads Codex hook JSON from stdin

Classifies a shell command the agent is about to run and emits a JSON Result indicating whether a git-courer MCP tool should be used instead of raw git. Two modes:

  • Argument mode: git-courer hook-check "git commit -m foo" → prints {command, decision, mcp_tool, reason} JSON. decision is "allow" (non-git, safe to run) or "ask" (git mutation/read that should use the MCP tool named in mcp_tool).
  • Stdin mode (Codex hooks): when stdin is a pipe and no args are given, reads Codex PreToolUse hook JSON, extracts the command, classifies it, and emits Codex hook output with additionalContext suggesting the MCP tool. Non-git commands exit cleanly with no output.

The classifier is a pure function (internal/classifier/gitcmd) — it inspects the command string only and never executes anything. Related hook subcommands: session-start-hook, subagent-start-hook, and pre-invocation-hook emit golden-rules context for Codex/Antigravity lifecycle hooks.

release

git-courer release [bump]

Runs the release workflow (tag or GitHub Release) via the workflow.ReleaseService. Not an MCP tool — it is a CLI-only command driven by the commit store and the configured release.type.