mcpField
A
auto-type-checking

auto-type-checking

github.com/spencerpaulyTesting & quality868441 installsUpdated 13w ago
Repository

About auto-type-checking

A Cursor skill for checking TypeScript types after edits, either manually with `tsc` or automatically through file-edit hooks. It helps coding agents catch common type errors before build time.

Key features

  1. 01Manual `tsc --noEmit` checks
  2. 02Automatic checks with Cursor Hooks
  3. 03Guidance for common type errors

Use cases

  1. 01Check types after editing TypeScript files
  2. 02Report errors automatically through Cursor hooks

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/spencerpauly/awesome-cursor-skills --skill auto-type-checking

After installing, type/auto-type-checkingin Claude Code to confirm it loaded.

Details

From the project README

Auto Type Checking

Catch type errors immediately after every edit instead of discovering them at build time.

Manual Workflow

After editing a TypeScript file, run:

npx tsc --noEmit 2>&1 | head -30

If errors appear, fix them before moving on.

Automated with Cursor Hooks

Add to .cursor/hooks.json to run automatically after every file edit:

{
  "hooks": [
    {
      "event": "afterFileEdit",
      "script": "check-types.sh",
      "pattern": "**/*.{ts,tsx}"
    }
  ]
}

Create .cursor/hooks/check-types.sh:

#!/bin/bash
# Quick type check — only reports errors, doesn't block
npx tsc --noEmit --pretty 2>&1 | head -20
exit 0  # Don't block the agent even if there are errors
chmod +x .cursor/hooks/check-types.sh

What to Check

When type errors appear:

  1. Missing imports: Cannot find name 'X' → add the import
  2. Type mismatches: Type 'string' is not assignable to type 'number' → fix the type or the value
  3. Missing properties: Property 'x' does not exist on type 'Y' → add the property to the interface or fix the access
  4. Null safety: Object is possibly 'null' → add null check or optional chaining
  5. Generic constraints: Type 'X' does not satisfy the constraint 'Y' → fix the generic parameter

Tips

  • Use --noEmit to type-check without producing output files
  • For large projects, tsc can be slow — consider --incremental or running only on changed files
  • If using path aliases, ensure tsconfig.json paths are configured correctly
  • For monorepos, run tsc from the package root, not the workspace root
  • Pair with grinding-until-pass for a full "fix until clean" loop

Comments

Markdown supported