Skip to main content
Glama

move_symbol

Move a top-level function, type, const, or var from one file to another in the same package. Atomic operation with doc-comment preservation and automatic rollback on failure.

Instructions

Move a top-level declaration (function, method, type, const, or var) from one file to another within the SAME directory/package, atomically.

The symbol's full source — its declaration and, by default, its contiguous leading doc comment (include_doc_comment, default true) — is removed from source_uri and appended to destination_uri in a single all-or-nothing operation: if the destination write fails, the source is rolled back, so the declaration is never duplicated or lost. Locates the symbol via the LSP document-symbol tree, falling back to a fresh tree-sitter parse when the language server is cold or unavailable.

Scope (v1, conservative): source and destination must be in the SAME directory. plumb does NOT rewrite references or imports, so a move that would change a symbol's package or import path — a different directory, or (for Go) a different package clause — is REFUSED rather than applied half-correctly. Move within a package where references resolve unchanged; relocate across packages by hand.

destination_uri must already exist unless create_destination=true (a newly created Go file is seeded with the source file's package clause). Refuses when the symbol is not found, the name is ambiguous (disambiguate with a slash-separated name_path), the destination is missing without create_destination, or either path is outside the workspace. For Go, also refuses when source and destination carry different build constraints — explicit (//go:build or legacy +build comments) or implicit (the _GOOS/_GOARCH/_GOOS_GOARCH and _test filename-suffix conventions, e.g. handlers_linux.go or foo_test.go) — since moving a declaration between them would silently change what compiles per platform/tag, or drop it from the production build entirely.

Dry-run by default (dry_run=true): previews the unified diff of both files without writing. Set dry_run=false to apply.

Undo is per-file: reverting a move takes two undo_edit calls, one for source and one for destination, and the state between them is a transient duplicate of the moved declaration in both files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dry_runNoIf true (default), preview the diff of both files only; do not write.
dirty_okNoAllow moving when either file has uncommitted changes. Default false — review/commit first, or pass true to proceed.
name_pathYesSlash-separated symbol path within the source file (e.g. "ClassName/methodName", or just "funcName" for a top-level declaration).
source_uriYesAbsolute path, file:// URI, or workspace-relative path of the file currently holding the symbol.
destination_uriYesAbsolute path, file:// URI, or workspace-relative path of the file to move the declaration into. Must be in the SAME directory (package) as source_uri.
create_destinationNoCreate destination_uri if it does not exist. Default false (the destination must already exist). A newly created Go file is seeded with the source file's package clause.
include_doc_commentNoMove the symbol's contiguous leading doc comment along with it. Default true — a relocated declaration should keep its documentation. Where the declaration is WRAPPED (an exported ES declaration under its export statement, a decorated Python def under its @decorator) its doc comment sits above the wrapper, so the moved range covers the wrapper too — which is what keeps @property with the method it decorates.
Behavior5/5

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

With no annotations provided, the description fully discloses behavioral traits: atomic all-or-nothing rollback, dry-run default, per-file undo requiring two undo_edit calls, refusal on build-constraint mismatches, and handling of wrappers/doc comments. This goes far beyond minimal requirements.

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 contributes meaningful detail. It is front-loaded with the core action, then systematically covers scope, exclusions, safety, parameters, and undo. No filler or redundancy—each sentence earns its place given the tool's complexity.

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 7 parameters, no annotations, and no output schema, this description is remarkably thorough. It covers failure modes, edge cases (import paths, build constraints, wrapped declarations), and expected outcomes (diff preview, undo behavior), making it complete enough for an agent to select and invoke correctly without additional info.

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 has 100% coverage, the description enriches each parameter with operational implications: create_destination seeds a Go file with the package clause, include_doc_comment explains wrapper coverage, dirty_ok clarifies uncommitted checks, and dry_run defines the preview behavior. This significantly aids correct parameter usage.

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 begins with a precise verb and resource: 'Move a top-level declaration (function, method, type, const, or var) from one file to another...' It immediately differentiates from sibling tools by specifying the atomic cross-file move scope and the same-directory constraint, making it unambiguous.

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 explicitly states when to use the tool ('Move within a package where references resolve unchanged') and when not to ('relocate across packages by hand'), and lists refusal conditions. It also gives guidance on dry-run and undo, providing full context for selection among alternatives.

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/plumbkit/plumb'

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