Skip to main content
Glama

gemini_patch

Have Gemini propose a code change as a unified diff, validated with git apply --check against your working tree and never applied, so you can review and apply it yourself.

Instructions

Have Gemini propose a code change as a unified diff. zwilling checks the paths it touches (same rules as attachments) and dry-runs it with git apply --check against the working tree, but never applies it: review it and apply it yourself. Attach every file the change touches. If it doesn't apply, call again with follow_up and the error.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "instructions": "<instructions>"
    },
    "name": "gemini_patch"
  }
}

Input Schema

NameRequiredDescriptionDefault
diffNoAttach a git diff: "staged" (index vs HEAD), "working" (unstaged), "HEAD" (all uncommitted changes), a ref, or a range like "main...HEAD". Counts against the size limit.
filesNoPaths relative to the project root (max 20 files, 500 KB total). Also accepts line ranges (src/a.ts:40-120), directories (src/) and globs (src/**/*.ts); globs and directories respect .gitignore. Contents are inlined into the prompt.
modelNoModel ID as listed by `agy models`; the suffix is the reasoning effort, e.g. gemini-3.8-flash-low | -medium | -high. Omit to use the configured default (.zwilling.json, else agy's). Higher effort is slower.
follow_upNoLog entry id of an earlier answer (e.g. g-20261113-a1b2c3, shown after every answer). Its question and answer are sent along as context. One level only: the earlier entry's own history is not included.
timeout_sNoTimeout for this call in seconds (default 120).
instructionsYesThe change to make.

Output Schema

NameRequiredDescriptionDefault
errorNoWhy the patch was not found, was refused, or does not apply.
filesYesRoot-relative paths the patch touches.
patchYesThe proposed unified diff, or null if the answer contained none.
appliesYesTrue if the patch passed the path checks and `git apply --check` against the current working tree.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The only annotation is openWorldHint, so the description carries the burden and does it well: it discloses path validation ('same rules as attachments'), a dry-run via `git apply --check` against the working tree, and the critical guarantee that the change is never applied. It also tells the agent to review and apply the change itself, which is essential behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four short sentences, front-loaded with the purpose, then the safety/validation behavior, then the prerequisite, then the error-recovery path. Every sentence carries actionable information with no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, return format need not be explained. The description covers safety semantics, validation behavior, required attachment practice, and the retry path, leaving nothing an agent needs in order to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so parameters like diff, files, model, and timeout are already documented. The description reinforces files ('attach every file the change touches') and follow_up usage, but adds little syntax or format detail beyond the schema, so baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: 'Have Gemini propose a code change as a unified diff.' The proposal-only framing (never applies) makes it clearly distinct from a general ask or review tool, so an agent can identify it without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete operating context: attach every file the change touches, and on a failed apply, retry with follow_up and the error. It does not explicitly contrast with siblings such as gemini_review, but the 'propose a change' framing plus the retry loop covers the practical when-to-use case.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.