Query Context
Context Nest gives you two ways to pull from your vault: ctx resolve for a metadata list of matches, and ctx query for full, graph-aware context retrieval.
Selectors
Both commands take a selector. The selector grammar:
| Form | Matches |
|---|---|
#tag (or tag:#tag) |
Documents carrying a tag |
type:X |
Documents of a node type |
[[Title]] |
A document by title |
scope:X |
Documents in a visibility scope |
Combine selectors with these operators:
| Operator | Meaning |
|---|---|
+ |
AND (intersection) |
| |
OR (union) |
- |
NOT (exclude) |
ctx resolve "#engineering" # documents with a tag
ctx resolve "type:document +status:published" # intersection
ctx resolve "#api |#v2" # union
ctx resolve "#api -#deprecated" # exclude
Note: the operators are
+,|,-. The&operator used in older docs is no longer valid —ctxrejects it withINVALID_SELECTOR.
Resolve (metadata)
ctx resolve "#engineering"
Returns a list of matching documents with their ids, types, and status — no bodies.
Query (full context)
ctx query "#engineering" # all docs with a tag
ctx query "type:document" # all docs of a type
ctx query "pack:engineering-essentials" # all docs in a pack
ctx query "#api +status:published" # intersection
ctx query "#api |#v2" # union
Returns the full document content in hydration order plus trace entries.
Published-only by default
ctx query returns published documents only by default. To include drafts (for example while authoring), add --include-drafts:
ctx query "#engineering" # published only
ctx query "#engineering" --include-drafts # published + drafts
Graph traversal (--hops)
ctx query is graph-aware: from the matched nodes it follows links outward to pull in the surrounding neighborhood. Control the depth with --hops (default: 2). Use --hops 0 for just the matches, 1 for matches + direct links, higher to reach further:
ctx query "[[API Design Guide]]" --hops 1 # the doc + its direct links
ctx query "#engineering" --hops 0 # just the matches, no traversal
Add --full to force full-load mode (load all documents rather than graph-walking), and --json for machine-readable output.
Cloud packs (coming soon)
Cloud packs will allow querying context from hosted packs without downloading source files:
ctx query @promptowl/executive-ai-strategy
See Cloud Packs for the planned design.
JSON output
All query commands support --json for programmatic consumption:
ctx query "pack:engineering-essentials" --json
Search
Full-text search across all vault documents (separate from selector queries):
ctx search "rate limiting"
ctx search "rate limiting" --limit 5 --json
Related pages
- Quick StartGet a Context Nest vault running in under 2 minutes. By the end, you'll have a versioned, queryable knowledge vault that any AI agent can read.
- Create a VaultStarter recipes scaffold a vault with documents, packs, and agent instructions tailored to a role:
- Install the ctx CLIThe package installs with a flattened dependency tree — its runtime dependencies are bundled/flattened so a global install pulls a self-contained CLI…
- Cloud PacksCloud packs will be hosted on the PromptOwl platform and queryable without downloading source files.
- Add DocumentsThis creates nodes/api-design.md from a frontmatter template as version 1, and regenerates the index. Tags accept a comma- or space-separated list; you…