Skip to content

sethlivingston/the-typescript-narrows

Repository files navigation

The TypeScript Narrows

The TypeScript Narrows is a Claude Skill and an ESLint plugin that complement each other. Together they help AI agents narrow the "five different ways to do X" to a single, opinionated, best-practice way to do X. Some examples:

  • No any, no !, no type assertions — narrow instead
  • No enum — use as const objects with discriminated unions
  • No default exports, no barrel files
  • No .forEach(), no .reduce() — use for...of
  • No floating promises, no misused promises
  • return await inside try/catch (always)
  • ?? over ||, ?. over manual null checks
  • Exhaustive switch — every union variant handled
  • Result types for expected failures, throw only for bugs
  • Readonly<T> params, readonly properties, no mutable exports
  • Branded types for domain IDs and value objects
  • Early returns to fail fast and avoid deep nesting
  • strict: true plus noUncheckedIndexedAccess
  • ...and many more

The Claude skill and the ESLint plugin extend @typescript-eslint and cover over 50 opinions on type safety, error handling, async patters, naming conventions, and more.

"The TypeScript Narrows" is a play on "The Deathly Hallows".

Repo Structure

Getting Started

For AI-assisted development: Install the Claude plugin from the marketplace:

claude plugin add-marketplace github:sethlivingston/claude-marketplace
claude plugin install the-typescript-narrows

The skill triggers automatically when writing or reviewing TypeScript. See the plugin README for details.

For automated enforcement: Install @sethlivingston/eslint-plugin-typescript-narrows to lint against these opinions in CI and your editor:

npm install --save-dev @sethlivingston/eslint-plugin-typescript-narrows

See eslint-plugin README for setup instructions.

Both artifacts work independently, but they're designed to complement each other -- the skill covers opinions that can't be expressed as lint rules.

Coverage

See docs/TRACEABILITY.md for the full traceability matrix mapping all opinions to their enforcement mechanisms.

License

MIT

About

Claude Skill and ESLint plugin that remove TypeScript's footguns and inconsistencies

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors