Patch theme file (find & replace)
patch_fileReplace 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.
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": {
"filename": "<filename>",
"old_str": "<old_str>",
"new_str": "<new_str>"
},
"name": "patch_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | No | Short description for the git log | |
| new_str | Yes | Replacement text (empty string deletes old_str) | |
| old_str | Yes | Exact text to replace — must be unique in the file | |
| filename | Yes | ||
| allow_hidden | No | Required (true) to edit content inside a disabled/hidden section or block. Only set after the user explicitly confirms they want to edit hidden content. |