Reference

Patch Language
Spec v1.3

The complete syntax reference for authoring and understanding RepoPatch patchsets — operations, prefix rules, executor behaviour, and hard limits.

v1.3 — Current Anchor-First Model

Top-Level Structure

A valid patchset document has exactly this shape:

PATCHSET PATCH path/to/file.py ... operation blocks ... ENDPATCH PATCH path/to/another_file.py ... operations ... ENDPATCH ENDPATCHSET

Content Prefixes & Separator

Every content line inside an operation carries one of two prefixes. The prefix is determined solely by which block the line belongs to — not by whether the line is blank or non-blank.

OLD / ANCHOR block prefix: - (dash space) - def process_data(items): - return items - (blank old line → exactly "- ")
NEW / INSERT block prefix: . (dot space) . def process_data(items, validate=True): . return items . (blank new line → exactly ". ")

The separator between an old block and a new block must be exactly:

---
Blank Line Rule — Critical
  • A blank line in an old/anchor block → write as - (dash-space, nothing after). Never use . .
  • A blank line in a new/insert block → write as . (dot-space, nothing after). Never use - .
  • This rule applies in every operation — INSERT BEFORE, INSERT AFTER, DELETE, REPLACE, CREATEFILE — without exception.

Anchor Model & Uniqueness

v1.3 is anchor-first. An anchor block is a contiguous block of one or more - lines. The executor finds exactly one acceptable match for each anchor in the target file.

Operations

INSERT BEFORE Insert

Adds new lines immediately before a matched anchor block.

INSERT BEFORE - anchor line 1 - anchor line 2 --- . new line 1 . new line 2
INSERT AFTER Insert

Adds new lines immediately after a matched anchor block.

INSERT AFTER - anchor line 1 - anchor line 2 --- . new line 1 . new line 2
DELETE Remove

Removes an explicit old-content block from the file.

DELETE - old line 1 - old line 2 - old line 3
REPLACE Swap

Swaps an explicit old block for a new block at the same logical location.

REPLACE - def foo(): - - pass --- . def foo(): . . return 42

In the example above, the second - line and the second . line each represent a blank line in the file.

CREATEFILE New File

Creates a brand-new file. The target file must not already exist in the workspace.

PATCH src/new_module.py CREATEFILE . """New module.""" . . MAX_RETRIES = 3 . TIMEOUT = 30 ENDPATCH
DELETEFILE Delete File

Removes an entire file from the workspace. The target file must exist.

PATCH src/obsolete.py DELETEFILE ENDPATCH

Executor Behaviour

For each operation the executor must:

Hard Limits

These rules are never violated, regardless of how a request is framed:

⛔ Must Never Do
  • Output git diff, unified diff, or context diff.
  • Output comments inside any PATCH block.
  • Include code fences or markdown formatting inside the PATCHSET body.
  • Omit required anchor or old blocks for INSERT, DELETE, or REPLACE.
  • Use line numbers as patch semantics.
  • Guess when an old block is ambiguous.
  • Renumber or rewrite the target file outside the requested operations.
  • Use . as the prefix for any line in an old or anchor block.
  • Use - as the prefix for any line in a new or insert block.