tld watch
View MarkdownThis is the big one. tld watch connects your source code directly to your architecture diagrams and keeps them in sync.
It’s a three-stage pipeline: scan → represent → watch. It runs locally and offline.
tld watchWhat it does
Section titled “What it does”When you run tld watch, four things happen in sequence:
- It scans your codebase, parsing source files with Tree-sitter, extracting symbols (classes, functions, modules) and their references
- It filters and represents, applying thresholds and visibility rules to turn raw symbols into clean architecture elements
- It launches the local web app, so you can see your diagrams immediately
- It watches for changes, any file you modify gets rescanned, and diagrams update in real time
- If you git commit your changes, the diagram state is committed too, and your tld workspace will get cleaned like your git worktree.
You get a live, code-driven architecture map. Right on your machine. As you or your agent codes.
Basic usage
Section titled “Basic usage”# Watch the current directorytld watch .# Watch a specific pathtld watch ./src
# Open the web app in your browser automaticallytld watch --openWhen watch starts, you’ll see something like:
tld v2.0.0──────────────────────────────────── Watching /Users/you/project Repository github.com/org/project Branch main HEAD abc123def tlDiagram available at http://127.0.0.1:8060──────────────────────────────────── Press Ctrl-C to stop watching.Then, as you save files:
source modified src/services/auth.go: representation updated elements +2 ~1, connectors +3 ~0, views +1, tags +0-0Embedding support
Section titled “Embedding support”Vector embeddings group related components semantically. Two services that work together conceptually end up near each other in the diagram, even if they live in different directories.
tld watch --embedding-provider openai --embedding-model text-embedding-3-smallAny OpenAI-compatible endpoint works:
tld watch --embedding-provider openai \ --embedding-endpoint https://my-llm.internal/v1 \ --embedding-model custom-model \ --embedding-dimension 768The CLI verifies the embedding provider’s health on startup. If it can’t reach the endpoint, it fails early with a clear error.
To disable embeddings: either set the provider to none, or just don’t pass any embedding flags at all. They’re off by default.
Thresholds and noise control
Section titled “Thresholds and noise control”Dense codebases produce dense symbol graphs. A single utility file imported by 100 components shouldn’t pollute your diagram. Thresholds give you control.
tld watch \ --max-elements-per-view 30 \ --max-connectors-per-view 60 \ --max-incoming-per-element 10 \ --max-outgoing-per-element 10Each threshold caps how much detail gets expanded before collapsing into a group. Read more in the configuration guide.
Watcher backends
Section titled “Watcher backends”# Auto-detect (default, works great on macOS and Linux)tld watch
# Force fsnotify (event-based, low CPU)tld watch --watcher fsnotify
# Force polling (for network drives, Docker volumes, etc.)tld watch --watcher poll --poll-interval 2sThe auto mode picks fsnotify on platforms that support it, falling back to polling. You usually don’t need to think about this.
Watcher vs analyze
Section titled “Watcher vs analyze”Both tld watch and tld analyze scan source code. They serve different purposes:
tld analyzeone-shot scan, writes directly to your workspace YAML files. Build-focused workflow.tld watchcontinuous pipeline, writes to a local SQLite database. Shows results in the local web app. Live-development workflow.
Which one should you use? If you’re actively coding and want to see how changes impact architecture, use tld watch. If you’re preparing diagrams for a release or a review, use tld analyze → tld plan → tld apply.
They can coexist. You can tld analyze your codebase, push to the cloud, and also keep tld watch running locally for exploration.
The —rescan flag
Section titled “The —rescan flag”Watch caches parsed files for speed. Only modified files get rescanned. If you want to force a full rescan from scratch:
tld watch --rescanThis clears all cached parse results and rebuilds everything. Useful if you’ve changed thresholds, changed embedding models, or suspect stale data.
What happens under the hood
Section titled “What happens under the hood”The pipeline has three distinct phases, all happening locally:
Phase 1: Scan: Tree-sitter parses every source file. It extracts named symbols (functions, classes, structs, interfaces) and reference edges (imports, calls, type references). Results go into a local SQLite database keyed by git commit hash. Incremental, only changed files get rescanned.
Phase 2: Filter & Represent: The raw symbol graph is massive. Filters remove noise: test files, generated code, vendored dependencies (controlled by your exclude patterns). Thresholds collapse high-degree connections. Visibility scores determine what’s important enough to show. The output is clean architecture elements and connectors.
Phase 3: Watch: A file watcher monitors your source tree. When files change, they’re rescanned. The delta between the old and new representation is computed. Changes are pushed to the local web app via WebSocket, updating diagrams in real time for any connected browser.
All of this runs locally. Nothing gets sent to the cloud unless you explicitly tld apply.