agentleFS
daveebbelaardaveebbelaar/bawa/skills/code/performance/SKILL.md

performance

Skill17 starsChanged 10 days agoMITView on GitHub

Make a Windows app fast by measuring hangs, stutter, CPU, memory, and startup, then moving work off the UI thread and onto the GPU. Use when the app freezes or shows "Not responding", a shortcut feels slow, scrolling or dragging stutters, the fan spins, memory grows, or the user asks to optimize or profile.

78 other projects use a version of this, 2 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use tdd-rust, web-quality-audit and 3 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • FlorianBruniauxSkill

    tdd-rust

    Also in 3 projects that use this

  • RodrigoTomeESSkill

    web-quality-audit

    Comprehensive web quality audit covering performance, accessibility, SEO, and best practices. Use when asked to "audit my site", "review web quality", "run lighthouse audit", "check page quality", or "optimize my website".

    Also in 9 projects that use this

  • vijpatel7Skill

    core-web-vitals

    Optimize Core Web Vitals (LCP, INP, CLS) for better page experience and search ranking. Use when asked to "improve Core Web Vitals", "fix LCP", "reduce CLS", "optimize INP", "page experience optimization", or "fix layout shifts".

    Also in 10 projects that use this

  • ufodev-ioSkill

    security-guardian

    Comprehensive security layer for all interactions with Claude: audits code, dependencies, commands, configs, and AI-generated output for vulnerabilities. Protects against prompt injection, data leaks, unsafe advice, and social engineering. Works in Cursor, Claude Code, claude.ai, and API contexts. Use always as a background security protocol in any Claude-powered environment.

    Also in 3 projects that use this

  • mijunriSkill

    database

    数据库脚本与操作规范。脚本放在 db_scripts 目录,遵循查询优化、事务、安全等实践。

    Also in 6 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 52 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Reproduce: Write the exact steps, or add a probe command to the agent CLI or the debug bridge (test-windows-app skill) that runs the slow …

    line 21
  2. Very specific:

    Read traces as text where you can: see "Measuring" in recipes.md.

    line 44
  3. Distinctive:

    Show first, work after: Put the window or panel on screen in the same frame as the key press, then load.

    line 60
  4. Distinctive:

    Do not animate what must be fast: Search results and switchers update in place.

    line 68
  5. Distinctive:

    Write Direct3D or compute shaders only when a measurement shows XAML, composition, or Win2D is too slow.

    line 81
  6. Very specific:

    Keep frames as IDirect3DSurface or a D3D11 texture between capture, processing, and encoding.

    line 83
  7. Very specific:

    Use NativeAOT for tray utilities, launchers, and panels.

    line 89

“Common” is measured: kept by at least 6 in 10 of the 52 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Performance

Fast means two numbers: the first frame after a key press shows in under 100 ms, and nothing on the UI thread blocks for more than 50 ms. Every change in this skill starts and ends with a measurement, so you know it helped. Symptom-by-symptom fixes are in recipes.md. For video, audio, camera, Direct3D, or large image pipelines, also read gpu-media.md.

The loop

reproduce -> measure (Release build) -> find the line -> fix -> measure again -> commit with the numbers
  1. Reproduce. Write the exact steps, or add a probe command to the agent CLI or the debug bridge (test-windows-app skill) that runs the slow action and logs the time of each step.
  2. Measure the Release build. ./build.ps1 builds Release by default; -Dev builds Debug, which turns off JIT optimizations and points at the wrong code.
  3. Find the line. Pick the tool for the symptom:

    SymptomTool
    App freezes, "Not responding"dotnet-stack report -p <pid>, then read the UI thread's stack (the one in Microsoft.UI.Xaml)
    Slow actiondotnet-trace collect -p <pid> --duration 00:00:00:10, then dotnet-trace report <file> topN -n 30
    Short freezes while typing or draggingA UI-thread watchdog in the app (recipes.md, "Measuring"), or WPR with the XAMLAppResponsiveness profile
    Stutter while scrolling or animatingWPR -start GPU -start DesktopComposition, opened in WPA
    Memory growsdotnet-counters monitor -p <pid> --counters System.Runtime, then dotnet-gcdump collect -p <pid>
    Fan, batterydotnet-counters CPU usage while idle; look for timers and polling
    Slow launchTime from Process.Start to the first answer (recipes.md, "Startup")

    The .NET tools install once: dotnet tool install --global dotnet-trace (and dotnet-counters, dotnet-stack, dotnet-gcdump). Ask before installing. WPR ships with Windows; WPA comes with the Windows Performance Toolkit. WPR needs an elevated terminal.

    Read traces as text where you can: see "Measuring" in recipes.md. Delete every .nettrace, .gcdump, and .etl after reading. They hold process command lines, file paths, and memory contents. Never commit or share one.

  4. Fix with the matching recipe.
  5. Measure again with the same steps. Put before and after in the commit message: "Picker opens in 40 ms, was 600 ms".

The rules that fix most problems

  • The UI thread does UI only. File, network, database, image decoding, cross-process Win32 calls, and audio go elsewhere. A UI-thread call that waits on another process (SendMessage to a hung window, a COM call into another app) freezes the app for as long as that process hangs.
  • Show first, work after. Put the window or panel on screen in the same frame as the key press, then load. Never make the UI wait for the work.
  • Let the GPU composite. XAML renders through the compositor. Large images go in an Image once; pointer movement changes only a small element's transform. Never redraw a full-screen bitmap per pointer event.
  • Decode at display size. BitmapImage.DecodePixelWidth, or BitmapDecoder with a BitmapTransform, cached by path and size.
  • Do not animate what must be fast. Search results and switchers update in place.
  • Virtualize long lists, defer hidden UI. ListView or ItemsRepeater for lists, x:Load="False" for panels most people never open.
  • No polling without a reason. Timers stop when nothing on screen needs them.

Windows and .NET notes

  • XAML layout, the compositor, Direct2D (Win2D), Direct3D, Media Foundation, and Windows.Media.Ocr already use the GPU or hardware blocks. Hand them the work instead of looping over pixels in C#.
  • Write Direct3D or compute shaders only when a measurement shows XAML, composition, or Win2D is too slow. Most apps never need it.
  • Keep frames as IDirect3DSurface or a D3D11 texture between capture, processing, and encoding. Converting to a SoftwareBitmap and back costs copies through CPU memory.
  • For start time, NativeAOT beats everything else: tools/publish.ps1 -Aot. Measured on the template, cold start to the main window: about 420 ms self-contained JIT, 170 ms NativeAOT. ReadyToRun gained only about 10%. Use NativeAOT for tray utilities, launchers, and panels; the distribute skill has the setup (the MSVC linker) and the trim-warning fixes.

Done when the slow action has a measured before and after, the after meets the two numbers at the top, and the commit message names both.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.