tree-sitter-scope-extractor
Installation
SKILL.md
Tree-Sitter AST Scope Extraction Protocol (Surgical Block Ingestion)
Overview
When an agent is debugging a stack trace pointing to a specific line number (e.g., TypeError at src/services/order.ts:142), naive agents ingest the complete 800-line source file.
Full-file ingestion:
- Consumes 6,000+ Tokens: 90% of the file contains unrelated CRUD routes, database connection pools, and logging utilities.
- Dilutes Debugging Attention: The LLM's attention heads must filter through 750 lines of background code to focus on the 20 lines that actually caused the bug.
- Multiplies Turn Latency: Re-ingested on every follow-up diagnostic turn.
The Tree-Sitter AST Scope Extraction Protocol parses the file into an Abstract Syntax Tree in 2 milliseconds, extracting strictly the top-level imports and the immediate enclosing AST scope (function, method, or class block).