Skip to content
Back to skills

Writing Typescript

ASecurity

Use when writing, editing, or reviewing TypeScript in a Node.js ESM project. Triggers on `.ts` files, ESM `package.json`, `import` paths, strict-mode type errors, async code, or environment variables, even when the user doesn't say 'TypeScript'.

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentstypescriptgonode

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned November 30, 2026

npx -y skills add xonovex/platform --skill writing-typescript --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Writing Typescript?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Writing Typescript
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/xonovex-writing-typescript/badge)](https://www.skillsdirectory.com/skills/xonovex-writing-typescript)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: writing-typescript
description: "Use when writing, editing, or reviewing TypeScript in a Node.js ESM project. Triggers on `.ts` files, ESM `package.json`, `import` paths, strict-mode type errors, async code, or environment variables, even when the user doesn't say 'TypeScript'."
---

# TypeScript Coding Guidelines

Write strict TypeScript modules with explicit types, direct imports, and checked errors.

## Requirements

- Node.js ESM, TypeScript ≥ 5.8, Vitest ≥ 3, Zod ≥ 4.

## Essentials

- **Strict mode** - Enable strict flags, avoid `@ts-ignore` without comment+issue
- **Type safety** - Explicit public types, `unknown` over `any`, derive from generated types
- **Imports** - Use `import type` for type-only imports
- **Async/await** - Handle errors explicitly, only use `async` with `await`, see [references/async-without-await.md](references/async-without-await.md), [references/unnecessary-async-keywords.md](references/unnecessary-async-keywords.md)
- **Immutability** - Use `const`/`readonly` where possible
- **Validation** - Zod for I/O boundaries, infer types from schemas
- **Linting** - Never suppress with eslint-disable, fix root causes, see [references/avoid-eslint-disable.md](references/avoid-eslint-disable.md)
- **Template literals** - Convert numbers with `String(value)`, see [references/template-literals-require-string-conversion.md](references/template-literals-require-string-conversion.md)
- **Numeric literals** - Use underscores in large numbers (`30_000`), see [references/numeric-separator-enforcement.md](references/numeric-separator-enforcement.md)
- **Method references** - Keep object references to maintain `this` binding, see [references/unbound-method-references.md](references/unbound-method-references.md)
- **Environment** - Use dot notation for `process.env` access, see [references/env-access-bracket-notation.md](references/env-access-bracket-notation.md)
- **Paradigm** - Functional style → **applying-fp**; class/OO design → **applying-oop**

## Gotchas

- Structural typing means `{ a: string }` accepts `{ a: string, b: number }` silently: explicit `satisfies` is the way to catch unintended extras
- `as` casts bypass the type system without check: prefer narrowing functions (type predicates) over casts
- `type` vs `interface`: interfaces merge across declarations, types don't. `declare global { interface Window { ... } }` works, `type Window = ...` doesn't
- `unknown` is the safer `any`, but it doesn't propagate; narrowing once doesn't carry across assignments
- Module resolution depends on `tsconfig` `moduleResolution` (`bundler` vs `node16` vs `nodenext`): wrong choice silently breaks deep imports

## Progressive disclosure

- Read [references/async-without-await.md](references/async-without-await.md) - Load when seeing async functions that don't use await
- Read [references/unnecessary-async-keywords.md](references/unnecessary-async-keywords.md) - Load when simplifying synchronous controller functions
- Read [references/avoid-eslint-disable.md](references/avoid-eslint-disable.md) - Load when tempted to suppress linting warnings
- Read [references/template-literals-require-string-conversion.md](references/template-literals-require-string-conversion.md) - Load when inserting numbers in template literals
- Read [references/numeric-separator-enforcement.md](references/numeric-separator-enforcement.md) - Load when writing large numeric literals
- Read [references/unbound-method-references.md](references/unbound-method-references.md) - Load when passing methods as callbacks or references
- Read [references/env-access-bracket-notation.md](references/env-access-bracket-notation.md) - Load when accessing process.env variables

Files in this skill

  • SKILL.md3.6 KB
  • eval-output.json2.5 KB
  • eval-trigger.json5 KB
  • moon.yml86 B
  • references/async-without-await.md521 B
  • references/avoid-eslint-disable.md605 B
  • references/env-access-bracket-notation.md505 B
  • references/numeric-separator-enforcement.md396 B
  • references/template-literals-require-string-conversion.md393 B
  • references/unbound-method-references.md544 B
  • references/unnecessary-async-keywords.md536 B
  • sources.json827 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.