
Code Quality
Run mandated lint and TypeScript checks, then systematically review a Flows app (or a path/PR scope) for maintainability issues before you merge.
Install
npx skills add https://github.com/cognitedata/builder-skills --skill code-qualityWhat is this skill?
- Hard requirement: run `pnpm run lint` and `pnpm exec tsc --noEmit` before manual review—lint errors must be fixed; warni
- Stepwise manual audit: eliminate `any`, naming, dead code, duplication/DRY, single responsibility, component size, depen
- Scoped via argument-hint to a file, directory, or PR branch; defaults to whole app when no argument is given.
- Explicit anti-skip wording: do not skip linting steps when triggers like code review, refactor, maintainability, or tech
- Findings reported with concrete file paths and line numbers for agent-follow-up fixes.
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 is framed for PR-ready review and explicit code-quality gates—not optional polish after launch. Subphase review matches structured code review with file paths, line numbers, and severity-style findings after automated baselines.
Common Questions / FAQ
Is Code Quality 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 - Code Quality
# Code Quality Review Review **$ARGUMENTS** (or the whole app if no argument is given) for code quality issues. Work through every step below in order and report all findings with file paths and line numbers. --- ## Step 1 — Run the linter first Before reading any code manually, get a baseline from the automated tools: ```bash pnpm run lint ``` List every error and warning. Fix all errors before proceeding — lint errors are not negotiable. Warnings should be reviewed and resolved unless there is a documented exception. Also run the TypeScript compiler in strict mode to surface any hidden type issues: ```bash pnpm exec tsc --noEmit ``` List every type error. These must be fixed. --- ## Step 2 — TypeScript type safety ### 2a — Eliminate `any` types Search for `any` usage across the codebase: ```bash grep -rn --include="*.ts" --include="*.tsx" -E ": any|as any|<any>" src/ ``` For each hit, replace with the correct type. Common substitutions: | Instead of | Use | |------------|-----| | `any` for unknown external data | `unknown` + type guard or Zod parse | | `any` for event handlers | `React.ChangeEvent<HTMLInputElement>`, `React.MouseEvent`, etc. | | `any` for CDF responses | The SDK's own response types (import from `@cognite/sdk`) | | `any[]` for arrays | `T[]` with the correct generic | | `as any` casts | Proper type narrowing or explicit overloaded function signature | The goal is zero `any` in `src/`. If a third-party library forces it, wrap the call in a typed adapter function so `any` does not leak into the app. ### 2b — Make impossible states unrepresentable Use the type system to make invalid states fail at compile time. Fewer reachable states = easier code to read and change. **Branded types** — brand primitives so they can't be mixed up. Validate once at the boundary; downstream code trusts the type. ```ts type PhoneNumber = string & { __brand: "PhoneNumber" }; function parsePhone(input: string): PhoneNumber { if (!/^\+?\d{10,15}$/.test(input)) throw new Error(`Invalid: ${input}`); return input as PhoneNumber; } ``` If the project uses a library with native branded-type support (e.g. Effect), use their primitives instead of rolling your own. **Discriminated unions over flag bags** — replace boolean/optional combos with an exhaustive union: ```ts // Don't — invalid combos representable type State = { loading: boolean; user?: User; error?: string }; // Do — only valid states exist type State = | { status: "loading" } | { status: "success"; user: User } | { status: "error"; error: string }; ``` Search for flag-bag patterns: ```bash grep -rn --include="*.ts" --include="*.tsx" -E "loading\?|isLoading.*isError|isSuccess.*isError" src/ ``` Flag every type that combines boolean flags where only certain combos are valid. These should be discriminated unions. ### 2c — Let types flow end-to-end DB schema → server → client should share types without manual duplication. Don't restate types you can derive — reach for `Pick`, `Omit`, `Parameters`, `ReturnType`, `Awaited`, `typeof` before writing a new interface. ```ts // Don't — duplicate shape, drifts when the row changes type UserSummary = { id: string; email: Email }; function renderUser(u: UserSummary) { /* ... */ } // Do — derive from the source of truth type User = Awaited<ReturnT