Claude-specific loctree skill with PostToolUse hook augmentation for rg/grep results and explicit loct commands.
Loctree provides AST-aware codebase understanding. Unlike text search (grep/ripgrep), loctree understands code structure: symbol definitions, exports, imports, dependencies, and dead code.
This skill is automatically active through the PostToolUse hook. When you use Grep or Bash with rg/grep, loctree automatically augments results with semantic context.
You can also explicitly invoke loctree for deeper analysis.
When you search for code patterns, the hook automatically:
A.*B → A|B)loct find to get semantic matchesExample: You grep for ApiClient.*request → Hook transforms to request|ApiClient → Returns symbol definitions + semantic matches + cross-match files showing where both terms appear together.
loct find <symbol|pattern>Search for symbol definitions across the codebase.
loct find "MyComponent" # Single symbol
loct find "SymbolA|SymbolB" # Multi-query (OR)
loct find "canonical_model|vision" # Find related symbols
Output includes:
loct impact <file>Analyze what would break if you change a file.
loct impact src/utils/helpers.ts
Use before refactoring to understand ripple effects.
loct slice <file>Get the minimal dependency slice for a file.
loct slice src/components/Button.tsx
Shows only the files needed to understand this file.
loct healthCodebase health report: dead code, cycles, duplicates.
loct health
Output includes:
loct focus <directory>Analyze a specific directory's structure.
loct focus src/api/
loct query who-imports <file>Find all files that import a given file.
loct query who-imports src/hooks/useAuth.ts
loct --for-aiGet a comprehensive codebase overview optimized for AI understanding.
loct --for-ai
Run this first when starting work on a new codebase.
loct --for-ai to understand codebase structureloct find instead of grep for symbol searches (10x better results)loct impact before refactoring to avoid breaking changesloct health periodically to catch dead code and cyclesThe hook automatically recognizes these patterns:
| Pattern Type | Example | Action |
|---|---|---|
| PascalCase | MyComponent | loct find |
| camelCase | handleClick | loct find |
| snake_case | user_service | loct find or Tauri command |
| File path | src/utils.ts | loct slice |
| Directory | src/api/ | loct focus |
| Multi-term | A|B or A.*B | loct find "A|B" |
| Health keywords | dead, unused, cycle | loct health |
When searching multiple terms, loctree identifies files containing 2+ different terms - these are often the most relevant files for understanding relationships.
Install loctree CLI:
cargo install loctree
# or
brew install loctree
Verify installation:
loct --version
Initialize in your project (creates .loctree/ cache):
loct scan
Made with (งಠ_ಠ)ง by the ⌜ Loctree ⌟ 𝖙𝖊𝖆𝖒 (c) 2026 Maciej & Monika + Klaudiusz (AI)