| name | cognite-dms-queries |
| description | Search-first, production-safe query patterns for Cognite DMS (Data Modeling Service), including pagination, traversal, retries, and anti-pattern avoidance. |
Cognite DMS Queries Skill
Use this skill when creating or reviewing queries against CDF DMS.
Primary Goal
Produce queries that are:
- Correct.
- Efficient at scale.
- Easy to reason about and maintain.
This skill is opinionated and search-first.
Core Principles
-
Search first, traverse second
- Use
instances.search(...) to find/rank anchors.
- Then hydrate related data with
Query traversal or relation-aware filters.
-
Constrain early
- Always scope with
space and/or hard filters (sourceContext, subtree Prefix, etc.) whenever possible.
- Avoid broad cross-space scans unless explicitly needed for discovery.
-
Paginate explicitly
- Use cursor pagination (
/sync style) or chunked iterators.
- Prefer fixed page sizes (for example 500-1000) over large one-shot reads.
-
Fetch only what you need
- In
select, request explicit property lists.
- Avoid wildcard projection (
"*").
-
Operational resilience
- Retry transient failures (408/425/429/5xx) with bounded exponential backoff + jitter.
- Keep query payloads and per-page limits moderate to reduce timeout risk.
Recommended Query Flow
Follow this order by default:
- Search basics (name-only scoring).
- Constrained search (
query + hard filters).
- Top-K hydrate pattern.
- Fallback strategy (strict -> broad).
- Prefix-based subtree retrieval.
- Graph traversals via
Query.
- Cursor pagination for full retrieval.
Anti-patterns (do not generate unless explicitly requested)
limit=-1 one-shot reads for large datasets.
properties=["*"] in production retrieval paths.
- Broad
instances.list(...) without space in production paths.
- N+1 loops (querying related entities one by one in Python).
- Client-side filtering when server-side filters can do the job.
- Missing retry handling for transient API failures.
- Mixed verbose/raw dumps (
print(res) / full object dumps) for large responses.
- Raw HTTP payload posts when SDK APIs provide equivalent capability and retries.
Output and Style Requirements
When providing query examples:
- Include a short purpose statement.
- Prefer compact output helpers:
- print count
- print first N rows (
N=10) with externalId, name, description (plus optional extra fields)
- print overflow indicator (
... and N more)
- Use discovery-first where practical (derive real token/value before applying strict filters).
Reference
Use the canonical examples in:
references/cdf-dms-queries.md