Skip to main content
Glama

Patch theme file (find & replace)

patch_file

Replace an exact string in a Shopify theme file to make targeted edits. Ensures the text is unique and auto-commits changes to git for undo.

Instructions

Edit an existing theme file by replacing an exact string. old_str must appear exactly once in the file (include enough surrounding lines to make it unique). Auto-commits to git. Preferred over write_file for edits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageNoShort description for the git log
new_strYesReplacement text (empty string deletes old_str)
old_strYesExact text to replace — must be unique in the file
filenameYes
allow_hiddenNoRequired (true) to edit content inside a disabled/hidden section or block. Only set after the user explicitly confirms they want to edit hidden content.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.0

TDQS

A4.6/5.0
Behavior4/5

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

With no annotations provided, the description carries the full behavioral burden. It discloses a critical side effect ('Auto-commits to git'), the exact-match constraint, and the requirement that old_str appear exactly once. It does not go into failure modes or hidden-content behavior, but the most important behavioral traits are present.

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?

Two dense sentences deliver the action, constraint, side effect, and sibling-tool guidance with no filler. The most important operational details are front-loaded, and every clause earns its place.

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

Completeness4/5

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

For a 5-parameter edit tool with no output schema, the description plus schema covers the core invocation: what to patch, how to make the match unique, the auto-commit effect, and when to prefer it over write_file. The allow_hidden parameter is documented in the schema, and return-behavior details are not essential for calling this tool correctly.

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

Parameters4/5

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

Schema description coverage is 80%, so the schema handles most parameter meaning. The description adds practical value beyond the schema by explaining that enough surrounding lines should be included to make old_str unique, which helps the agent construct a valid old_str value. This is a meaningful addition rather than mere repetition.

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?

The description states a specific action ('Edit an existing theme file'), the exact mechanism ('replacing an exact string'), and the resource. It also distinguishes itself from write_file by explicitly saying it is preferred for edits, so an agent can differentiate it from siblings without ambiguity.

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

Usage Guidelines5/5

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

It gives clear, actionable guidance: use this for editing existing files by exact replacement, and it explicitly names write_file as the alternative for other cases ('Preferred over write_file for edits'). It also tells the agent how to make old_str unique by including surrounding lines, which is essential for correct invocation.

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