gestalt
Query code intelligence with gestalt. Use when finding callers/callees, tracing references, running CozoScript queries, or generating repo maps.
What this skill does
# gestalt
Rust binary, embedded CozoDB, tree-sitter indexing with optional SCIP overlay. Supports Rust, Python, Go, TypeScript/JavaScript. Auto-indexes on first run.
## Auto-Detect Rules
Parse `$ARGUMENTS` in order:
| Pattern | Route | Action |
|---|---|---|
| `review [target]` | Structural review | Read and follow `operations/review.md` |
| No argument / other | Query mode | Continue with gestalt commands below |
## Subagent orientation
All subagents (implementers, testers, reviewers) should orient before starting work:
```bash
gestalt map # Where do I look?
gestalt analyze # What are the hotspots, seams, coupling?
```
Then use `callers`/`callees`/`refs` to drill into specific symbols as needed.
## map vs analyze
| | `gestalt map` | `gestalt analyze` |
|---|---|---|
| Purpose | Navigation | Understanding |
| Question | "Where do I look?" | "Why is it structured this way?" |
| Audience | Agents, quick orientation | Humans refactoring, debugging architecture |
| Output | Module signatures with symbols | Cluster metrics, seams, hotspots, coupling |
### map — the territory
```bash
gestalt map src/ # Enriched map (auto-indexes)
gestalt map src/ --tokens 512 # Token budget
gestalt map --top 20 # Top-20 ranked symbols
gestalt map --verbose # Per-cluster detail
```
```
∴ clusters(5): ...
∴ depth(4): ⊤ command_cache_migration → ... → tags ⊥
∴ bridges(5): extract_tags → ...
∴ fan-in(3): ...
∴ fan-out(3): ...
./src/tree/parser.rs:
72│pub fn parse ...
```
Feed to an agent or skim when starting work.
### analyze — why the territory looks that way
```bash
gestalt analyze # Full analysis
gestalt analyze --top 50 # More symbols
gestalt analyze --file src/db.rs # Single file
gestalt analyze --kind function # Filter by kind
gestalt analyze --format json # Machine-readable
gestalt analyze --no-clusters # Hide clusters
gestalt analyze --no-cycles # Hide cycles
gestalt analyze --no-entry-points # Hide entry points
```
```
∴ hotspots(5): find_project_root (↑21 ↓2), ...
∴ seams(4): extract (3 clusters), fingerprint (2 clusters), ...
∴ links(1): [fingerprint, locking, manifest] → [fingerprint, project] (1 refs)
∴ graph: 417 nodes, 723 edges, 13 clusters, density 0.004
∴ singletons(6): ...
[extract, parser] (rank: 0.0474, size: 2, coupling: 0.08) †extract
./src/tree/parser.rs:
72 │ function parse ↑38 ↓1
```
Study when the graph reveals a problem — refactoring targets, coupling hotspots, architectural seams.
## Diff and history
```bash
gestalt diff <base> [target] # Definition-level changes between revisions
gestalt diff main..HEAD # Changed symbols with impact markers
gestalt diff main..HEAD --format json # Machine-readable change set
gestalt diff main..HEAD --verbose # Impact propagation layers
gestalt diff main..HEAD --depth 3 # Custom impact depth (implies --verbose)
gestalt diff main..HEAD --include-tests # Include test symbols
gestalt blame <symbol> # Git blame for symbol's definition
gestalt blame <symbol> --format json # Machine-readable
gestalt log <symbol> # Git log for symbol's line range
gestalt log <symbol> --limit 5 # Limit entries
gestalt log <symbol> --format json # Machine-readable
```
Output markers for diff:
- `↑N` — N sites reference this symbol
- `⊤ root` — entry point: calls others, not called by others
- `⊥ leaf` — foundation: called by others, calls nothing
- `⇔` — bridge: high betweenness centrality
## Structural review
Gestalt provides enough structural data to drive a review protocol — see [operations/review.md](operations/review.md).
The protocol uses `gestalt diff --format json` for triage, `callers`/`callees`/`blame`/`log` for deep investigation, and `analyze`/`rank` for structural context. The agent identifies where to look and generates targeted questions; the human provides semantic judgment.
## Call graph
```bash
gestalt callers <symbol> # Who calls this?
gestalt callers parse # → parse [function] src/tree/parser.rs:78
gestalt callers helper --file src/db.rs # Filter to file
gestalt callees <symbol> # What does this call?
gestalt callees mtime_hash # → collect_entries [function] src/mtime.rs:44
gestalt refs <symbol> # All references with location
gestalt refs Config # → src/main.rs:42:10 (from: run_command)
```
Output format:
- `callers`/`callees`: `name [kind] file:line`
- `refs`: `file:line:col (from: symbol_name)` or `(top-level)`
## Other commands
| Command | Purpose |
|---------|---------|
| `gestalt rank` | Rank symbols by PageRank + degree centrality |
| `gestalt rank --format tree` | Same ranking, tree output |
| `gestalt rank --file src/db.rs --kind function` | Filter by file/kind |
| `gestalt index [paths]` | Index with tree-sitter |
| `gestalt index src/ --scip index.scip` | Index + SCIP overlay |
| `gestalt query '<datalog>'` | Raw CozoScript query |
| `gestalt cache list` | Show indexed projects |
| `gestalt cache clear` | Delete all cache |
| `gestalt cache prune` | Remove stale entries |
## Output markers
| Marker | Meaning |
|--------|---------|
| `↑N ↓M` | In-degree / out-degree |
| `⇔` | Bridge node (top-10% betweenness centrality) |
| `⇄` | Cycle member (SCC with >1 symbol) |
| `†stem` | Seam (file stem appears in multiple clusters) |
## SCIP overlay
Precise cross-crate references. Generate the index, then overlay:
```bash
gestalt index src/ --scip index.scip
```
| Language | Indexer | Install |
|----------|---------|---------|
| Rust | rust-analyzer | `rustup component add rust-analyzer` |
| Go | scip-go | `go install github.com/sourcegraph/scip-go/cmd/scip-go@latest` |
| Python | scip-python | `npm i -g @sourcegraph/scip-python` |
| TypeScript | scip-typescript | `npm i -g @sourcegraph/scip-typescript` |
## CozoScript queries
[CozoScript](https://docs.cozodb.org/en/latest/queries.html) (Datalog dialect). Tables: `symbol`, `reference`.
**symbol**: `scip_symbol`, `name`, `kind`, `file`, `line`, `end_line`, `col`, `end_col`, `is_external`
**reference**: `from_symbol`, `to_symbol`, `file`, `line`, `col`
```bash
# Schema introspection
gestalt query '::relations' # List tables
gestalt query '::columns symbol' # Columns for a table
# Functions in a file
gestalt query '?[name, line] := *symbol{name, kind, file, line}, kind = "function", file = "src/main.rs"'
# Call graph
gestalt query '?[caller, callee] := *reference{from_symbol: cs, to_symbol: cs2}, *symbol{scip_symbol: cs, name: caller}, *symbol{scip_symbol: cs2, name: callee}'
# Unused functions
gestalt query '
called[sym] := *reference{to_symbol: sym}
?[name, file, line] := *symbol{scip_symbol: sym, name, kind, file, line}, kind = "function", not called[sym]
'
```
## Troubleshooting
- **Empty results**: Run `gestalt index .` or `gestalt map` to populate the database.
- **Stale data**: `gestalt cache clear` then re-index.
- **Query syntax**: [CozoScript docs](https://docs.cozodb.org/en/latest/queries.html).
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.