Back to Skills

performance

MUST be used whenever fixing performance issues in a Flows app. This skill finds AND fixes performance problems — re-renders, inefficient queries, missing pagination, unbounded fetches, large bundles, and memory leaks. It does not just report them. Always measure before and after. Triggers: performance, slow, laggy, optimize, re-render, bundle size, load time, CDF query, large list, memory leak, debounce, virtualize, lazy load, code split.

5stars1forksUpdated 6/29/2026

Security Assessment

Safe(100/100)
Security Score100/100

About performance

A performance remediation workflow for Cognite Flows apps that systematically finds and fixes slowdowns rather than only reporting them, covering unnecessary re-renders, inefficient queries, missing pagination, unbounded fetches, large bundles, and memory leaks. A core principle is to always measure before and after: the first step runs the production build and preview, then captures a Lighthouse score and a React Profiler recording, noting components with the longest render times and highest render counts so that every later fix can be checked against these baseline numbers. An optional argument scopes the work to a specific file, component, or area; otherwise the whole app is examined.

Subsequent steps each pair a search with a direct fix. Re-render issues are addressed by wrapping inline objects and arrays with useMemo, wrapping event handlers with useCallback, memoizing context provider values, and applying React.memo only to components confirmed to re-render unnecessarily via the Profiler. For Cognite Data Modeling access, read-heavy paths that populate tables, dropdowns, or search results are steered toward the search/Elasticsearch path by rewriting instances.list calls to instances.query (or instances.search for full-text), while list is retained for writing, syncing, or semantics unavailable on query. A decision table clarifies when query, search, list, retrieve, and aggregate are each appropriate.

The workflow then moves client-side work to the server: any .filter() applied to a full result set after an SDK call is rewritten so the criterion lives in the API request's filter parameter, with a hard rule that if the API supports the filter, it should move server-side immediately, leaving a code comment only where it genuinely cannot. Property projections and explicit limits are added so only displayed fields and rows are fetched, client-side text search is replaced with the SDK's search endpoint, and pagination is fixed by adding limits, batching sequential requests into Promise.all, and moving fetches into useQuery or useMemo with stable dependency arrays. For deeper rationale on search-versus-relational paths and materialization tradeoffs, it points to a semantic-knowledge directory if present in the workspace.

FAQ

Does this skill measure performance before making changes?

Yes. The first step runs the production build and preview, then captures a Lighthouse score and a React Profiler recording as a baseline. Every fix is meant to be measured against these numbers, never optimized blindly.

How does it reduce unnecessary React re-renders?

It wraps inline objects and arrays with useMemo, event handlers with useCallback, and context values with useMemo, and applies React.memo to pure presentational components, but only to ones confirmed to re-render unnecessarily via the Profiler.

When should instances.list be rewritten to instances.query?

When list is used in a read-heavy UI path such as populating a table, dropdown, or search results, since list stresses Postgres while query hits the Elasticsearch path. List is kept for writing, syncing, or semantics not available on query or search.

How does it handle client-side filtering of fetched data?

It moves the filter into the SDK call's filter parameter and removes the .filter() call. The hard rule is that if the API supports the filter, it moves server-side immediately; a code comment is added only when the API genuinely cannot express it.

What does it do about missing pagination or unbounded fetches?

It adds explicit limits matching the UI page size, adds a properties selection to fetch only needed fields, moves fetches into useQuery or useMemo with stable dependencies, and rewrites sequential requests into Promise.all where they can run in parallel.

Install performance

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill