Skip to main content
Glama

Replace a symbol's body by name (write)

replace_symbol
DestructiveIdempotent

Edit code symbols by name via a project index: replace an existing definition or insert a new one beside an anchor, with atomic batch edits.

Instructions

Write a symbol by NAME — you never re-send the old body to locate the edit. Two modes: REPLACE (name/path+line plus body) overwrites an existing definition; INSERT (after:"X" or before:"X" plus body) adds a NEW symbol next to an existing one, which is what you want for 'add a method beside the related ones' — the anchor's own span comes from the index, so after means after its closing brace, not its signature line. Insert puts body in verbatim: indent it for the file, and include a leading/trailing newline if you want a blank line. range comes from the index; the file is SNAPSHOTTED first (.slimdex/snapshots), re-indexed after, and the new line span is reported so you don't re-read to verify. Safe to mix with ordinary edit tools: if the file moved under the index, a NAME is re-resolved against a fresh parse automatically (an explicit path+line still refuses, since that coordinate is yours). Ambiguous/unknown names are refused, never guessed. body = the complete replacement definition, indented for the file. edits:[…] applies several at once (one snapshot, one re-index); the batch is refused before any write if a target is ambiguous, two edits overlap, or a file isn't writable, and a write that fails mid-batch rolls the earlier files back and says so.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyNoThe complete new definition, replacing the old one verbatim.
lineNoDefinition line (use with path).
nameNoSymbol to replace, resolved via the index.
pathNoFile path (use with line instead of name).
afterNoINSERT mode: add `body` as a NEW symbol immediately after this existing symbol's closing brace. Pin which occurrence with path + line when the name repeats inside one file (normal for CSS).
editsNoSeveral replacements, applied atomically. Each entry takes name, or path+line, plus body.
beforeNoINSERT mode: add `body` as a NEW symbol immediately before this existing symbol.
pathPrefixNoDisambiguate the after/before anchor when the name exists in several files.
Behavior5/5

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

While annotations already mark the tool as destructive and idempotent, the description adds substantial context: it snapshots the file first, re-indexes after, derives anchor spans from the index, inserts body verbatim, and guarantees atomic batch application with rollback on partial failure. It also explains that ambiguous names are refused and never guessed, offering safety details far beyond the annotation hints.

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?

The description is long, but every sentence earns its place by conveying operational details essential for correct use. It is front-loaded with the core purpose ("Write a symbol by NAME") and then progressively adds mode distinctions, safety behavior, and batch semantics. Given the tool's complexity, the length is appropriate and not wasteful.

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 tool with a destructive hint and no output schema, the description is remarkably complete. It covers both modes, failure and refusal scenarios, interaction with the index, snapshotting and re-indexing, batch atomicity with rollback, and even reports the new line span so the agent knows the return value. No critical aspect of usage is left unaddressed.

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 the schema already describes all parameters at 100% coverage, the description significantly enriches meaning: it explains the semantic difference between REPLACE and INSERT modes, clarifies that `after`/`before` refer to the anchor's closing brace, warns about indentation and newlines, and describes how `edits` provides atomic multi-symbol replacement. This goes well beyond the schema's literal field descriptions.

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 opens with a specific verb+resource: "Write a symbol by NAME" and immediately clarifies that you never need to re-send the old body. It further differentiates from sibling tools by detailing two modes (REPLACE and INSERT), making the tool's purpose unmistakable and distinct from the search/read-oriented siblings.

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?

The description gives explicit when-to-use guidance: it explains that INSERT mode is "what you want for 'add a method beside the related ones'", and contrasts with ordinary edit tools by explaining name-based resolution and automatic re-resolution when files move. It also states refusals for ambiguous/unknown names and batch failure handling, effectively telling the agent when not to use it.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Siddhukaushik/slimdex-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server