.claude/skills/review-blocking/SKILL.md
Discover functions that block the main thread, then micro-audit each for internal optimization opportunities
npx skillsauth add cwilliams5/Alt-Tabby review-blockingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Enter planning mode. Two-phase audit: first discover which functions block the main thread using mechanical criteria, then micro-audit each function's internals for optimization opportunities. Use an agent team for the audit phase — the per-function work is embarrassingly parallel.
review-latency traces paths end-to-end (window change → store, user action → pixels) and cares about ordering, compound cost, and whether something is on the critical path. This skill opens each function in isolation and asks "can this be faster internally?" without caring about callers, frequency, or path position. The different framing surfaces different findings — path-tracing skips a function that's "only called once," but micro-auditing still catches the redundant array copy inside it.
Find functions that block the main thread using these criteria. The criteria are mechanical — use grep and query tools, not judgment.
These functions block the main thread by definition:
Critical "On" — they hold an interrupt lock. Every microsecond inside Critical delays pending hotkey/timer callbacks.query_timers.ps1 to inventory all timer callbacks in src/core/ and src/gui/.Hotkey( registrations and the callback functions they reference.DllCall("SetWinEventHook" callbacks. These fire on every focus change, window create/destroy.These functions have cost that scales:
for loops, Loop blocks iterating collections. Cost scales with collection size.Shader_PreRender has 40+ ComCalls per invocation (D3D11 state setup, compute dispatch, Draw, GPU readback) and runs N times per frame (once per active shader layer). FX_PreRenderShaderLayers loops over all active layers calling Shader_PreRender each.Array(), Map(), .Push(), .Clone() inside a function body. Allocation cost.For each Tier 1/2 function, identify its direct callees (depth 1 only) using query_callchain.ps1 -Depth 1 (or query_function_visibility.ps1). Add those to the audit list. Do NOT recurse further — if a helper's helper is slow, the parent function's audit will surface the call cost.
Produce a categorized function list:
| Function | File | Tier | Reason |
|----------|------|------|--------|
| _WEH_WinEventProc | winevent_hook.ahk | 1 | WinEvent callback + Critical |
| GUI_Repaint | gui_paint.ahk | 1 | Timer callback |
| Blacklist_IsMatch | blacklist.ahk | 3 | Called by Blacklist_IsWindowEligible (Tier 2) |
Only functions in src/core/ and src/gui/ (plus src/shared/ files they call into). Exclude src/lib/ (third-party), src/editors/ (not on main thread during Alt-Tab), src/pump/ (separate process).
Use query_state.ps1 to determine if a blocking function is only reachable from specific state machine branches — a function that blocks only during IDLE is less critical than one that blocks during ACTIVE.
Use an agent team. Split the discovery list into batches and assign each batch to a parallel agent. Each agent reads the function body (use query_function.ps1 <funcName>) and audits it in isolation.
The rule: changes must be invisible to callers. Same inputs → same outputs → same side effects. Only internal implementation changes.
Redundant work:
Allocation waste:
static buffers reused across calls — EXCEPT in functions reachable during STA pump (paint path, COM callers, QPC). Reentrancy overwrites the static buffer mid-use. See ahk-patterns.md Hot Path Resource Rules..Push() in a loop when the final size is known (pre-size with Array(n) if AHK supports it, or use a pre-allocated buffer)Loop inefficiencies:
HasOwnProp() / .Has() checks before access when the key is guaranteed to existDllCall overhead:
"Cdecl" on callbacks (forces slower marshaling)Critical section duration:
Critical "On" ... Critical "Off" that doesn't need the interrupt lockreview-criticals territory. Only suggest moving non-critical work outside the existing boundaries.Cache opportunities:
static locals for values computed once and reused across calls (DPI scaling factors, compiled regex patterns, etc.)review-latency territoryreview-criticals territoryreview-mcode territory (but do note if you spot one, as a cross-reference)For each function, agents report:
| Finding | Line(s) | Current | Proposed | Est. Saving | Complexity |
|---------|---------|---------|----------|-------------|------------|
| title local read twice from rec.title | 45, 52 | Two property accesses | Cache in local t := rec.title | ~0.5μs | Trivial |
| String concat in 30-iteration loop | 60-65 | s .= item.name "," per iteration | Pre-size or use Array+Join | ~5-15μs | Low |
Est. Saving — be honest. If it's sub-microsecond, say so. The user wants the full picture, not a filtered one.
Complexity — Trivial (one-line), Low (few lines, obvious), Medium (structural change within function), High (requires new static/cache infrastructure).
After the agent team reports, validate every finding yourself. Read the actual function code.
For each candidate:
file.ahk lines X–Y" with actual code quoted.Critical "On", so static buffers in any function reachable from the paint/COM path can be overwritten mid-use).Section 1 — Discovery results:
| Function | File | Tier | Reason | |----------|------|------|--------| | ... | ... | ... | ... |
Total: N functions across M files.
Section 2 — Micro-audit findings (grouped by file):
For each file, list all findings across its functions:
winevent_hook.ahk| Function | Finding | Line(s) | Est. Saving | Complexity | Fix |
|----------|---------|---------|-------------|------------|-----|
| _WEH_WinEventProc | Redundant WinGetTitle call | 88 | ~50μs | Trivial | Cache in local |
gui_paint.ahk| Function | Finding | Line(s) | Est. Saving | Complexity | Fix | |----------|---------|---------|-------------|------------|-----|
Section 3 — Cross-references to other review skills:
| Finding | Function | Relevant Skill | Note |
|---------|----------|---------------|------|
| NumGet loop over icon buffer | _ExtractAlpha | review-mcode | Candidate for native C |
| Critical section holds through file I/O | _SaveState | review-race-conditions | Scope may be too wide |
Order Section 2 by estimated total savings per file (sum of all findings in that file), highest first.
Ignore any existing plans — create a fresh one.
tools
Create a new git worktree and switch the session into it
tools
Spawn agent to trace code flow via query tools — answer only, no context cost
tools
Commit, push, and create a PR for the current branch
tools
Retire a shader by moving its files to legacy/shaders_retired