.claude/skills/review-file-size/SKILL.md
Find files approaching context limits and evaluate whether coupling-aware splits are worthwhile
npx skillsauth add cwilliams5/Alt-Tabby review-file-sizeInstall 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. Identify source files approaching the context load limit and evaluate whether they can be meaningfully split. Use parallelism where possible.
Files over ~25k tokens cause problems: the Read tool must batch them, they bloat context for tasks that only need a small piece, and they're harder to reason about in a single pass. But splitting a file poorly — into two halves that share all the same globals and must always be loaded together — is worse than one large file. A split only helps if the pieces are independently useful.
Scan all .ahk files in src/ and tests/ (excluding src/lib/). For each file, estimate the token count — don't rely on line counts alone. AHK files with long DllCall signatures, inline strings, or dense logic have significantly more tokens per line than sparse files with short functions.
Approximate token estimation: Read each file and estimate tokens. Characters ÷ 4 is a rough baseline, but AHK identifiers and camelCase inflate this. Aim for a reasonable estimate, not exact counts.
Threshold: Only flag files that are approaching trouble — roughly 20k+ tokens. Files well under this threshold are fine regardless of line count. Don't propose splitting a 500-line file that's 12k tokens just because it's "large by line count."
For each file above the threshold, use the tools to assess whether a split is viable:
| Tool | What It Tells You |
|------|------------------|
| query_interface.ps1 <file> | Public functions and globals — are there distinct groups serving different consumers? |
| query_global_ownership.ps1 <globalName> | For each global the file uses — who else writes/reads it? Would a split add manifest entries? |
| query_function_visibility.ps1 <funcName> | For key functions — who calls them? Would splitting require cross-file calls between the halves? |
Look for natural seams:
Look for coupling walls:
For each file where a seam exists, evaluate the net benefit:
Benefits of splitting:
Costs of splitting:
#Include dependenciesOnly recommend a split when the net benefit is clearly positive. A file at 22k tokens with no natural seam is better left alone than forcibly split into two 11k-token files that are joined at the hip.
Section 1 — File size inventory (only files near/above threshold):
| File | Lines | Est. Tokens | Status |
|------|-------|-------------|--------|
| gui_state.ahk | 1400 | ~28k | Above threshold |
| gui_paint.ahk | 900 | ~19k | Approaching |
| viewer.ahk | 1100 | ~22k | Above threshold |
Section 2 — Coupling analysis for candidates:
| File | Natural Seam? | Shared Globals Across Seam | New Manifest Entries | Independently Useful? |
|------|--------------|---------------------------|--------------------|--------------------|
| gui_state.ahk | Yes — interceptor vs state transitions | 2 (gGUI_State, gGUI_Sel) | 0 (both already shared) | Yes — interceptor logic reads different than state logic |
| viewer.ahk | Weak — most functions share gViewer_* | 8 | 4 new entries | No — halves always loaded together |
Section 3 — Recommended splits (only where net-positive):
| File | Split Into | Seam | Tokens Each | Coupling Cost | Benefit |
|------|-----------|------|-------------|--------------|---------|
| gui_state.ahk | gui_state.ahk + gui_interceptor.ahk | Interceptor event handling vs state transitions | ~14k / ~14k | 0 new manifest entries | Tasks investigating input vs state can load one half |
Section 4 — Files left alone (above threshold but not worth splitting):
| File | Est. Tokens | Why Not Split |
|------|-------------|--------------|
| viewer.ahk | ~22k | All functions share 8+ gViewer_* globals — no seam |
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