
Correctness And Error Handling
Systematically find and fix correctness gaps, async failures, and missing loading or empty UI states in a Cognite Flows app.
Install
npx skills add https://github.com/cognitedata/builder-skills --skill correctness-and-error-handlingWhat is this skill?
- MUST-run workflow for Flows apps: find defects and fix in place, not report-only
- Step 1 maps async flows from main/App, hooks, contexts, and CDF api/services call sites
- Covers network/CDF 403/timeouts, loading UI, empty results, and known defect fixes
- Allowed agent tools: Read, Glob, Grep, Shell, Write for whole-app or scoped directories
- Triggers on correctness, unhandled rejections, error boundaries, useEffect cleanup, and type guards
Adoption & trust: 1k installs on skills.sh; 4 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Journey fit
Canonical shelf is Ship because the skill hardens the app against runtime and async failures before release, even though edits touch build-time source files. Testing subphase fits a fix pass over data flows, error boundaries, and UI states—not greenfield feature work.
Common Questions / FAQ
Is Correctness And Error Handling safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Correctness And Error Handling
# Correctness & Error Handling Fix Find and fix correctness issues and missing error handling in **$ARGUMENTS** (or the whole app if no argument is given). Work through every step below. Each step searches for problems and then **fixes them in place**. Only report issues that cannot be auto-fixed. --- ## Step 1 — Map data flows and fix known defects Read these files before checking anything: - `src/main.tsx` / `src/App.tsx` — top-level error boundaries and auth flow - All files matching `**/hooks/*.ts`, `**/contexts/*.tsx` — shared async state - All files matching `**/api/*.ts`, `**/services/*.ts` — CDF SDK call sites For each async data source, note: - What happens when the request fails (network error, CDF 403, timeout)? - What does the UI show while loading? - What does the UI show if the result is empty? ### Find and fix known defects in critical paths ```bash # Find TODO/FIXME/HACK in critical code paths (not test files) grep -rn --include="*.ts" --include="*.tsx" -E "(TODO|FIXME|HACK|XXX):" src/ | grep -v ".test." | grep -v ".spec." # Find "fix" or "broken" or "workaround" markers grep -rn --include="*.ts" --include="*.tsx" -i -E "(TODO.*fix|workaround|broken|known.?bug|temporary.?hack)" src/ ``` For each match in a critical path (data fetching, rendering, auth, navigation): 1. **Read the surrounding code** to understand the incomplete/broken behavior. 2. **Fix the underlying issue** — implement the missing logic, correct the broken behavior, or add proper error handling. 3. If the fix requires significant architectural changes beyond this skill's scope, **replace the TODO with a safe failure mode**: graceful error handling, a sensible fallback value, or an explicit user-facing message explaining degraded functionality. 4. **Remove the TODO/FIXME/HACK comment** after fixing. The code should speak for itself. Do not leave TODOs in critical paths. Every one must be resolved or converted to a safe fallback. --- ## Step 2 — Add top-level error boundary Every Flows app must have at least one React Error Boundary wrapping the main content so that an unexpected render-time exception shows a user-friendly message instead of a blank screen. ```bash grep -rn --include="*.tsx" --include="*.ts" -E "ErrorBoundary|componentDidCatch|getDerivedStateFromError" src/ ``` If no error boundary exists, **create the ErrorFallback component and add the ErrorBoundary wrapper** to `App.tsx`. Install `react-error-boundary` if not present: ```bash pnpm add react-error-boundary ``` Then add to `App.tsx`: ```tsx import { ErrorBoundary } from "react-error-boundary"; function ErrorFallback({ error }: { error: Error }) { return ( <div role="alert" className="p-8 text-center"> <p className="text-lg font-semibold">Something went wrong</p> <pre className="mt-2 text-sm text-muted-foreground">{error.message}</pre> </div> ); } // Wrap the main content: <ErrorBoundary FallbackComponent={ErrorFallback}> <MainContent /> </ErrorBoundary> ``` Write the updated `App.tsx` with the ErrorBoundary in place. Do not just suggest it — make the edit. --- ## Step 3 — Wrap unhandled async functions in try/catch Search for every `async` function and `Promise` chain that does not have error handling: ```bash # Find async functions grep -rn --include="*.ts" --include="*.tsx" -E "async\s+function|async\s