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 โ source, issues, releases.
- docs.rs/loctree โ live API documentation (canonical).
- crates.io/crates/loctree โ published crate.