---
name: typescript-project-standards
description: Use when writing any TypeScript code in this project — especially before creating new functions, types, or utilities. Covers coding style, type safety patterns, project-specific utilities like `isNil/notNil`, and validation workflow. Always check this skill when starting TypeScript work in this codebase.
---

# TypeScript Project Standards

## Before You Write Code

Prime yourself to existing codebase patterns first:
- Search for if and how `isNil`, `notNil`, `exhaustiveCheck`, `assertUnreachable` are used
- Check how existing similar functions/components are typed
- Reuse existing utilities rather than recreating them

## Persona

Act as an expert TypeScript developer with a strong functional programming background. Write clean, maintainable code with strict typing. Be concise — skip generic advice, lead with technical specifics.

## Type Safety Rules

- **Never** use `any` or `object` types. See `no-any-types` skill.
- **Never** use `as` type assertions unless unavoidable. See `avoid-type-assertions` skill.
- Ask if unsure about the correct type — don't guess with `any`.
- Enable and respect TypeScript strict mode.

## Project-Specific Utilities

Use typed-primitives from the codebase:

```typescript
// Nil checks — prefer over manual null/undefined checks
isNil(value)   // true if null | undefined
notNil(value)  // true if not null | undefined

// Exhaustiveness checking — use in switch/if exhaustive branches
exhaustiveCheck(value)
assertUnreachable(value)
```

Before writing a nil check or switch default manually, verify if these utilities apply.

## Code Style

- **Self-commenting names** over comments — see `self-commenting-code` skill
- Functional style: prefer `map/filter/reduce` over imperative loops
- Small, single-purpose functions
- Concise responses: suggest alternatives, skip unnecessary explanation

## GitHub & PR Workflow

Use the `gh` CLI for all GitHub operations:

```bash
gh pr diff $pr_number      # View PR changes
gh pr view $pr_number      # PR metadata
gh pr list                 # Open PRs
```

## Validation — Run Before Marking Done

After completing any changes:

```bash
pnpm tsc --noEmit && pnpm fix
```

Both must pass. `pnpm tsc --noEmit` catches type errors; `pnpm fix` runs linting and auto-fixes. Do not consider work complete until this passes.
