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
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Raw source code content to prune. | |
| reduction_mode | No | Reduction tier: 'ultra' for AST signatures only (80-95% reduction), 'balanced' for signatures + control flow. | ultra |
| file_path_or_ext | No | File name or extension (e.g. 'service.ts', 'main.go', 'app.py', '.rs', '.java', '.cs', '.kt', '.swift') indicating language parser. | snippet.py |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |