agentleFS
Baba01hacker666Baba01hacker666/dummyskills/skills/typescript/ts-lint-and-typecheck/SKILL.md

ts-lint-and-typecheck

Skill0 starsChanged 2 months agoMITView on GitHub

Guides agents through resolving TypeScript compiler errors (TS2322, TS2345, TS2532) and ESLint/Biome violations without suppression comments.

  • Installs packages

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 14
  2. Very specific:

    Do not use for Python type checking.

    line 20
  3. Very specific:

    Do not use for runtime test execution.

    line 21
  4. Very specific:

    If no file is specified: run npx tsc --noEmit across project to discover failing files.

    line 28
  5. Very specific:

    Absolute Ban: Never add // @ts-ignore, // @ts-nocheck, or cast to any.

    line 29
  6. Very specific:

    If property may be undefined (TS2532): add optional chaining (?.) or a defensive guard clause.

    line 30
  7. Distinctive:

    Follow these numbered actions:

    line 33
  8. Very specific:

    If a third-party module lacks types: check if npm i -D @types/<package> exists.

    line 48
  9. Very specific:

    If handling unknown API JSON: define a Zod schema or TypeScript interface.

    line 49
  10. Distinctive:

    Stop and ask the user when:

    line 82

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

TypeScript Lint and Type-Check

Resolves TypeScript compiler errors and linter violations at the root cause. Enforces strict typing with zero tolerance for @ts-ignore or any.

1. Purpose

Diagnose and solve TypeScript compile errors. "Type Narrowing" refines union types using type guards. "Type Assertion" (as Type) is restricted to verified invariants.

2. When to Use

Use this skill when:

  • npx tsc --noEmit fails with TS error codes (TS2322, TS2345, TS2532).
  • ESLint reports @typescript-eslint/no-explicit-any or no-unused-vars.
  • Upgrading TypeScript compiler versions.

3. When Not to Use

  • Do not use for Python type checking; use py-lint-and-typecheck.
  • Do not use for runtime test execution; use ts-testing.

4. Required Inputs

  • target_file: TypeScript file with compiler or lint errors.
  • error_message: Compiler or linter diagnostic output.

5. Missing-Input Behavior

  1. If no file is specified: run npx tsc --noEmit across project to discover failing files.
  2. Absolute Ban: Never add // @ts-ignore, // @ts-nocheck, or cast to any.
  3. If property may be undefined (TS2532): add optional chaining (?.) or a defensive guard clause.

6. Procedure

Follow these numbered actions:

  1. Action 1: Run TypeScript Compiler
    • Execute npx tsc --noEmit. Extract file, line, and TSxxxx code.
  2. Action 2: Match Error Pattern to Root Cause
    • TS2322 (Type mismatch): Align interface properties or provide default value.
    • TS2532 (Object is possibly undefined): Add if (!obj) return ... guard.
    • TS2345 (Argument type mismatch): Check parameter types in function signature.
  3. Action 3: Apply Type-Safe Modification
    • Edit the target file cleanly.
  4. Action 4: Run Linter
    • Execute npx eslint <target_file> or npx @biomejs/biome check <target_file>.
  5. Action 5: Re-Verify Clean Compile
    • Confirm npx tsc --noEmit exits with code 0.

7. Decision Rules

  • If a third-party module lacks types: check if npm i -D @types/<package> exists.
  • If handling unknown API JSON: define a Zod schema or TypeScript interface; do not declare as any.

8. Output Format

Emit the report using this template:

### TypeScript Type-Check Report: [Target File]

- **Compiler Command**: `npx tsc --noEmit` -> PASS
- **Linter Command**: `npx eslint [file]` -> PASS
- **Errors Resolved**: [Count]

#### Resolved Diagnostics
| Line | Error Code | Diagnostic Description | Root Cause Fix |
| :--- | :--- | :--- | :--- |
| `[Line]` | `TS2322` | Type 'null' not assignable to 'string' | Added nullish coalescing default value |

#### Verification Status
- Zero type errors, zero `@ts-ignore` comments.

9. Verification Checklist

  • tsc --noEmit exits code 0.
  • No @ts-ignore, @ts-expect-error, or any added.
  • Linter exits code 0.
  • Unused variables and imports deleted.

10. Common Failures and Recovery

Failure SymptomCauseRecovery Action
TS2531: Object is possibly nullUnchecked optional propertyAdd guard if (item === null) return;.
@typescript-eslint/no-explicit-anyUsing anyReplace with unknown and add type guard.

11. Stop or Escalation Conditions

Stop and ask the user when:

  • Fixing the type error requires breaking public export contracts in a published library.

12. Examples

Example 1: Successful Execution

Input:

File: src/api.ts
Error: TS2532: Object is possibly 'undefined' on line 24: return req.user.id;

Output:

### TypeScript Type-Check Report: src/api.ts

- **Compiler Command**: `npx tsc --noEmit` -> PASS
- **Linter Command**: `npx eslint src/api.ts` -> PASS
- **Errors Resolved**: 1

#### Resolved Diagnostics
| Line | Error Code | Diagnostic Description | Root Cause Fix |
| :--- | :--- | :--- | :--- |
| 24 | `TS2532` | Object is possibly 'undefined' | Added guard: `if (!req.user) throw new UnauthorizedError(); return req.user.id;` |

#### Verification Status
- Zero type errors, zero `@ts-ignore` comments.

Example 2: Ambiguous or Missing Input

Input:

Fix tsc.

Output:

### TypeScript Type-Check Report: Halted - No Errors Provided

- **Status**: Halted

Please provide the compiler error output or run `npx tsc --noEmit` to list active diagnostics.

Example 3: Expected Final Output

Output:

### TypeScript Type-Check Report: src/config.ts

- **Compiler Command**: `npx tsc --noEmit` -> PASS
- **Errors Resolved**: 2

#### Resolved Diagnostics
| Line | Error Code | Diagnostic Description | Root Cause Fix |
| :--- | :--- | :--- | :--- |
| 10 | `TS2345` | Argument of type 'string \| undefined' not assignable to 'string' | Validated env variable exists before passing to parser |

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.