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.
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. |