Skip to content
Back to skills

Typescript Extension Engineering

ASecurity

Effective TypeScript and VS Code extension engineering for this repo - strict typing patterns, error handling, async/streams, disposables, activation, webview messaging, performance, packaging with webpack, testing with Mocha and vscode-test. Use when writing or reviewing extension-host or shared TypeScript.

  • 8 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 5, 2026
developmenttypescriptgotestingperformance

Works with

  • vscode

Security analysis

A100/100

Scanned December 5, 2026

npx -y skills add afri-bit/candb-studio --skill typescript-extension-engineering --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Typescript Extension Engineering?

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

Security grade badge for Typescript Extension Engineering
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/afri-bit-typescript-extension-engineering/badge)](https://www.skillsdirectory.com/skills/afri-bit-typescript-extension-engineering)

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: typescript-extension-engineering
description: Effective TypeScript and VS Code extension engineering for this repo - strict typing patterns, error handling, async/streams, disposables, activation, webview messaging, performance, packaging with webpack, testing with Mocha and vscode-test. Use when writing or reviewing extension-host or shared TypeScript.
---

# TypeScript and VS Code extension engineering

## TypeScript
- `strict` on; no `any`. Model unknown input as `unknown` and narrow with user-defined type guards or a small schema validator at boundaries (webview messages, file input).
- Discriminated unions for protocols (`{ type: 'x'; ... }`) with exhaustive `switch` + `assertNever`.
- Branded or opaque types for units that must not mix (`Nanoseconds`, `CanId`, `ByteOffset`); `bigint` for 64-bit raw values and ns timestamps (JSON cannot carry bigint - serialise as string or split).
- Immutability by default (`readonly`, `ReadonlyArray`); pure functions in `core`.
- Errors: typed errors from `src/shared/errors/`, `catch (err: unknown)`, helpers in `errorUtils`; never swallow; add context (what, where, input id).
- Numbers: bit math on `number` is 32-bit signed - use `>>>`, masks, or `BigInt` for >= 32-bit fields; test sign extension explicitly.

## Async and streams
`async`/`await`; `AsyncIterable` for frame/log streams; `AbortSignal` for cancellation; bound concurrency; never fire-and-forget a promise without `.catch`. Do not `await` inside hot loops when batching is possible.

## VS Code specifics
- `activate` returns quickly; lazy-create heavy services; activation events specific (`onLanguage:dbc`, `onCustomEditor:`, `onCommand:`).
- Everything disposable goes into `context.subscriptions`. Event emitters disposed. Timers cleared on dispose.
- Webviews: `retainContextWhenHidden` only when needed (memory); CSP with nonce; `asWebviewUri`; restore state with `getState/setState` or re-send from host.
- Custom editor: `CustomTextEditorProvider`/document model, apply edits via `WorkspaceEdit` so undo/redo and dirty state work; handle external changes.
- Use `Logger` (output channel), not `console`. Respect `vscode.workspace.fs` for virtual workspaces where feasible; declare `capabilities` in `package.json` honestly.
- Settings via `contributes.configuration` with descriptions, defaults, and scope; read through one config module.

## Performance
Measure before optimising (`console.time` in dev, VS Code "Developer: Show Running Extensions"). Avoid O(n^2) over messages x signals; index by id. Virtualise large lists. Parse big files incrementally.

## Build and packaging
webpack bundle to `dist/extension.js`; externals only `vscode`; vendor SDKs bundled (see spec `cansub-adapter`). `.vscodeignore` keeps `.claude/`, `openspec/`, `docs/`, tests out of the `.vsix`.

## Testing
Unit: pure TS with `test/mocha-vscode-stub.cjs` shim. Integration: `@vscode/test-electron`. Prefer fakes over mocks; deterministic clocks; table-driven tests for bit-packing and parser cases.

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 development →

Comments

Loading comments…

Newsletter

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