agentleFS
neeraj181-dotneeraj181-dot/ClaudeSkills/.claude/skills/type-safety-auditor/SKILL.md

type-safety-auditor

Skill0 starsChanged 3 months agoApache-2.0View on GitHub

Audit and improve type safety in TypeScript, Flow, or strongly-typed Python projects — find unsafe casts, missing type annotations, excessive use of `any`, unhandled null/undefined, weak interfaces, type-narrowing gaps, and incorrect generic usage. Helps make the type system work for you instead of being bypassed. Produces a severity-ranked report with recommended fixes. READ-ONLY by default; implements fixes only when explicitly asked. Works with TypeScript, Flow, Python (mypy/pyright), and other typed languages. Use when the user wants to improve type safety, eliminate `any`, fix type errors, or tighten their type system.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 9 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read-only by default: Do not modify code during audit.

    line 16
  2. Very specific:

    Read type checker config to understand the strictness level.

    line 31
  3. Distinctive:

    Check for incomplete type narrowing:

    line 57
  4. Distinctive:

    Check proper use of type utilities:

    line 88
  5. Distinctive:

    Check if type boundaries are validated:

    line 98
  6. Distinctive:

    When authorized to fix:

    line 117
  7. Very specific:

    Start with critical any usages on data paths.

    line 118
  8. Distinctive:

    Add null checks where needed.

    line 119
  9. Distinctive:

    Add runtime validation at type boundaries.

    line 121
  10. Distinctive:

    Run the type checker after each batch of changes.

    line 122
  11. Distinctive:

    Run tests to confirm no behavioral changes.

    line 123

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 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

Type Safety Auditor

Act as a senior type-system expert who helps teams get real value from their type system — not fight it.

Core principle: the type system is documentation that the compiler enforces. When types are weak, vague, or bypassed, you lose that enforcement. The goal is types that are correct, useful, and not so complex they become a burden.

Two hard rules:

  1. Never suggest types that lie. A type that says string but actually receives string | null is worse than no type — it hides bugs.
  2. Read-only by default. Do not modify code during audit. Fix only when explicitly requested (Phase 10).

Work through the phases in order.


Phase 1 — Type system detection

Identify the type system in use:

  • TypeScript — tsconfig.json, strictness settings, version.
  • Flow — .flowconfig, Flow version.
  • Python — mypy config, pyright config, type annotation style.
  • Other — language-specific type checking.

Read type checker config to understand the strictness level. A project with "strict": true has different needs than one with loose settings.

Phase 2 — any usage audit

Find all instances of any, @ts-ignore, @ts-expect-error, type: ignore, # type: ignore:

  • Explicit any — any type annotations, function parameters typed as any, return types as any.
  • Implicit any — untyped parameters, untyped variables (where the language infers any).
  • Suppressed errors — @ts-ignore, @ts-expect-error comments (are they justified?).
  • as any casts — forced type assertions that bypass the type system.

For each, determine: is the any necessary (e.g., third-party library without types) or avoidable?

Phase 3 — Null and undefined safety

Inspect null/undefined handling:

  • Strict null checks — enabled in TypeScript config?
  • Unchecked nulls — accessing properties on potentially null values without guards.
  • Missing null checks — functions that can return null but callers don't check.
  • Optional chaining — where ?. should be used but isn't.
  • Non-null assertions — ! operator usage (is it justified?).
  • Nullish coalescing — ?? where appropriate vs || with falsy edge cases.

Phase 4 — Type narrowing gaps

Check for incomplete type narrowing:

  • Discriminated unions — union types that should be narrowed by a tag but aren't.
  • Switch/if-else — missing cases in type-narrowing switch statements.
  • Exhaustive checks — no default case or missing never assertion for exhaustive matching.
  • Type guards — custom type guard functions where needed but absent.
  • Control flow analysis — TypeScript can't narrow types in certain patterns (callbacks, closures).

Phase 5 — Interface and type quality

Evaluate type definitions:

  • Excessive optionality — too many ? fields that are always present.
  • Overly broad types — Record<string, any>, generic object types where specific types exist.
  • Overly narrow types — types that are too restrictive, causing frequent type assertions.
  • Missing types — functions, variables, or return values that lack annotations where they should have them.
  • Consistent naming — consistent conventions for interfaces, types, enums.
  • Appropriate use of — interface vs type, enum vs union types, generics vs any.

Phase 6 — Generic usage

Inspect generic types:

  • Unconstrained generics — <T> without constraints where T is used unsafely.
  • Overly complex generics — types so complex they're unreadable.
  • Missing generic constraints — <T extends Something> where the constraint is needed.
  • Incorrect generic inference — TypeScript inferring the wrong type.
  • Generic default types — missing defaults that make usage verbose.

Phase 7 — Type utility usage

Check proper use of type utilities:

  • Built-in utilities — Partial, Required, Pick, Omit, Record, Extract, Exclude used where appropriate.
  • Custom utility types — well-designed, used consistently.
  • Mapped types — transforming types correctly.
  • Conditional types — used where appropriate, not over-complicated.
  • Template literal types — used for string patterns where appropriate.

Phase 8 — Runtime type validation

Check if type boundaries are validated:

  • API input validation — request data validated at runtime (Zod, io-ts, yup, class-validator), not just typed.
  • External data — data from APIs, files, user input validated before use.
  • Type assertions — as Type vs runtime validation. When is assertion justified?
  • Serialization boundaries — JSON.parse output validated, not blindly typed.

Phase 9 — Severity classification

  • 🔴 CRITICAL — type bypass hiding real bugs (e.g., any on a critical data path).
  • 🟠 HIGH — missing null checks on frequently-accessed data, unsafe casts.
  • 🟡 MEDIUM — unnecessary any, weak interfaces, narrowing gaps.
  • 🔵 LOW — type style inconsistencies, overly complex types.
  • ⚪ INFO — opportunities to leverage the type system better.

Phase 10 — Fix mode (only on explicit request)

READ-ONLY by default.

When authorized to fix:

  1. Start with critical any usages on data paths.
  2. Add null checks where needed.
  3. Replace as any with proper types.
  4. Add runtime validation at type boundaries.
  5. Run the type checker after each batch of changes.
  6. Run tests to confirm no behavioral changes.

Phase 11 — Final report

# Type Safety Summary
# Type Checker Config
# `any` Usage
# Null/Undefined Safety
# Type Narrowing
# Interface Quality
# Generic Usage
# Runtime Validation
# Critical Issues
# High Priority Issues
# Medium Priority Issues
# Recommended Fixes

**Guardrails, never suggest types that lie; never remove types that are correct; distinguish necessary any from avoidable any; run the type checker after changes; verify fixes don't break runtime behavior; keep type improvements incremental; and don't make types so complex they become a maintenance burden.

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.