.claude/skills/review-shaders-direct/SKILL.md
Incremental HLSL shader audit — grep-driven, no agent swarm, built for codebases with prior optimization passes
npx skillsauth add cwilliams5/Alt-Tabby review-shaders-directInstall 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.
Deep-audit HLSL pixel shaders in src/shaders/ for GPU performance waste. Use direct Grep/Read — do NOT delegate discovery to agents. This skill is designed for codebases that have already been through optimization passes, where most low-hanging fruit is gone and agent swarms produce more false positives than real findings.
Agent swarms scanning for shader optimization patterns have two failure modes after prior passes:
Direct Grep/Read output is ground truth. Build the audit on that.
Count files and get the lay of the land:
find src/shaders -name "*.hlsl" | wc -l
find src/shaders -name "*.hlsl" -printf "%h\n" | sort | uniq -c
Run these Grep queries yourself. Each returns ground-truth file:line matches. Run them in parallel where independent.
Transcendentals:
cos( in files that do NOT contain sincos — find files that haven't been convertedsin(X) and cos(X) with same argument near each other — paired candidatespow( with literal integer/half-integer exponents (2.0, 3.0, 0.5)Loop-invariant rotations:
4. mul(rot( or mul(rotate( — find all rot() call sites
5. Cross-reference with for loops — are any rot() calls inside loops with time-only arguments?
Constant rotations:
6. rot( followed by a literal number (not a variable) — candidates for static const
Algebraic:
7. clamp( — check if any have exact 0.0, 1.0 bounds (→ saturate)
8. fmod( with , 1.0) second argument (→ frac)
9. length( appearing twice with same argument nearby (→ dot for squared)
Conversion artifacts:
10. iMouse in non-mouse shaders — dead code?
11. pow( with 2.0 exponent — should be x*x
For each Grep hit, Read the file at that line to verify:
Critical rule: If Grep returns 0 matches for a pattern, that pattern is clean. Do not report findings that don't exist in Grep output.
Different shaders use different rotation matrix conventions:
float2x2(c, s, -s, c) — one rotation directionfloat2x2(c, -s, s, c) — the transpose (opposite direction)When replacing rot(LITERAL) with static const float2x2, you MUST read the rot() function in that file to determine which convention it uses, then compute sin/cos values accordingly. Getting this wrong silently reverses rotation direction.
For small batches (< 10 files): edit directly with Edit tool.
For large batches (10+ files with same mechanical pattern): you MAY use an agent for bulk edits, but:
git diff --stat after the agent completespowershell -File tests/test.ps1 --live
Then check for bin changes:
git status --short resources/shaders/
HLSL changes MUST have corresponding .bin changes committed together.
Same optimization patterns as /review-shaders — sincos, pow simplification, loop-invariant hoisting, constant rotation matrices, clamp→saturate, fmod→frac, dead code, CSE — but discovered through Grep, not through agent reports.
Cardinal rule: Every optimization must produce visually identical output. Prove mathematical equivalence for each change.
Report only verified findings — patterns confirmed by Grep output AND file reads. Group by pattern:
| Pattern | File:Line | Current Code | Fix | Verified |
|---------|-----------|-------------|-----|----------|
| Paired sin/cos | foo.hlsl:42 | cos(v); sin(v)*1.73 | sincos(v, n, m) | Read confirmed |
Do not include patterns that Grep showed 0 matches for. Do not include files where Read showed the pattern was already optimized.
/review-shaders| Aspect | /review-shaders | /review-shaders-direct |
|--------|-------------------|--------------------------|
| Discovery | Agent swarm (3 Explore agents) | Direct Grep + Read |
| False positive rate | High after prior passes | Zero (tool output is ground truth) |
| Fabrication risk | Agents report non-existent findings | None (you see the Grep output) |
| Planning mode | Yes (full plan workflow) | Optional — skip if findings are small |
| Bulk edits | Agent workers | Direct edits; agents only for 10+ file mechanical changes, verified via git diff |
| Speed | Slower (agent overhead + verification) | Faster (direct tool calls) |
| Best for | First-pass audit of unoptimized codebase | Incremental passes on already-optimized codebase |
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