codebase-audit
Skill44 starsChanged 57 days agoMITView on GitHub
Use when auditing the imp codebase for structural debt, dead code, god-objects/files, duplication, flag sprawl, or deciding whether a cleanup is worth shipping - "structure audit", "tech debt", "is this still used", "dead code", "refactor for clarity", "should we split this file", "remove this flag", "file size gate red", "alloc sites gate red". Do NOT use for build/test mechanics (building-and-testing), perf/kernel work (benchmark-cuda / sm120-cuda-expert), or output quality (check-degeneration).
15 other projects use a version of this.
Adopted by
Most recently taken up by
- michielvandermeer/skillstheir own version, first seen Oct 4, 2026
- tomwangowa/agent-skillstheir own version, first seen Sep 30, 2026
- 0xkangl/skillstheir own version, first seen Sep 10, 2026
- tderoussel/agent-skillstheir own version, first seen Sep 8, 2026
- myatminlu/vector-skillstheir own version, first seen Aug 19, 2026
- TencentCloudBase/CloudBase-AI-Toolkittheir own version, first seen Aug 17, 2026
Used with
Projects with it also use improve-codebase-architecture, grill-with-docs and 1 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.
AWSSkillimprove-codebase-architecture
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
Also in 3 projects that use this
MicrosoftSkillgrill-with-docs
Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.
Also in 3 projects that use this
MicrosoftSkillhandoff
Compact the current conversation into a handoff document for another agent to pick up.
Also in 3 projects that use this
Other versions15 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 15
- TencentCloudBase/CloudBase-AI-Toolkit★ 1.1ksame name
- GoldenWing-360/claude-security-skills★ 19same name
- mhylle/claude-skills-collection★ 19same name
- myatminlu/vector-skills★ 18same name
- sohei56/maul-team★ 17same name
- michielvandermeer/skills★ 9same name
- frostney/pascal-mcp-sdk★ 2same name
- NitorCreations/nitor-agent-skills★ 2same name
- ReinaMacCredy/Skills★ 2same name
- tomwangowa/agent-skills★ 2same name
5 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- tests/CLAUDE.mdCLAUDE.md
- add-model-archSkill
- benchmark-cudaSkill
- building-and-testingSkill
- check-degenerationSkill
- code-graphSkill
- docs-layersSkill
- docs-syncSkill
- find-stubsSkill
- numerics-bisectSkill
- quant-formatsSkill
- server-apiSkill
- shipping-prsSkill
- sm120-cuda-expertSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 15 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 31
Verify each with the recipes.
- Very specific: line 32
Write up: dated ledger in docs/audit/ (DEBT_LEDGER_2026_08_21.md, AUDIT_ARCH_2026_07_29.md.
“Common” is measured: kept by at least 6 in 10 of the 15 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.
Files
Codebase audit & structural debt - imp
Two hard rules
- A raw finding is a candidate. Fan-out sweeps over-flag: on 2026-06-09 findings C1/C2/C4 were all REFUTED on inspection and several "dead flags/files" were live. Verify each against the code before reporting; the value is in the verification.
- Read
docs/audit/SETTLED.mdBEFORE generating hypotheses. The 2026-07-29 audit generated first: 8 of 13 hypotheses were already-collapsed duplication (its section 15) and 5 facts in its own brief were stale (9 vs 16 architectures, C++20 vs C++23,src/graph/vssrc/exec/; section 19). A candidate that contradicts a ledger entry needs that entry's ANCHOR disproven. Closing a finding updates BOTH the report status line and the ledger (scripts/check-release.shsection 1d fails CI on a stale open entry; F-6, S-10 ("still open" two days after #1209) and section G each went stale for days in the 07-29 campaign).
Verification recipes
| Claim | Check | Trap that fooled a past audit |
| flag/symbol X is dead | rg across src/ tests/ tools/ | dump_tokens, force_bos, bench.generate looked dead in src/, read in tools/imp-cli/main.cpp |
| config field never read | grep the leaf for a value-read in a conditional, excluding decl/parse/copy | a local var with the field's name hid the read (fp8_auto_legacy) |
| kernel/function dead | trace the call graph, not <<< sites; code-graph has NO launch edges right now (ccg enrich broken) so rg the launcher | q4k_imma CACHE was dead; mmq_q4k_imma_tile/_reorder live via q4k_imma_prefill -> mmq_q4k_imma_gemm; only ~30 LOC dead, not "~1200" |
| env var dead | grep docker-entrypoint.sh too | IMP_KV_FP8 read nowhere in src/, translated by the entrypoint into --kv-fp8 |
| god-file, split it | split on conflation or compile-time isolation, not size | gdn.cu, gemm.cu, json_schema.cpp are one domain each; the 7 attention_paged* share attention_paged_common.cuh. Precedent: engine_scheduler.cpp 2230 -> 1291 + engine_prefill.cpp + engine_decode_pipeline.cpp (#1782); gdn_scan_chunkpar.cu -> K1 + gdn_scan_chunkpar_pass.cu + .cuh at the 600-LOC kernel line; sampling family -> executor_sampling.cu (#1790); smallm -> executor_gemm_smallm.cpp (#1793) |
| rewrite into a registry/template | need a concrete bug | the weight_map.cpp if (!matched) ladder is readable; a mis-mapped name = garbage output |
| imp.conf key inert | read in src/ AND tools/? C-API bridge at engine init? | server.prefix_cache was parsed, unread, bridged (#636) |
| a log line proves the code path | compare the printed number against the code that uses it | a CORRECT log line named a number the code did not use (#1746/#1705); the sparse startup line printed the 16-block arithmetic while ACTIVE printed the real one (#1819) |
a number in a .cu is wrong | pull the arithmetic into a pure function + CPU tests at both operating points | src/exec/sparse_attn_geometry.h, 7 tests, 4 fail on the original defect (#1819) |
Workflow
- Ledger first:
docs/audit/SETTLED.md; memory axis: rootAUDIT.md; structural:docs/audit/DEBT_LEDGER_2026_08_21.md(stale[allow]reasons, the "every gate is advisory" prehistory of the blocking gates). Re-derive every brief fact (SETTLED section F lists the five that were wrong, each with a counter-check). - Fan out (Explore agents, grep) AGAINST the ledger.
- Verify each with the recipes; demote refuted ones immediately.
- Write up: dated ledger in
docs/audit/(DEBT_LEDGER_2026_08_21.md,AUDIT_ARCH_2026_07_29.md; olderstructural_debt_*indocs/archive/), append refutations with anchors toSETTLED.md("Refuted (do not re-chase)"); memory findings go to rootAUDIT.md(CONFIRMED / REFUTED / OPEN). Counts are evidence, not estimates. - Ship as small PRs off
origin/main,make build+make test-unit+ hooks (skill building-and-testing, shipping-prs); behavior-sensitive removals also run check-degeneration.
Gates that shape audit findings (scripts/ci_static_gates.sh; all block inside Build since #1527; hooks run them in ~2 s)
| Gate | Tool | Rule |
| File size | tools/check_filesize.py, tools/filesize_thresholds.toml | code LOC (comments/blanks stripped): kernel .cu warn 500 / hard 600, TU 600 / 800, header 500 / 700. [allow] entries { code_loc = N, reason = "..." } are a TWO-WAY ceiling since #1526 (drift either way fails; --update re-pins). Cost metric = recompile blast radius (one .cu = one ptxas TU), so a #included .cu is charged to its includer since #1905 — executor_attention.cu read 542 as a file and 1279 as the TU. Rationale per file: docs/audit/AUDIT_FILESIZE.md. The filesize group also runs check_determinism_sites.py, check_dead_inline_accessors.py, check_log_fatal.py |
| Function size | tools/check_function_size.py, tools/function_size_thresholds.toml | the largest body in a file, warn 200 / hard 500 code LOC (p99 of 5830 functions is 199). Same two-way [allow] ceiling, keyed path::signature. Exists because a file's cohesion reason was covering an 884-line function inside an allowlisted "(c) one concern" file (#1905) |
| Test lanes | tools/check_test_lanes.py --report | own check since #1770; fails on a test in no ctest entry or a unit-lane test demoted vs the base; no-lane count printed with its delta |
| Alloc sites | tools/check_alloc_sites.py + tools/alloc_allowlist.txt, tools/check_alloc_pairs.py | invariant I1 (one module talks to the driver); fails on a new site AND a stale entry (#1479 left gdn.cu's entry behind). Counts SOURCE sites: the T2 slot pool removed ~96% of runtime allocations with a flat site count (AUDIT.md B34); runtime number via make check-alloc-interpose (steady_state_allocations(), never benchmark that build, AUDIT.md G16) |
| Dead inline accessors | tools/check_dead_inline_accessors.py (make check-dead-inline), tools/dead_inline_allowlist.txt | header-inline definitions with no caller |
| Launch guards | tools/check_launch_guards.py | post-launch check present |
| Kernel resources | make kernel-resources, tools/kernel_resource_baseline.txt | register/local-frame ratchet (#1549) |
| Doc citations | scripts/check_doc_citations.py . | a file split moves line numbers and kills file:line in living docs (#1782 -> #1783); docs/audit/ itself is exempt |
Priors: settled, do not re-flag
Canonical: docs/audit/SETTLED.md (collapsed duplication S-1..S-11, deliberate specialisations, hunted-and-absent negatives, findings that were themselves wrong). Not yet in the ledger:
- Two config systems (
RuntimeConfigvsModelConfig::Overrides) are deliberate; keys use the typed binder ladderB/I/F/S(...)(#626); the config surface lives insrc/core/config/*.h. - Structural-debt chain D1-D4 / C1-C8 archived in
docs/archive/README.md, verdicts indocs/archive/housekeeping_2026_06_13.md. Audit #5 (docs/archive/structural_debt_2026_07_07.md, companiondocs/archive/vram_audit_2026_07_07.md): server layer is the debt source, issues #888-#897; read its NOT-flagged list first.src/memory/vram_owned.hEXISTS since #1530 (once a hallucinated finding). - Memory (
AUDIT.md, 2026-07-29): "engine teardowns leak ~15 GiB" is REFUTED as a leak: every CUDA release works, WSL2/WDDM never returns a process's peak commitment. Traps:cudaMallocsuccess proves nothing (28 GiB at 22.6 GiB free; ~1530 vs ~237 GB/s tells),cudaMemPoolAttrReservedMemCurrentdrops to 0 on trim, assert onUsedMemCurrent. - Serving-loop classes closed by measurement: host turnaround (#1791), elementwise/residual fusion (#1793), prefill||decode overlap (#1792), H2D consolidation (#1834). Roadmap item 0(c) complete.
- A refactor that touches
exec/executor.hneeds a forced rebuild (grep -rl exec/executor.h src tools tests | xargs touch && make dev): stale objects segfault and look like the refactor.
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
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.

