DOCS
Documentation
API reference (mirror of docs.rs/loctree) and repo documentation. Canonical sources stay authoritative; this page indexes and links.
API REFERENCE
Crate loctree
AI-oriented project analyzer. A static-analysis instrument designed for AI agents and developers β addresses the generation patterns that produce re-export cascades, circular imports, and spaghetti dependencies.
Canonical source: docs.rs/loctree Β· crates.io
FEATURES
Features
- Holographic Slice β One file plus all its imports plus every consumer in a single context bundle.
- Handler Trace β Trace a Tauri / IPC handler end-to-end across the FE β BE boundary.
- Dead Export Detection β Find exports with zero importers β confidence-scored, suppressible.
- Circular Import Detection β Tarjan SCC over the import graph; identifies the weakest link in each cycle.
- Auto-Detect Stack β Marker-file detection for Rust, JS/TS, Python, Go, Dart, Svelte, Vue, CSS.
- HTML Reports β Server-rendered Leptos report with a navigable dependency graph.
QUICK START Β· LIBRARY
Quick start β library usage
Two examples mirroring the docs.rs intro β stack detection and import analysis.
Detect a project's stack
use loctree::{detect, snapshot, slicer};
use std::path::PathBuf;
let detected = detect::detect_stack(std::path::Path::new("."));
println!("Detected: {}", detected.description);Run import analysis
use loctree::{analyzer, args};
use std::path::PathBuf;
let mut parsed = args::ParsedArgs::default();
parsed.dead_exports = true;
parsed.circular = true;
let roots = vec![PathBuf::from(".")];
analyzer::run_import_analyzer(&roots, &parsed).unwrap();QUICK START Β· CLI
Quick start β CLI
The CLI binary is loct (loctree binary remains as a compatibility alias).
loctree
loctree slice src/App.tsx
loctree trace get_user
loctree -A --circular
loctree --for-aiFull operational walkthrough β install, scan, integrate β lives on /how-it-works.
RE-EXPORTS
Re-exports
Public surface re-exported at the crate root. Each entry links to the canonical rustdoc page.
Modeβ Top-level analysis mode (Init, Slice, Search, AnalyzeImports, ForAi, Tree, Git).Optionsβ Aggregate options consumed by run_import_analyzer.OutputModeβ Human / JSON / SARIF emission selector.ColorModeβ Auto / always / never color rendering.FileAnalysisβ Per-file analysis record (imports, exports, edges, language).DetectedStackβ Result of stack detection β language, marker file, description.detect_stackβ Detect the project stack from marker files.HolographicSliceβ File + dependencies + consumers context bundle.SliceConfigβ Configuration for the slicer (depth, filters).Snapshotβ Persistent snapshot β files, edges, indexes, bridges.run_import_analyzerβ Top-level entry point for analysis pipelines.ReportSectionβ Report section identifier used by HTML rendering.RefactorPlanβ Composite refactor plan with steps and risk.ParsedCommandβ Parsed CLI command after subcommand resolution.
MODULES
Modules
Top-level modules of the loctree crate. Each link opens the rustdoc module page.
analyzerβ Import / export analyzer for TS, JS, Python, Rust, CSS, Go, Dart, Svelte, Vue.argsβ Legacy flag parser used as fallback after the subcommand parser.cliβ Command enum, parser, and dispatch layer for the loct binary.colorsβ ANSI color rendering and color-mode handling.configβ Project configuration loader (.loctree/config.toml).detectβ Stack detection from marker files (Cargo.toml, package.json, β¦).diffβ Snapshot diff utilities β compare two scans.focuserβ Module focus β files, internal edges, external dependencies.fs_utilsβ Filesystem helpers β gather files, respect gitignore + loctignore.gitβ Git integration β HEAD detection, staleness checks.impactβ Impact analysis β direct + transitive consumers (blast radius).jaq_queryβ jq-style queries over snapshot.json.layoutmapβ CSS layout map analyzer.progressβ Progress bars and status reporting (stderr).queryβ Snapshot query layer used by instant commands.refactor_planβ Composite refactor planner β steps, risk, sequencing.similarityβ Similarity metrics for the twins / crowd analyzers.slicerβ Holographic slice generator β file + deps + consumers.snapshotβ Snapshot persistence β files, edges, export index, bridges.suppressionsβ False-positive management (.loctree/suppressions.toml).treeβ Directory tree rendering with LOC counts.typesβ Core types β FileAnalysis, Mode, Options, ImportEntry, ExportSymbol.watchβ File watcher β incremental scans on change.
REPO DOCUMENTATION
The repository ships canonical Markdown for everything operational. Each section below links straight to the source β single source of truth, never out of date.
GETTING STARTED
Getting started
Hands-on entry into Loctree β install, scan, query.
docs/getting-started.mdβ first scan, essential commands, core concepts.docs/README.mdβ documentation index with quick links to every topic.README.mdβ project overview, install paths, and the headline feature list.
INSTALLATION
Installation
docs/installation.mdβ install matrix: cargo, curl, source build.docs/dev/01_installation.mdβ developer setup for working on Loctree itself.docs/01_homebrew_release.mdβ Homebrew release process and tap structure.
CLI REFERENCE
CLI reference
Every subcommand of loct, every flag, every output mode.
docs/cli/commands.mdβ command catalog: scan, slice, dead, cycles, twins, trace, hotspots, β¦docs/cli/options.mdβ global flags, output modes, CI flags (--fail, --sarif, --no-scan).docs/02_query_mode.mdβ jq-style query mode reference.docs/03_runtime_apis.mdβ runtime API surface and integration points.
EDITOR / IDE
Editor / IDE
docs/ide/vscode.mdβ VS Code extension setup and command map.docs/ide/neovim.mdβ Neovim integration via lspconfig.docs/ide/lsp-protocol.mdβ raw LSP protocol contract β diagnostics, hover, code actions.
INTEGRATIONS
Integrations
docs/integrations/mcp-server.mdβ MCP server tools, configuration, and agent workflow.docs/integrations/ci-cd.mdβ GitHub Actions, GitLab CI, pre-commit, SARIF upload.docs/ci/README.mdβ CI cookbook entries.
TUTORIALS
Tutorials
01_ai_agents_manual.mdβ manual workflow for AI agents using loctree as a perception layer.02_crowd_detection.mdβ functional clustering with the crowd analyzer.03_test_fixture_filtering.mdβ filtering test fixtures from analysis.
USE CASES
Use cases
Thirty-plus worked examples on real codebases β from Tauri command audits to FastAPI route maps.
docs/use-cases/ β browse the full catalogue.
Highlights:
PERCEPTION LAYER
Perception layer
The doctrine behind context-over-memory: why agents perceive the codebase before remembering it.
PERCEPTION.mdβ manifesto / doctrine document.docs/perception/adr.mdβ architecture decision record.docs/perception/kpis.mdβ KPI definitions for agent context quality.docs/perception/research.mdβ underlying research synthesis.
ARCHITECTURE
Architecture
- Long-form architecture page β the canonical 4-layer doctrine, rendered in-page.
docs/architecture.mdβ source Markdown.- Semantic spec page β Cut 3A shell + make idiom catalog.
docs/semantic-spec.mdβ source Markdown.docs/dev/02_architecture.mdβ developer-oriented architecture notes.
BENCHMARKS
Benchmarks
01 β v0.7.0 comparative analysisβ head-to-head comparison against alternative tools.docs/search-tools-comparison.mdβ loctree vs grep / ripgrep / ast-grep β when each one wins.- /evidence β live transcripts and artifacts from real repositories.
RESOURCES
Resources
CHANGELOG.mdβ release history.CONTRIBUTING.mdβ how to contribute, dev setup, release process.- github.com/Loctree/loctree-ast β source, issues, releases.
- docs.rs/loctree β live API documentation (canonical).
- crates.io/crates/loctree β published crate.