一键导入
tensor-grep
Use tensor-grep for repository code search, symbol lookup, blast-radius analysis, and edit planning when solving codebase tasks or preparing patches.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use tensor-grep for repository code search, symbol lookup, blast-radius analysis, and edit planning when solving codebase tasks or preparing patches.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when searching code, logs, or repositories with tensor-grep; validating rg or AST parity; using tg MCP tools; checking GPU/search routing; or producing agent-friendly context, source, refs, or blast-radius output.
Use when you need the domain theory behind tensor-grep's search/retrieval behavior, not just the command syntax — ripgrep exit codes (including the exit-2-but-kept partial-results contract)/PCRE2/binary-NUL-detection/-uuu/-- sentinels, ast-grep + tree-sitter routing, BM25 vs the flat no-IDF capsule scorer, PageRank vs in-degree centrality, the trigram index, PyO3 + the GIL, MCP argv surface, LSP 3.17 framing, and Model2Vec/potion-code (SHIPPED as `tg search --semantic`). Load before explaining WHY tg behaves a certain way, reasoning about the protocol/algorithm THEORY underneath a backend/router change (exit-code semantics, scoring math, wire framing), or writing docs that touch these subsystems — for the invariants a backend/router change must not break, use `tensor-grep-architecture-contract` instead (or in addition). Not a how-to-run or how-to-debug guide — see the sibling table below for those.
Use when you need the load-bearing design of tensor-grep and WHY it holds before touching cli/bootstrap.py, rust_core/src/main.rs, backends/, core/result.py, cli/main.py's native-delegation gate, routing, the agent capsule, or before reviewing/planning any change to the front door, command/flag registration, or backend contract. Explains the bootstrap intercept-before-Typer front door, native-vs-Python routing, the 4 command + 2 flag registration sites, the Backend Fail-Closed Contract, the native-delegation forward-or-refuse contract (`_can_delegate_to_native_tg_search` + its field-coverage ratchet), the partial-results `result_incomplete`/`incomplete_reason` envelope, `MatchLine`'s frozen-but-hashable dataclass contract, the ASCII-only CLI output rule, the agent-context moat, the invariants that must hold, and the known-weak points (flat no-IDF scorer, GPU not viable, rg parity gap, FFI not the dir-scan speed path). Read this to build the right mental model; use sibling skills for the how-to of changing, de
Use when asked to deep-dive, audit, fix, or drain tensor-grep backlog — OR investigate/rank next work and produce SPEC/TDD plans (docs/plans/requirements|design|tasks-*.md) without implementing. Triggers: "work the backlog", "what next", "investigate and plan", backlog-completion campaign. META-ORCHESTRATOR — 20-skill library. Semantic-search flagship: tensor-grep-semantic-search-campaign. Scale/hang campaign: tensor-grep-large-repo-scale-campaign. Load tensor-grep-change-control before edit.
Use when about to claim, review, or dispute a speedup/regression in tensor-grep (tg vs rg, hot-cache, AST, agent-workflow, or GPU changes) — which benchmark script to run, how to read check_regression.py, the noise-floor/absolute-jitter rule for sub-10ms rows, the fair-baseline rule (never compare tg against a strawman comparator), and the launcher-attribution rules (tg_launcher_mode, tg_launcher_command_kind, stale-binary refusal) that make a benchmark artifact claim-quality instead of noise.
Use when setting up the tensor-grep dev environment from a fresh clone, rebuilding the Rust/PyO3 extension or standalone `tg` binary after touching `rust_core/`, or debugging a build/toolchain problem — uv install, `maturin develop`, `cargo build`, the pinned 1.96.0 Rust toolchain, Python >=3.11 floor, a "hanging" cargo build, cargo/rustc missing from PATH, ruff CRLF false-alarms, or a dependency upper-cap silently downgrading tensor-grep on a newer Python. Gives exact copy-paste setup commands and the traps that have each cost a real cycle.
| name | tensor-grep |
| description | Use tensor-grep for repository code search, symbol lookup, blast-radius analysis, and edit planning when solving codebase tasks or preparing patches. |
Use this skill when you need to locate code precisely, understand likely edit impact, or prepare a minimal patch in a real repository.
tg find "QUERY" [PATH] (experimental): whole-repo hybrid BM25 + dense-embedding ranking, no pattern pre-filter required.tg session to cache the repo-map, then call session-scoped commands (tg session context-render, tg session edit-plan, tg session blast-radius-render) without re-indexing on each invocation.All symbol commands are path-first: tg <command> <REPO_PATH> <SYMBOL>.
A reversed <SYMBOL> <REPO_PATH> call is auto-corrected with a stderr hint, and
a single tg <command> <SYMBOL> resolves against the current directory — but
prefer the canonical path-first form.
tg --versiontg orient REPO_PATHtg inventory REPO_PATH --jsontg imports FILE / tg importers FILE [ROOT] — absolute pathstg search PATTERN REPO_PATH --rank--glob / --type / --max-depth) or --allow-broad-generated-scantg source REPO_PATH/src SYMBOLtg find "natural language query" REPO_PATH (experimental) ranks the whole repo by BM25 + dense relevance instead of requiring a regex match at all. result_incomplete: true + exit 2 means the scan/ranking covered only PART of the repo (raise --max-repo-files / --deadline); a missing rank_fallback_reason means the dense leg ran, present means it degraded to BM25-only (still a legitimate result, just lexical-only).src/ for complete callers (root often returns partial):
tg callers REPO_PATH/src SYMBOL --deadline 15 --jsontg defs / tg refs / tg blast-radius similarlysrc/ for latency on v1.71.1 (whole-repo tg agent is ~26s NATIVE, exit 0; the 75s figure is a WSL /mnt/c 9p artifact, not a regression):
tg agent REPO_PATH/src "task" --json # ~24s PASStg agent REPO_PATH "task" on large trees until root latency is stable
5b. Evidence receipt:tg evidence emit REPO_PATH --capsule capsule.json --query "task" --json --agent-id AGENT
5c. Optional browsable map (still slow — do not block agent loops):tg codemap REPO_PATH --out /tmp/code-map --jsontg session open --json REPO_PATH then session-scoped commands.When you add an entity that must be registered in multiple places (a command, a flag, a route, a hook), enumerate ALL its registration sites BEFORE claiming the change is done — missing one fails quietly. The default audit path:
tg callers PATH SYMBOL --json lists every call site (file:line). On a real billing repo it surfaced 2 webhook handlers + 1 reconcile cron in ~1s — a 10-minute grep-and-read became a one-second decision.
When the JSON has "result_incomplete": true, the call-site list was TRUNCATED by a scan/output cap — treat coverage as partial; do not conclude unlisted sites are safe. Human mode emits a loud stderr caveat.tg scan PATH --ruleset RULESET runs a built-in security/compliance rule pack across those sites (see tg rulesets for pack names). --config sgconfig.yml and --rule FILE are separate options for a custom ast-grep config or a single rule file — not for built-in packs.tg doctor --with-lsp.For registration-completeness specifically: tg callers PATH REGISTRATION_FUNCTION lists callable registrations — but the call graph can't see set/list/decorator registrations (allow-lists, @router.post, dispatch tables), which are often the missed site, so grep / tg scan those too. Your new entry must appear in ALL sites. (General principle: verify-plan-against-code Hard Rule 6; call-graph blind spots: tensor-grep-code-audit P7.)
A resolved zero-caller result is NOT dead code either — the call graph can't see set/list/decorator/dispatch-table registrations; cross-check with tg scan or grep before removing a zero-caller symbol. As of v1.17.1 the registration-completeness checker (extract_members) is string/comment-aware, so #-commented entries are no longer surfaced as false members.
claude -p or other non-interactive automation, do not ask for confirmation.tg against the repository path that was added via --add-dir.tg identifies the likely file/span, make the change directly instead of stopping at analysis.git-style unified diff only.tg over repeated manual grep loops when working inside a real repository.tg orient REPO_PATH first when entering an unfamiliar repo — it gives centrality, entry points, and a symbol map in one call, and costs no API key or GPU.tg search PATTERN PATH --rank for content/text search; prefer it over raw grep loops when relevance ranking matters. The --bm25 flag is an alias for --rank.tg ranks highest.tg already identified the primary file and span.Unscoped / multi-project workspace search refuses fast (v1.71.1). tg search TODO from /mnt/c/dev/projects → exit 2 in ~1.1s with a clear safety-guard message (no more 60s hang). Scope with a project path, --glob, --type, --max-depth, or pass --allow-broad-generated-scan only when intentional.
Prefer REPO/src for complete callers (still true on v1.71.1). tg callers tensor-grep/src … --deadline 15 → complete (3 callers, ~6s). Same symbol on the repo root → exit 2 / partial: true with 0 callers. Prefer narrowed PATH for exhaustive graph answers.
Whole-repo tg agent is WSL-slow, NOT natively regressed on v1.71.1. Native whole-repo runs ~26s (tensor-grep, exit 0, valid capsule); the 75s WSL /mnt/c timeout is a 9p-latency artifact -- reproduce natively before calling it a regression. Prefer src/ (~24s) for latency in agent loops.
Large JS/TS trees can still hang agent. tg agent on agent-studio timed out at 60s in the v1.71.1 workspace sweep — narrow PATH further or raise budget only when needed.
Workspace tg orient . works (~53s on v1.71.1). Per-repo orient is faster (~24s).
tg codemap is agent-loop-safe since #153 (v1.71.0). Native: src ~15s, whole-repo ~41s (844 files), both partial=false complete; the default wall-clock deadline bounds it (returns partial=true, never hangs). The old "90s timeout" was WSL /mnt/c 9p amplification. Default --out is docs/code-map.
tg inventory --deadline returns a floor (workspace 525 files incomplete at 30s on v1.71.1). Prefer per-repo inventory without a tight deadline when totals must be trusted.
tg imports / tg importers: absolute paths; importers may be partial / empty under deadline even when reverse deps exist.
tg evidence emit: subcommand required; aggregates prior capsules (no re-scan unless --recompute).
tg classify: FILE_PATH only; default format already JSON (no --json flag).
tg checkpoint create: scope to src/ on large trees.
tg scan works again on WSL (v1.71.1) for built-in rulesets (~1.4s PASS), but may warn about unreadable Windows-style paths under the Linux mount (os error 3). Treat findings as best-effort when those warnings appear; doctor available: true is still not a perfect runnable proof across shims.
nativetg defs REPO_PATH SYMBOL --provider lsptg blast-radius REPO_PATH SYMBOL --provider hybridUse lsp or hybrid only if native lookup seems ambiguous or incomplete.
git-style unified diff with diff --git headers and enough context lines to apply cleanly.See REFERENCE.md for current command patterns and examples.