loctree
Claude-specific loctree skill with PostToolUse hook augmentation for rg/grep results and explicit loct commands.
SKILL.md
| Name | loctree |
| Description | Claude-specific loctree skill with PostToolUse hook augmentation for rg/grep results and explicit loct commands. |
name: loctree description: Claude-specific loctree skill with PostToolUse hook augmentation for rg/grep results and explicit loct commands.
Loctree - Codebase Intelligence Skill (Claude)
Loctree provides AST-aware codebase understanding. Unlike text search (grep/ripgrep), loctree understands code structure: symbol definitions, exports, imports, dependencies, and dead code.
When This Skill Activates
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.
Automatic Augmentation (Zero Friction)
When you search for code patterns, the hook automatically:
- Detects symbol-like patterns (PascalCase, camelCase, snake_case)
- Transforms regex to multi-query (
A.*B→A|B) - Runs
loct findto get semantic matches - Adds context: definitions, usages, cross-match files, dead code status
Example: You grep for ApiClient.*request → Hook transforms to request|ApiClient → Returns symbol definitions + semantic matches + cross-match files showing where both terms appear together.
Explicit Commands
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:
- Symbol matches (definitions)
- Semantic matches (similar names)
- Parameter matches (function args)
- Dead code status
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 health
Codebase health report: dead code, cycles, duplicates.
loct health
Output includes:
- Dead exports (unused code)
- Circular dependencies
- Duplicate exports (twins)
- Health score (0-100)
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-ai
Get a comprehensive codebase overview optimized for AI understanding.
loct --for-ai
Run this first when starting work on a new codebase.
Best Practices
- Start with
loct --for-aito understand codebase structure - Use
loct findinstead of grep for symbol searches (10x better results) - Check
loct impactbefore refactoring to avoid breaking changes - Run
loct healthperiodically to catch dead code and cycles
Pattern Recognition
The 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 |
Cross-Match Files
When searching multiple terms, loctree identifies files containing 2+ different terms - these are often the most relevant files for understanding relationships.
Prerequisites
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)