LeIndex-Code: Token-Efficient Code Analysis

VerifiedSafe

LeIndex-Code provides token-efficient code analysis via a 5-layer stack (AST, Call Graph, CFG, DFG, PDG), achieving 82% token savings in balanced mode with full semantic completeness for LLMs. It helps when you need to generate, refactor, or understand code while minimizing token usage in AI-assisted workflows.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude CodeCursorWindsurfCopilotCodex
#code-analysis#token-efficient#call-graph#semantic-search

Recommended for

Automated summary

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.

Strengths

  • Significant token savings (82% in balanced mode) without losing semantic information needed for code generation.
  • Multi-layer analysis (AST, call graph, control flow, data flow, program dependence) for deep code understanding.
  • Built-in semantic search for finding relevant code across a project.
  • Provides actionable LLM context with balanced mode while ultra mode for exploration.

Limitations

  • Ultra mode sacrifices significant semantic detail, not suitable for code generation.
  • Requires Python dependency (maestro.leindex) and may not be available in all environments.
  • The 82% savings is specific to balanced mode; savings may vary depending on codebase.
When to use it

Use LeIndex-Code when you need to provide an LLM with a condensed yet semantically complete view of your codebase for refactoring, debugging, or generating new code.

When not to use it

Avoid LeIndex-Code when you need full, uncompromised code context or when the codebase is very small where token savings are negligible.

Security analysis

Safe
Quality score90/100

The skill is a documentation reference for a Python library. It contains no destructive commands, data exfiltration instructions, or safety bypasses. The allowed-tools: [Bash] is metadata, but the skill itself does not instruct any bash execution beyond Python imports.

No concerns found

How this analysis is made

Examples

Token-efficient code context extraction
Extract token-efficient context for refactoring: use LeIndex-Code's ContextExtractor in balanced mode on the file 'src/api.py'.
Semantic search across project
Run semantic search for 'authentication' in '/path/to/project' using LeIndex-Code's semantic_search function.
Call graph analysis
Analyze the call graph of function 'analyze_file' in 'src/analyzer.py' using LeIndex-Code's CallGraphAnalyzer.

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})")

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/leindex-code-token-efficient-code-analysis-mma3jrli/download' --output '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli/SKILL.md.part' && mv '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli/SKILL.md.part' '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Original excerpt: Quick Reference
TaskCommand
Context extractionfrom maestro.leindex import ContextExtractor
Semantic searchfrom maestro.leindex import semantic_search
AST analysisfrom maestro.leindex import ASTAnalyzer
Call graphfrom maestro.leindex import CallGraphAnalyzer

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli/SKILL.md' && test -s '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/leindex-code' && cp -R '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli' '.claude/skills/leindex-code'

Cursor
test -f '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli/SKILL.md' && test -s '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/leindex-code' && cp -R '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli' '.cursor/skills/leindex-code'

Codex
test -f '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli/SKILL.md' && test -s '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/leindex-code' && cp -R '.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli' '.agents/skills/leindex-code'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli'

openskills read 'leindex-code-token-efficient-code-analysis-mma3jrli'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/leindex-code-token-efficient-code-analysis-mma3jrli/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills