
This is a checklist-driven audit for catching disposable and event listener leaks in VS Code extension code. You'd reach for it when reviewing code that registers DOM handlers, fixing reported leaks where listener counts grow unbounded, or working with lifecycle callbacks. It walks through six patterns in order: using addDisposableListener for DOM events, Event.once for one-time fires, MutableDisposable for methods called repeatedly, model-tied DisposableStores, resource pool disposal scoping, and test validation. Each rule is validated against actual VS Code PRs where these patterns prevented or fixed real leaks. The practical bit is the sequential checklist format, since missing even one pattern can leak thousands of objects over time.
$ npx -y skills add microsoft/vscode --skill memory-leak-audit --agent claude-codeInstalls into .claude/skills of the current project.
The #1 bug category in VS Code. This skill encodes the patterns that prevent and fix leaks.
Work through each check in order. A single missed pattern can cause thousands of leaked objects.
Rule: Never use raw .onload, .onclick, or addEventListener() directly. Always use addDisposableListener().
// BAD — leaks a listener every call
this.iconElement.onload = () => { ... };
// GOOD — tracked and disposable
this._register(addDisposableListener(this.iconElement, 'load', () => { ... }));
Validated by: PR #280566 — Extension icon widget leaked 185 listeners after 37 toggles.
Rule: Use Event.once() for events that should only fire once (lifecycle events, close events, first-change events).
Sponsors