
Auto Perf Optimize
Investigate VS Code chat and UI memory or latency regressions with Playwright-backed scratchpad scenarios and reusable smoke runners.
Overview
Auto Perf Optimize is an agent skill most often used in Ship (also Build, Operate) that structures Playwright performance investigations for VS Code–style chat and UI with scratchpad scenarios and smoke runners.
Install
npx skills add https://github.com/microsoft/vscode --skill auto-perf-optimizeWhat is this skill?
- Gitignored scratchpad organized as dated subfolders with scenario.mts and findings.md
- Checked-in chat-memory-smoke.mts for multi-turn prompts, heap samples, and optional snapshots
- chat-session-switch-smoke pattern for tab and session switching investigations
- Promote proven scratchpad runners to parent scripts/ when they generalize
- Quick-start via playwright-core and node against skill scratchpad paths
- Dated scratchpad subfolder pattern: scenario.mts plus findings.md
- chat-memory-smoke supports --message, --iterations, --skip-send, --keep-open, --reuse
Adoption & trust: 79 installs on skills.sh; 186k GitHub stars.
What problem does it solve?
You suspect chat or editor UI is leaking memory or slowing down but lack a repeatable scenario runner and documented before/after measurements.
Who is it for?
Maintainers of VS Code extensions or agent chat surfaces who already use Node and Playwright for automated repro.
Skip if: Greenfield app builders with no local VS Code build or no need for browser-driven editor automation.
When should I use this skill?
When investigating VS Code chat or UI performance, memory growth, or session-switch latency using automated scenarios.
What do I get? / Deliverables
You get dated scratchpad scenarios, findings.md with rejected hypotheses, and optional promotion of stable runners into shared scripts.
- scratchpad/YYYY-MM-DD-*/scenario.mts investigation runner
- findings.md with measurements and rejected ideas
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Performance validation belongs on the Ship shelf as the last gate before users feel slowness or leaks in production-like sessions. The skill centers heap sampling, multi-turn chat smoke, and session-switch scenarios—explicit performance engineering, not feature coding.
Where it fits
Baseline heap after a new chat panel ships so you know regressions before code freeze.
Run chat-memory-smoke with --iterations before tagging a release candidate.
Reopen a dated scratchpad folder when users report scroll jank after a prior fix.
How it compares
Use instead of one-off manual Task Manager checks without scripted multi-turn chat reproduction.
Common Questions / FAQ
Who is auto-perf-optimize for?
Solo developers and small teams optimizing VS Code–related chat or UI performance with scripted Playwright scenarios.
When should I use auto-perf-optimize?
In Ship before release when profiling chat memory; in Build when adding heavy chat features; in Operate when investigating production-like slowness reports.
Is auto-perf-optimize safe to install?
It implies running local browsers and Node scripts; review the Security Audits panel on this page and run only trusted scenario code in scratchpad.
SKILL.md
READMESKILL.md - Auto Perf Optimize
* !README.md !.gitignore # Scratchpad — one-off scenario runners This folder is gitignored. Write investigation-specific runners here freely. ## Organization Put each investigation in a **dated subfolder** named `YYYY-MM-DD-short-description/`: ``` scratchpad/ 2026-04-09-chat-scroll-leak/ scenario.mts findings.md 2026-04-12-editor-tab-switching/ scenario.mts findings.md ``` Each subfolder should contain: - **Scripts** — scenario runners, analysis scripts, etc. - **`findings.md`** — a summary of the investigation: all ideas considered, whether each led to a change or was rejected (and why), and before/after measurements so the user can review decisions and follow up. Scenario runners you create here can import utilities from the checked-in scripts or copy patterns from them. When a runner proves generally useful, promote it to the parent `scripts/` folder. ## Quick start ```bash # Write a runner cat > scratchpad/my-scenario.mts << 'EOF' import { chromium } from 'playwright-core'; // ... your scenario EOF # Run it node .github/skills/auto-perf-optimize/scratchpad/my-scenario.mts ``` ## Checked-in scripts (in `scripts/`) These are reusable, generic runners. Use them directly or as templates: - **`chat-memory-smoke.mts`** — Multi-turn chat smoke runner. Sends prompts, waits for responses, samples heap, takes optional snapshots. Supports `--message`, `--iterations`, `--skip-send`, `--keep-open`, `--reuse`, etc. - **`chat-session-switch-smoke.mts`** — Creates multiple chat sessions with different content, then repeatedly switches between them via the sessions sidebar. Measures per-switch memory growth. - **`userDataProfile.mts`** — Utility for managing user-data profiles in smoke test runs. ## Tips - Always use `--user-data-dir .build/auto-perf-optimize/user-data` (the persistent profile with Copilot auth). Never create a fresh user-data-dir. - Use `--skip-prelaunch` to avoid re-downloading Electron on every run. - If you need to clean up an orphaned test instance, stop only the specific Code - OSS process (e.g. by killing the PID that was logged at launch, or `lsof -ti :<port> | xargs kill`). Avoid `pkill -f 'Electron'` — it can kill unrelated Electron apps. - For heap snapshot analysis, use the `heap-snapshot-analysis` skill's scratchpad and helpers. /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ /** * Chat memory smoke runner. * * Intended workflow: * - Run `node .github/skills/auto-perf-optimize/scripts/chat-memory-smoke.mts --iterations 3 --no-heap-snapshots` for a fast health check. * - Run `node .github/skills/auto-perf-optimize/scripts/chat-memory-smoke.mts --iterations 8 --heap-snapshot-label 03-iteration-01 --heap-snapshot-label 03-iteration-08` when comparing post-warmup heap snapshots. * - Inspect the output folder's summary.json, screenshots, and optional heap/*.heapsnapshot files. * * The default profile is persistent at .build/auto-perf-optimize/user-data so auth can be reused across performance runners. * Pass --temporary-user-data when a clean, disposable profile is required; combine it with --seed-user-data-dir to start from a logged-in seed. */ import { chromium, type Browser, type CDPSession, type Locator, type Page } from 'playwright-core'; import { spawn, type ChildProcess } from 'node:child_process'; import { createWriteStream } from 'node:fs'; import { mkdir, rm, writeFile } from 'node:fs/promises'; import http from 'node:http'; import os from 'node:os'; import path from 'node:path'; import process from 'node:process'; import { setTimeout as timeout } from 'node:timers/promises'; import { StopWatch } from '../../../../src/vs/base/common/s