Skip to main content
Glama

prune_code_snippet

Compress in-memory source code into compact AST/interface signatures before LLM prompts, returning pruned code and precise token savings.

Instructions

Compresses arbitrary in-memory source code or text into compact AST/interface signatures on-the-fly, returning pruned code and precise token savings percentage (80-95% reduction).

Behavior:

  • Pure in-memory transformation: Does not read or write any files on disk; takes text input and returns pruned text.

  • Idempotent: Deterministic output for identical input code and reduction mode.

  • 100% Offline: Polyglot AST/regex parsers for Python, TypeScript, Go, Rust, Java, C#, C++, Swift, Kotlin.

Usage Guidelines:

  • When to use: Compress in-memory code blocks or clipboard buffers before passing them into LLM chat prompts.

  • Sibling Routing: To scan and compress entire directories or repositories on disk, use 'get_project_context_tree' or 'get_smart_skeleton_context'.

Returns: Markdown fenced code block with pruned signatures and precise token reduction percentage.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesRaw source code content to prune.
reduction_modeNoReduction tier: 'ultra' for AST signatures only (80-95% reduction), 'balanced' for signatures + control flow.ultra
file_path_or_extNoFile name or extension (e.g. 'service.ts', 'main.go', 'app.py', '.rs', '.java', '.cs', '.kt', '.swift') indicating language parser.snippet.py

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.1.1
    • addedInput schema / properties / code / description
      Added value: +"Raw source code content to prune."
    • addedInput schema / properties / file_path_or_ext / description
      Added value: +"File name or extension (e.g. 'service.ts', 'main.go', 'app.py', '.rs', '.java', '.cs', '.kt', '.swift') indicating language parser."
    • addedInput schema / properties / reduction_mode / description
      Added value: +"Reduction tier: 'ultra' for AST signatures only (80-95% reduction), 'balanced' for signatures + control flow."
  2. First observedv0.1.0

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does it well: it discloses the no-disk-I/O contract, idempotency, offline operation, and the supported language set. The gap is failure behavior — nothing says what happens with an unsupported extension or code the parser cannot handle, which matters for a tool taking arbitrary input plus a language hint.

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 with the core purpose in the first sentence, then labeled Behavior / Usage Guidelines / Returns sections that are easy to scan. Slightly verbose — the 80-95% figure appears twice and the language enumeration partially duplicates the schema's extension list.

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?

An output schema exists so return values need not be spelled out, yet the description still notes the Markdown fenced-block plus token-reduction percentage. Combined with the behavioral and routing detail, an agent has everything needed to call this correctly.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline is 3; the schema already documents code, reduction_mode tiers, and file_path_or_ext extensions. The description's restatement of the ultra/balanced tiers and the language list adds emphasis but no meaning beyond the schema.

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 ('Compresses arbitrary in-memory source code or text into compact AST/interface signatures') and pins the transform as on-the-fly/in-memory. That scope qualifier cleanly separates it from disk-scanning siblings like get_project_context_tree before the agent opens any 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?

Explicit 'When to use' names the concrete scenario (compressing in-memory code blocks or clipboard buffers before LLM prompts) and 'Sibling Routing' names the two alternatives for the on-disk case. Both when-to-use and when-not-to-use are covered.

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