query is the JSON-native interface to the xspec requirement graph. Every subcommand emits JSON unconditionally — no --json flag is needed. Use query when you are writing scripts, CI tools, or editor integrations that need structured graph data.
Node vs graph-node
Two argument types appear acrossquery subcommands:
<node>— a workspace-relative spec reference:path#idfor a named node, or a barepathfor the file root node. Only spec nodes are valid here.<graph-node>— a superset of<node>that also accepts code locations:pathfor a file root,path#unitfor a named code unit, orpath#unit@Nfor a specific occurrence within a unit.
Subcommands
query node
Return the complete record for a single spec node.ownHash, subtreeHash, effectiveHash, metadataHash), tags, coverage attribute, and all incoming and outgoing edges grouped by kind.
query nodes
Return one row per node in the workspace, with optional filters.string
Restrict to nodes belonging to the named spec group. Accepts a spec group name only — not a file path.
glob
Restrict to nodes defined in files matching the given workspace-relative glob.
string
Restrict to nodes carrying the given tag.
string
Restrict by coverage attribute. Accepted values:
required, none.query edges
Return all edges in the graph, with optional filters.graph-node
Restrict to edges originating from this graph node.
graph-node
Restrict to edges terminating at this graph node.
string
Comma-separated list of edge kinds to include. Valid values:
contains, depends, embeds, references.from, to, and kind fields.
query subtree
Return the node and all of its descendants in document order.query ancestors
Return the proper ancestors of a node, nearest-first.query reachable
Determine whether one graph node can reach another through the edge graph, and return the shortest path if so.graph-node
required
The starting node for the reachability search.
graph-node
required
The target node.
string
Comma-separated edge kinds to traverse. Accepts only the three dependency kinds:
depends, embeds, references. contains edges are not traversable here.path array with the identity strings along the shortest path, and a reachable boolean. If reachable is false, the path array is empty.
Always-JSON behavior
Unlike other xspec commands,query never produces human-readable output. All subcommands emit JSON unconditionally — passing --json is valid but has no additional effect. Pipe the output directly into jq or any JSON-aware tool.