dm-limits-and-best-practices
Reference skill for CDF Data Modeling API best practices. Covers concurrency limits (avoiding 429s), pagination patterns for instances.list and instances.query, batching write operations, search vs filter guidance, and the QueuedTaskRunner (Semaphore) utility for controlling concurrent requests. Triggers: DMS limits, 429 error, rate limit, pagination, cursor, nextCursor, batching, semaphore, QueuedTaskRunner, cdfTaskRunner, instances.search, instances.list, instances.query, instances.upsert, con
Security Assessment
About dm-limits-and-best-practices
A reference for applying Cognite Data Fusion Data Modeling (DMS) API best practices when writing or reviewing code that calls these APIs. It owns runtime reliability concerns such as concurrency limits, retries, throughput, and batching behavior, and defers graph-traversal payload correctness to a separate dm-graph-traversal skill. For exact, current limit numbers it points to the official Cognite documentation, while summarizing the key constraints to keep in mind: instance apply, delete, and query operations each have their own concurrent request limits, exceeding them returns HTTP 429, transformations consume much of the concurrency budget, instances.list has a max page size requiring pagination, instances.upsert accepts up to 1000 items per call, and in filters accept at most 1000 values per expression.
A significant section distinguishes search from filter. instances.search performs fuzzy free-text matching on string properties and supports an operator parameter, where AND (the default) narrows results so all terms must match and OR broadens them for exploratory or typeahead recall; search can also be combined with a filter for exact-match constraints. By contrast, instances.list and instances.query with a filter perform precise, deterministic matching (equals, range, in, hasData) with no fuzzy behavior. A decision table maps common needs to the right call: OR search for a search box, AND search to find a specific item by name, and filter on list or query for status, date-range, or enum constraints. For sets larger than 1000 IDs, a chunking pattern splits values into batches of 1000, issues requests in parallel through the task runner, and merges results.
The skill also documents a QueuedTaskRunner (semaphore) utility and advises always wrapping CDF API calls in a global cdfTaskRunner to bound concurrency and avoid 429s and deadlocks. If the project lacks a semaphore, it provides source for src/shared/utils/semaphore.ts: a generic QueuedTaskRunner class with a default of 15 concurrent tasks, a schedule method that queues tasks and supports a key option for deduplicating and aborting superseded tasks (throwing a provided AbortError), and an internal mechanism for consuming the next pending task as capacity frees up.
FAQ
What causes a 429 error and how does this skill help avoid it?
Exceeding the concurrent request limits on instance apply, delete, or query operations returns 429 Too Many Requests. The skill advises wrapping all CDF calls in the global cdfTaskRunner semaphore to bound concurrency and prevent 429s and deadlocks.
When should I use instances.search versus a filter?
Use instances.search for fuzzy free-text matching on string properties (with OR for broad typeahead and AND for narrow, all-terms-match queries), and use a filter on list or query for precise matching such as status, date ranges, or enums. Search and filter can also be combined.
How many values can an in filter take, and what if I have more?
An in filter accepts at most 1000 values per expression. For larger sets, the skill provides a chunking pattern that splits IDs into batches of 1000, issues requests in parallel via the task runner, and flattens the merged results.
What is the default concurrency of the QueuedTaskRunner?
The provided implementation uses a default of 15 maximum concurrent tasks (DEFAULT_MAX_CONCURRENT_TASKS), configurable through the constructor. It essentially acts as a semaphore allowing a limited number of tasks to run at once.
How many items can instances.upsert handle per call?
Up to 1000 items per call. The skill also notes that instances.list has a max page size requiring pagination and that query table expressions each have their own item limit.
Install dm-limits-and-best-practices
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
cognitedata/builder-skills