Skip to main content
Glama

file_edit_lines

Destructive

Apply multiple line-based edits—patch, insert, delete, or append—to one file in a single atomic call using original line numbers, with validation and dry-run before writing.

Instructions

Apply one or more edits to a single file in one atomic operation. All patches are validated and then applied bottom-up - supply the ORIGINAL line numbers from your last read.

actions:

  • patch: replace startLine..endLine with content (both inclusive, 1-based)

  • insert: insert content after startLine; use startLine=0 to prepend

  • delete: remove startLine..endLine; content is ignored

  • append: add content at the end of the file; line numbers are ignored Content is lines separated by line breaks; one final line break does not add an empty line.

COPY, DO NOT RETYPE: patch, insert and append may carry "from" instead of content. The server copies the lines (same file, another file, another workspace); you write none of them. "from": { "file": "Services/A.cs" (default: this file), "workspace": "Other" (default: this workspace), "startLine": 40, "endLine": 80 (leave both out for the whole file), "expectFirstLine": "public void Foo()", "expectLastLine": "}" (compared trimmed; the copy is refused if the lines moved), "remove": true (cut: the lines are deleted from their file too; both expect lines required), "replace": [{"find": "Invoice", "with": "Order", "count": 12}] (literal text, the match count must equal count), "csharp": {"namespaces": {"Old.Ns": "New.Ns"}, "identifiers": {"OldName": "NewName"}} (C# files only, by syntax; strings and comments are never touched; use replace for other languages), "indent": -4 (shift every line; negative removes leading spaces or tabs) } Use from whenever you move or duplicate more than about 10 lines that stay mostly the same. Take the line numbers from code_outline or code_method. Copied text that holds a secret is refused. Line numbers in from refer to the source as it is now.

dryRun=true runs every check and copy and reports what would happen without writing.

MANDATORY BATCHING RULE - violations cause wrong-place edits: When making several changes to the same file, send ALL patches in a SINGLE file_edit_lines call. Waymark applies them bottom-up, so line numbers stay correct across all patches. A second call uses line numbers that changed with the first one and lands at the WRONG LINE. Correct: one call with patches [{lines 10-12}, {lines 45-50}, {lines 80-85}] Wrong: three separate file_edit_lines calls for the same file.

OVERLAP RULE: ranges must not overlap - this is checked before anything is written. The file keeps its encoding and line endings. A cut from another file changes both files or neither. RETURNS: final line count, size in bytes, last-modified time, lines affected and, for copies, where the text came from.

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": {
      "workspace": "<workspace>",
      "relativeFilePath": "<relativeFilePath>",
      "patchesJson": "<patchesJson>"
    },
    "name": "file_edit_lines"
  }
}

Input Schema

NameRequiredDescriptionDefault
guideNotrue: put the files guide first in the result. Use on your first files call, or when told it changed.
dryRunNotrue: check and report only, write nothing (default false)
workspaceYesWorkspace name as shown in Waymark (a single workspace; '*' is not accepted)
patchesJsonYesJSON array of patch operations. Each entry: { "action": "patch|insert|delete|append", "startLine": 45, "endLine": 89, "content": "<new content>" } or, to copy lines instead of typing them, replace content by "from": { ... } (see the tool description). startLine/endLine are 1-based. content is ignored for delete.
relativeFilePathYesRelative file path from the workspace root (e.g. 'Services/OrderService.cs')

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.2.1

TDQS

A4.9/5.0
Behavior5/5

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

Annotations only say destructive/non-idempotent; the description goes far beyond by disclosing bottom-up application using ORIGINAL line numbers, pre-write validation and overlap checking, encoding/line-ending preservation, cross-file cut atomicity ('both files or neither'), secret-scanning refusal, expectFirstLine/expectLastLine guards, and the return fields.

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

Conciseness4/5

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

Front-loaded purpose sentence, then a compact action list, a 'from' block, and a scoped batching rule; nearly every line carries information. The Correct/Wrong batching example and a couple of parenthetical repeats cost a little length, but for a destructive multi-modal tool the density is justified.

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?

For a high-complexity destructive mutation tool with no output schema, the description covers actions, copy semantics, validation/refusal behavior, dry run, batching constraints, and even a RETURNS line describing resulting fields. Nothing an agent needs to call it safely is missing.

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

Parameters5/5

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

Although schema coverage is 100%, the patchesJson schema explicitly defers to the description for the 'from' object, and the description supplies semantics the schema lacks: startLine=0 prepends, delete ignores content, single trailing line break is not an extra line, from.startLine/endLine default to the whole file, and requires how validation works.

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 ('Apply one or more edits to a single file in one atomic operation') and enumerates the four supported actions (patch/insert/delete/append), so an agent can tell it apart from file_write or file_replace 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 Guidelines5/5

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

Gives explicit routing: take line numbers from code_outline or code_method, use 'from' for moving/duplicating more than ~10 mostly-identical lines, use replace instead of csharp for non-C# languages, and dryRun to preview. It also states a hard prohibition (never split edits to one file across calls) with the reason, which is exactly the kind of when-not guidance that prevents misuse.

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