[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78HK0NX0CYBYMZ8DFSVRE2H":3,"skill-same:01M78HK0NX0CYBYMZ8DFSVRE2H":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M78HK0NX0CYBYMZ8DFSVRE2H","memory-leak-audit",null,"Audit code for memory leaks and disposable issues. Use when reviewing event listeners, DOM handlers, lifecycle callbacks, or fixing leak reports. Covers addDisposableListener, Event.once, MutableDisposable, DisposableStore, and onWillDispose patterns.","Qtrick\u002Fprebasecode","Qtrick","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F141445503?v=4","01M78HD7H7KZCCZK56G86RHXHG","David Fan","01M78HD7J9D6W89KHEGD4BWBVN",0,"MIT","https:\u002F\u002Fgithub.com\u002FQtrick\u002Fprebasecode\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fmemory-leak-audit\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: memory-leak-audit\ndescription: 'Audit code for memory leaks and disposable issues. Use when reviewing event listeners, DOM handlers, lifecycle callbacks, or fixing leak reports. Covers addDisposableListener, Event.once, MutableDisposable, DisposableStore, and onWillDispose patterns.'\n---\n\n# Memory Leak Audit\n\nThe #1 bug category in VS Code. This skill encodes the patterns that prevent and fix leaks.\n\n## When to Use\n\n- Reviewing code that registers event listeners or DOM handlers\n- Fixing reported memory leaks (listener counts growing over time)\n- Creating objects in methods that are called repeatedly\n- Working with model lifecycle events (onWillDispose, onDidClose)\n- Adding event subscriptions in constructors or setup methods\n\n## Audit Checklist\n\nWork through each check in order. A single missed pattern can cause thousands of leaked objects.\n\n### Step 1: DOM Event Listeners\n\n**Rule**: Never use raw `.onload`, `.onclick`, or `addEventListener()` directly. Always use `addDisposableListener()`.\n\n```typescript\n\u002F\u002F BAD — leaks a listener every call\nthis.iconElement.onload = () => { ... };\n\n\u002F\u002F GOOD — tracked and disposable\nthis._register(addDisposableListener(this.iconElement, 'load', () => { ... }));\n```\n\n**Validated by**: PR #280566 — Extension icon widget leaked 185 listeners after 37 toggles.\n\n### Step 2: One-Time Events\n\n**Rule**: Use `Event.once()` for events that should only fire once (lifecycle events, close events, first-change events).\n\n```typescript\n\u002F\u002F BAD — listener stays registered forever after first fire\nmodel.onDidDispose(() => store.dispose());\n\n\u002F\u002F GOOD — auto-removes after first invocation\nEvent.once(model.onDidDispose)(() => store.dispose());\n```\n\n**Validated by**: PRs #285657, #285661 — Terminal lifecycle hacks replaced with `Event.once()`.\n\n### Step 3: Repeated Method Calls\n\n**Rule**: Objects created in methods called multiple times must NOT be registered to the class `this._register()`. Use `MutableDisposable` or return `IDisposable` to the caller.\n\n```typescript\n\u002F\u002F BAD — every call adds another listener to the class store\nstartSearch() {\n    this._register(this.model.onResults(() => { ... }));\n}\n\n\u002F\u002F GOOD — MutableDisposable ensures max 1 listener\nprivate readonly _searchListener = this._register(new MutableDisposable());\n\nstartSearch() {\n    this._searchListener.value = this.model.onResults(() => { ... });\n}\n```\n\nWhen the event should only fire once per method call, combine `Event.once()` with `MutableDisposable` — this auto-removes the listener after the first invocation while still guarding against repeated calls:\n\n```typescript\nprivate readonly _searchListener = this._register(new MutableDisposable());\n\nstartSearch() {\n    this._searchListener.value = Event.once(this.model.onResults)(() => { ... });\n}\n```\n\n**Validated by**: PR #283466 — Terminal find widget leaked 1 listener per search.\n\n### Step 4: Model-Tied DisposableStores\n\n**Rule**: When creating a `DisposableStore` tied to a model's lifetime, register `model.onWillDispose(() => store.dispose())` to the store itself.\n\n```typescript\nconst store = new DisposableStore();\nstore.add(model.onWillDispose(() => store.dispose()));\nstore.add(model.onDidChange(() => { ... }));\n```\n\n**Validated by**: Pattern used in `chatEditingSession.ts`, `fileBasedRecommendations.ts`, `testingContentProvider.ts`.\n\n### Step 5: Resource Pool Patterns\n\n**Rule**: When using factory methods that create pooled objects (lists, trees), disposables must be registered to the individual item, not the pool class.\n\n```typescript\n\u002F\u002F BAD — registers to pool, never cleaned per item\ncreateItem() {\n    const item = new Item();\n    this._register(item.onEvent(() => { ... }));\n    return item;\n}\n\n\u002F\u002F GOOD — wrap with item-scoped disposal\ncreateItem(): IDisposable & Item {\n    const store = new DisposableStore();\n    const item = new Item();\n    store.add(item.onEvent(() => { ... }));\n    return { ...item, dispose: () => store.dispose() };\n}\n```\n\n**Validated by**: PR #290505 — Chat content parts CollapsibleListPool and TreePool leaked disposables.\n\n### Step 6: Test Validation\n\n**Rule**: Every test suite that creates disposable objects must call `ensureNoDisposablesAreLeakedInTestSuite()`.\n\n```typescript\nimport { ensureNoDisposablesAreLeakedInTestSuite } from '..\u002F..\u002F..\u002F..\u002Fbase\u002Ftest\u002Fcommon\u002Futils.js';\n\nsuite('MyFeature', () => {\n    ensureNoDisposablesAreLeakedInTestSuite();\n\n    test('does something', () => {\n        \u002F\u002F test disposables are tracked automatically\n    });\n});\n```\n\n## Quick Reference\n\n| Scenario | Pattern | Anti-Pattern |\n|----------|---------|-------------|\n| DOM events | `addDisposableListener()` | `.onclick =`, `addEventListener()` |\n| One-time events | `Event.once(event)(handler)` | `event(handler)` for lifecycle |\n| Repeated methods | `MutableDisposable` or return `IDisposable` | `this._register()` in non-constructor |\n| Model lifecycle | `store.add(model.onWillDispose(...))` | Forgetting cleanup |\n| Pooled objects | Item-scoped `DisposableStore` | Pool-scoped `this._register()` |\n| Tests | `ensureNoDisposablesAreLeakedInTestSuite()` | No leak checking |\n\n## Verification\n\nAfter fixing leaks, verify by:\n1. Checking listener counts before\u002Fafter repeated operations\n2. Running `ensureNoDisposablesAreLeakedInTestSuite()` in tests\n3. Confirming object counts stabilize (don't grow linearly with usage)\n4. **For chat-specific leaks**: Run the chat memory leak checker via `npm run perf:chat-leak` (see the `chat-perf` skill). It sends N messages in a single session, forces GC between each, and uses linear regression on heap\u002FDOM samples to detect per-message growth. A slope above 2 MB\u002Fmsg indicates a leak. Use `--messages 20 --verbose` for more accurate results.\n","# Memory Leak Audit\n\nThe #1 bug category in VS Code. This skill encodes the patterns that prevent and fix leaks.\n\n## When to Use\n\n- Reviewing code that registers event listeners or DOM handlers\n- Fixing reported memory leaks (listener counts growing over time)\n- Creating objects in methods that are called repeatedly\n- Working with model lifecycle events (onWillDispose, onDidClose)\n- Adding event subscriptions in constructors or setup methods\n\n## Audit Checklist\n\nWork through each check in order. A single missed pattern can cause thousands of leaked objects.\n\n### Step 1: DOM Event Listeners\n\n**Rule**: Never use raw `.onload`, `.onclick`, or `addEventListener()` directly. Always use `addDisposableListener()`.\n\n```typescript\n\u002F\u002F BAD — leaks a listener every call\nthis.iconElement.onload = () => { ... };\n\n\u002F\u002F GOOD — tracked and disposable\nthis._register(addDisposableListener(this.iconElement, 'load', () => { ... }));\n```\n\n**Validated by**: PR #280566 — Extension icon widget leaked 185 listeners after 37 toggles.\n\n### Step 2: One-Time Events\n\n**Rule**: Use `Event.once()` for events that should only fire once (lifecycle events, close events, first-change events).\n\n```typescript\n\u002F\u002F BAD — listener stays registered forever after first fire\nmodel.onDidDispose(() => store.dispose());\n\n\u002F\u002F GOOD — auto-removes after first invocation\nEvent.once(model.onDidDispose)(() => store.dispose());\n```\n\n**Validated by**: PRs #285657, #285661 — Terminal lifecycle hacks replaced with `Event.once()`.\n\n### Step 3: Repeated Method Calls\n\n**Rule**: Objects created in methods called multiple times must NOT be registered to the class `this._register()`. Use `MutableDisposable` or return `IDisposable` to the caller.\n\n```typescript\n\u002F\u002F BAD — every call adds another listener to the class store\nstartSearch() {\n    this._register(this.model.onResults(() => { ... }));\n}\n\n\u002F\u002F GOOD — MutableDisposable ensures max 1 listener\nprivate readonly _searchListener = this._register(new MutableDisposable());\n\nstartSearch() {\n    this._searchListener.value = this.model.onResults(() => { ... });\n}\n```\n\nWhen the event should only fire once per method call, combine `Event.once()` with `MutableDisposable` — this auto-removes the listener after the first invocation while still guarding against repeated calls:\n\n```typescript\nprivate readonly _searchListener = this._register(new MutableDisposable());\n\nstartSearch() {\n    this._searchListener.value = Event.once(this.model.onResults)(() => { ... });\n}\n```\n\n**Validated by**: PR #283466 — Terminal find widget leaked 1 listener per search.\n\n### Step 4: Model-Tied DisposableStores\n\n**Rule**: When creating a `DisposableStore` tied to a model's lifetime, register `model.onWillDispose(() => store.dispose())` to the store itself.\n\n```typescript\nconst store = new DisposableStore();\nstore.add(model.onWillDispose(() => store.dispose()));\nstore.add(model.onDidChange(() => { ... }));\n```\n\n**Validated by**: Pattern used in `chatEditingSession.ts`, `fileBasedRecommendations.ts`, `testingContentProvider.ts`.\n\n### Step 5: Resource Pool Patterns\n\n**Rule**: When using factory methods that create pooled objects (lists, trees), disposables must be registered to the individual item, not the pool class.\n\n```typescript\n\u002F\u002F BAD — registers to pool, never cleaned per item\ncreateItem() {\n    const item = new Item();\n    this._register(item.onEvent(() => { ... }));\n    return item;\n}\n\n\u002F\u002F GOOD — wrap with item-scoped disposal\ncreateItem(): IDisposable & Item {\n    const store = new DisposableStore();\n    const item = new Item();\n    store.add(item.onEvent(() => { ... }));\n    return { ...item, dispose: () => store.dispose() };\n}\n```\n\n**Validated by**: PR #290505 — Chat content parts CollapsibleListPool and TreePool leaked disposables.\n\n### Step 6: Test Validation\n\n**Rule**: Every test suite that creates disposable objects must call `ensureNoDisposablesAreLeakedInTestSuite()`.\n\n```typescript\nimport { ensureNoDisposablesAreLeakedInTestSuite } from '..\u002F..\u002F..\u002F..\u002Fbase\u002Ftest\u002Fcommon\u002Futils.js';\n\nsuite('MyFeature', () => {\n    ensureNoDisposablesAreLeakedInTestSuite();\n\n    test('does something', () => {\n        \u002F\u002F test disposables are tracked automatically\n    });\n});\n```\n\n## Quick Reference\n\n| Scenario | Pattern | Anti-Pattern |\n|----------|---------|-------------|\n| DOM events | `addDisposableListener()` | `.onclick =`, `addEventListener()` |\n| One-time events | `Event.once(event)(handler)` | `event(handler)` for lifecycle |\n| Repeated methods | `MutableDisposable` or return `IDisposable` | `this._register()` in non-constructor |\n| Model lifecycle | `store.add(model.onWillDispose(...))` | Forgetting cleanup |\n| Pooled objects | Item-scoped `DisposableStore` | Pool-scoped `this._register()` |\n| Tests | `ensureNoDisposablesAreLeakedInTestSuite()` | No leak checking |\n\n## Verification\n\nAfter fixing leaks, verify by:\n1. Checking listener counts before\u002Fafter repeated operations\n2. Running `ensureNoDisposablesAreLeakedInTestSuite()` in tests\n3. Confirming object counts stabilize (don't grow linearly with usage)\n4. **For chat-specific leaks**: Run the chat memory leak checker via `npm run perf:chat-leak` (see the `chat-perf` skill). It sends N messages in a single session, forces GC between each, and uses linear regression on heap\u002FDOM samples to detect per-message growth. A slope above 2 MB\u002Fmsg indicates a leak. Use `--messages 20 --verbose` for more accurate results.\n",{"name":5,"description":7},"main","a87007e75a0e5632a49ac593bd7df9f4e8d57d38",".github\u002Fskills\u002Fmemory-leak-audit","https:\u002F\u002Fgithub.com\u002FQtrick\u002Fprebasecode","https:\u002F\u002Fgithub.com\u002FQtrick","2026-09-18 02:39:35",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add Qtrick\u002Fprebasecode --skill memory-leak-audit",{"tool":36,"command":37},"bunx","bunx skills add Qtrick\u002Fprebasecode --skill memory-leak-audit",{"tool":39,"command":40},"pnpm","pnpm dlx skills add Qtrick\u002Fprebasecode --skill memory-leak-audit","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FQtrick\u002Fprebasecode\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fmemory-leak-audit\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":19},"01M78HRHDZJD3512KSR0GZPJ57","review","Review skill with nested metadata","https:\u002F\u002Fgithub.com\u002FQtrick\u002Fprebasecode\u002Fblob\u002Fmain\u002Ftest\u002Fprebase\u002Ffixtures\u002Fproject-guidance-skill-meta\u002F.agents\u002Fskills\u002Freview\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M78HRG98D7PY73KG63XAK5H6","ui-ux-pro-max","UI UX Pro Max design guidance","https:\u002F\u002Fgithub.com\u002FQtrick\u002Fprebasecode\u002Fblob\u002Fmain\u002Ftest\u002Fprebase\u002Ffixtures\u002Fproject-guidance-monorepo\u002F.opencode\u002Fskills\u002Fui-ux-pro-max\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M78HRFBCY0MBYVQ0HRXSV5GX","deploy","Deploy skill","https:\u002F\u002Fgithub.com\u002FQtrick\u002Fprebasecode\u002Fblob\u002Fmain\u002Ftest\u002Fprebase\u002Ffixtures\u002Fproject-guidance-monorepo\u002F.codex\u002Fskills\u002Fdeploy\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M78HRE6JKXTMJN9DHCF487YD","interop","Interoperable Agent Skill for live smoke","https:\u002F\u002Fgithub.com\u002FQtrick\u002Fprebasecode\u002Fblob\u002Fmain\u002Ftest\u002Fprebase\u002Ffixtures\u002Fproject-guidance-monorepo\u002F.agents\u002Fskills\u002Finterop\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M78HRCTZENSGRPZX2N148VDD","ship","Devin ship skill","https:\u002F\u002Fgithub.com\u002FQtrick\u002Fprebasecode\u002Fblob\u002Fmain\u002Ftest\u002Fprebase\u002Ffixtures\u002Fproject-guidance-extra-skills\u002F.devin\u002Fskills\u002Fship\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M78HRBVY4KCF8ZRJ2M8RYFRD","lint","Codeium lint skill","https:\u002F\u002Fgithub.com\u002FQtrick\u002Fprebasecode\u002Fblob\u002Fmain\u002Ftest\u002Fprebase\u002Ffixtures\u002Fproject-guidance-extra-skills\u002F.codeium\u002Fskills\u002Flint\u002FSKILL.md",[],[]]