tsq
Use tsq to extract structured code information with tree-sitter queries, symbols, outlines, and references across languages.
What this skill does
## Purpose
Use this skill when you need structured, language-aware insight into code: declarations, references, outlines, and precise AST pattern matches. tsq is best for targeted extraction and analysis that would be noisy with text search.
## When to use what
- `tsq query`: Use for custom AST patterns and precise structural matching. Best when you need specific constructs or relationships in the syntax tree.
- `tsq symbols`: Use to catalog declarations (functions, types, methods, variables) across files for indexing or summaries.
- `tsq outline`: Use to get a high-level file structure (package/module, imports, top-level symbols) when you need quick orientation.
- `tsq refs`: Use to find usages of a symbol across a codebase.
- `tsq example-queries`: Use only to discover query syntax and patterns. It is a reference, not a required step.
## Core concepts
- Tree-sitter queries use capture names (e.g., `@name`) to extract data. Queries without captures return matches with no usable payload.
- Use `--file` for a single file, `--path` to scan a directory.
- Prefer `symbols` or `outline` when you do not need a custom query.
## Recommended workflow
1. Start with `outline` for a quick map of a file.
2. Use `symbols` to gather relevant declarations.
3. Use `refs` to trace usage.
4. Use `query` for precise AST patterns or advanced filtering.
## Minimal cross-language examples
These patterns are representative; adjust node types and names for the target language grammar.
```scm
; Function declarations (capture the whole node)
(function_declaration) @fn
; Function names only
(function_declaration name: (identifier) @name)
; Method calls (object.method())
(call_expression
function: (selector_expression
operand: (_) @receiver
field: (field_identifier) @method))
; Type definitions (struct/class-like)
(type_declaration
(type_spec
name: (type_identifier) @name
type: (_) @type_def))
; Imports (module paths)
(import_spec path: (interpreted_string_literal) @path)
```
# JSON output schemas
Tip: pipe `tsq ...` output into `jq` to extract exactly what you need, e.g.
`tsq symbols --path . --compact | jq '.[].symbols[] | select(.kind=="function") | .name'`
## `tsq query` -> `[]QueryMatch`
```json
[
{
"file": "path/to/file.go",
"pattern": 0,
"captures": [
{
"name": "name",
"node_type": "identifier",
"text": "Foo",
"range": {
"start": { "line": 12, "column": 6 },
"end": { "line": 12, "column": 9 }
}
}
]
}
]
```
## `tsq symbols` -> `[]SymbolsResult`
```json
[
{
"file": "path/to/file.go",
"symbols": [
{
"name": "Foo",
"kind": "function|type|method|var|const|interface|struct|field",
"visibility": "public|private",
"file": "path/to/file.go",
"range": {
"start": { "line": 12, "column": 1 },
"end": { "line": 20, "column": 2 }
},
"signature": "func Foo(...) ...",
"source": "func Foo() { ... }",
"receiver": "MyType",
"doc": "Doc comment text"
}
]
}
]
```
## `tsq outline` -> `FileOutline`
```json
{
"file": "path/to/file.go",
"package": "main",
"imports": [{ "path": "fmt", "alias": "f" }],
"symbols": [
{
"name": "Foo",
"kind": "function|method|struct|interface|type|const|var",
"visibility": "public|private",
"file": "path/to/file.go",
"range": {
"start": { "line": 12, "column": 1 },
"end": { "line": 20, "column": 2 }
},
"source": "func Foo() { ... }",
"receiver": "MyType"
}
]
}
```
## `tsq refs` -> `RefsResult`
```json
{
"symbol": "Foo",
"references": [
{
"symbol": "Foo",
"kind": "call|type_ref|field_access|identifier|reference",
"file": "path/to/file.go",
"position": { "line": 42, "column": 7 },
"context": "Foo()"
}
]
}
```
## Errors (stderr)
```json
{ "error": "message" }
```
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.