LeIndex-Code: Token-Efficient Code Analysis

VerifiedSafe

Code analysis with 82% token savings via 5-layer stack (AST, call graph, CFG, DFG, PDG). Preserves semantic completeness for LLM usage.

Sby Skills Guide Bot
DevelopmentIntermediate
206/2/2026
Claude CodeCursor
#code-analysis#token-efficiency#semantic-search#call-graph#ast

Recommended for

Our review

LeIndex-Code provides token-efficient code analysis using a 5-layer stack (AST, Call Graph, CFG, DFG, PDG) to reduce token usage by up to 82% while preserving semantic completeness for LLM-assisted coding tasks.

Strengths

  • Significant token savings (82% balanced mode) without losing semantic information for LLM usage.
  • Multi-layer analysis (AST, call graph, control flow, data flow, program dependency) for comprehensive code understanding.
  • Supports semantic search and context extraction for efficient exploration.

Limitations

  • Ultra mode (98% savings) sacrifices too much detail for actionable code generation.
  • Requires Python environment and installation of the maestro library.
  • May not be as effective for very small codebases where token savings are trivial.
When to use it

Use when you need to analyze or refactor a large codebase with limited LLM token budget, such as for complex code generation or debugging tasks.

When not to use it

Avoid when you need full, unfiltered code context for precise debugging or when the codebase is small and token savings are unnecessary.

Security analysis

Safe
Quality score85/100

The skill is a Python library for code analysis with no destructive or exfiltrating actions. Allowed-tools include Bash but no shell commands are executed; only Python imports and method calls are demonstrated. There is no risk of data leakage, system damage, or security bypass.

No concerns found

Examples

Extract token-efficient context
Use LeIndex-Code to extract a token-efficient summary of the file src/api.py in balanced mode for code generation.
Semantic search
Search for authentication-related functions in my project using LeIndex-Code's semantic search.
Analyze call graph
Analyze the call graph of the main function in app.py to understand its dependencies.

name: leindex-code description: Token-efficient code analysis via 5-layer stack (AST, Call Graph, CFG, DFG, PDG). 82% savings (balanced mode) with semantic completeness. allowed-tools: [Bash] keywords: [debug, refactor, understand, complexity, "call graph", "data flow", "what calls", "how complex", search, explore, analyze, dead code, architecture, imports]

LeIndex-Code: Complete Reference

Token-efficient code analysis with 82% token savings (balanced mode) while preserving semantic completeness for LLM usage.

Quick Reference

| Task | Command | |------|---------| | Context extraction | from maestro.leindex import ContextExtractor | | Semantic search | from maestro.leindex import semantic_search | | AST analysis | from maestro.leindex import ASTAnalyzer | | Call graph | from maestro.leindex import CallGraphAnalyzer |


Modes

Balanced Mode (Default) - 82% savings, LLM Actionable

Use for: Code generation, refactoring, implementation

from maestro.leindex import ContextExtractor

extractor = ContextExtractor(mode='balanced')  # Default
result = extractor.extract_for_file('src/api.py')

print(f"Savings: {result.savings_percent:.1f}%")
print(result.context.to_llm_string())

# Output includes:
# L119: analyze_file(file_path: str, include_call...) -> ContextExtractionResult
# L136: semantic_search(query: str, project_path..., limit: int)

Ultra Mode - 98% savings, Exploration Only

Use for: Code exploration, search, impact analysis

extractor = ContextExtractor(mode='ultra')
result = extractor.extract_for_file('src/api.py')

# Output:
# fn:analyze_file build_semantic_index get_token_savings
# (No signatures, NOT actionable for code generation)

Token Efficiency Comparison

| Mode | Savings | Semantic Quality | LLM Actionable | Use Case | |------|---------|------------------|----------------|----------| | Raw | 0% | Complete | ✓ Yes | Full file | | Balanced | 82% | High | ✓ Yes | Code generation | | Ultra | 98% | Low | ❌ No | Exploration only |

Key Insight: Balanced mode at 82% savings is the OPTIMAL balance for LLM-assisted coding. Ultra mode sacrifices too much semantic information (no signatures, no line numbers, no types) for LLM to accurately use the code.


Python API

from maestro.leindex import (
    # 5-layer analyzers
    ASTAnalyzer,
    CallGraphAnalyzer,
    CFGAnalyzer,
    DFGAnalyzer,
    SlicingAnalyzer,

    # Context extraction
    ContextExtractor,
    get_relevant_context,
    get_context_for_prompt,

    # Semantic search
    SemanticIndex,
    semantic_search,
    build_semantic_index,

    # Memory integration
    LeIndexMemoryBridge,
    get_leindex_memory_bridge,
)

# Example: Get token-efficient context (balanced mode)
extractor = ContextExtractor(mode='balanced')
result = extractor.extract_for_file('maestro/leindex/__init__.py')

print(f"Savings: {result.savings_percent:.1f}%")
print(f"Quality: {result.get_quality_report()}")

# Example: Semantic search
results = semantic_search("authentication functions", "/path/to/project")
for entity, score in results:
    print(f"{entity.name} in {entity.file} (score: {score:.2f})")
Related skills