Skip to content

feat(skills): add codebase-simplification-audit, a read-only whole-repo simplification audit - #784

Merged
pekral merged 1 commit into
masterfrom
codebase-simplification-audit
Aug 25, 2026
Merged

pekral merged 1 commit into
masterfrom
codebase-simplification-audit

Conversation

@pekral

@pekral pekral commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Closes #777

Summary

Nový skill codebase-simplification-audit. Spouští se jen když uživatel požádá o audit codebase nebo se rozhodne refaktorovat nějakou její část — a odpovídá cílovou reprezentací, ne názorem. Je audit-only: neupraví soubor, nespustí test, nic nekomituje ani nepushne.

Proč nový skill a ne rozšíření existujícího

Prošel jsem sousední skilly a žádný tenhle záběr nepokrývá; hranice je proto napsaná přímo ve skillu, aby se nález nehlásil dvakrát:

skill co vlastní proč to není tenhle případ
class-refactoring jedna třída, v MODE=apply mění kód tenhle je celorepozitářový a nikdy nic nemění
automation-audit-ops automatizace repa (workflow, hooky, skripty) ne datový model kódu
production-audit verdikt ship / block před releasem ne to, jak má kód vypadat
blueprint jeden cíl → sekvenční multi-PR plán ranked výstup tohohle auditu je jeho vstup
analyze-problem root cause nahlášeného problému tenhle startuje bez jakékoli stížnosti

Čtyři fáze

1. Coverage contract. Inventura každého subsystému: stabilní ID, přesná nepřekrývající se hranice vlastnictví, klíčové soubory, veřejná rozhraní, call sites, testy, status (queued / in review / recommend / skip). Souhrnný řádek typu „S9 — všechno ostatní" nedokazuje nic a je sám o sobě vadou pokrytí — musí se rozpadnout na skutečné hranice dřív, než začne první review.

2. Ohraničené subsystémové review. Jeden worker = jeden subsystém, nejvýš dvě materiálně užitečné simplifikace. Hledá se šest vzorů: rozházené booleany a nullable pole připouštějící nevalidní kombinace → stavový automat / discriminated union; opakované předpoklady o tvaru objektu → sdílený typovaný model; duplikované větvení → mapa / registry / reducer / command; nejasné vlastnictví stavu → hranice modulu; opakované scany a lookupy → vhodnější kolekce nebo index; lifecycle / concurrency stavy připouštějící zastaralý nebo protiřečící si stav. Každé doporučení nese všech osm polí (verdict, file:line evidence, dnešní nevalidní stavy, navržená reprezentace, nejmenší scope, rizika, validace, confidence). skip je dokončené review, ne selhání.

3. Validace a syntéza. Koordinátor sám ověří každý nález proti kódu — přečte citované řádky, nevěří workerovu shrnutí. Zamítá vágní, duplicitní, nálezy mísící úmyslnou sémantiku a hlavně ty, které komplexitu jen přesouvají za nový typ — což je nejčastější falešně pozitivní nález tohohle auditu.

4. Audit auditu. Pět nezávislých průchodů: pokrytí, překryv vlastnictví, materialita a over-abstraction, úplnost schématu, dependency-aware ranking. Když průchod pokrytí najde skutečné opomenutí, přidá se řádek subsystému a audituje se — nikdy se nezakryje rozšířením hranice, která už byla označená za hotovou.

Adaptace na tenhle repozitář

  • Bez agentů. Zadání předpokládá „fresh read-only agents where available". Balíček agenty už nedodává, takže skill má obě větve: paralelní workery, když je host poskytuje, jinak sekvenčně inline po jednom subsystému. Režim mění wall-clock cenu, nikdy ne coverage contract — žádný řádek se nesmí přeskočit proto, že je drahý.
  • Čte CLAUDE.md auditovaného projektu podle kontraktu z #782. Projektové instrukce často deklarují úmyslnou sémantiku, která ze „simplifikace" dělá nedorozumění.
  • Scratchpad je scratch. Pracovní soubor jde do session scratchpadu a na konci se maže podle Temporary-file hygiene; deliverable je vrácený report.

Changes

# co zadání chtělo commit SHA nezávislost
A1 nový skill spouštěný jen na audit/refactor, cílem nejpřesnější čisté řešení feat(skills): add codebase-simplification-audit, a read-only whole-repo simplification audit 055207b independent

Jeden commit: SKILL.md, jeho piny, README a CHANGELOG jsou jedna vertikální vrstva. Rozdělení po vrstvách by dalo commit se skillem, na který nic neukazuje.

Jak otestovat

  1. composer build — zeleně: 391 testů, 2699 assertions, 100 % coverage.
  2. composer skill-check — nový skill na 100 % rozpočtu bez warningu (jediný warning v reportu je zděděný resolve-issue, viz TODO v #782).
  3. README hlásí 64 skillů a nový skill je v tabulce Code Review, Security & Architecture.
  4. Vyžádej si audit (/codebase-simplification-audit) na malém repu a zkontroluj, že výstup nese tabulku Coverage se statusem u každého řádku a že se v pracovním stromu nic nezměnilo (git status čistý).

Piny

Dva nové testy v tests/Installer/SkillsContentTest.php drží read-only povahu, coverage contract, schéma o osmi polích, odmítnutí přesunuté komplexity, sekvenční fallback bez agentů a hranici vůči pěti sousedním skillům (u každého se navíc ověřuje, že cílový soubor existuje). Zafixováno jako substr_count(...)->toBe(1, $msg) — nese zprávu i unikátnost, podle poznatku zapsaného v #783. Pin ověřen mutate-and-revert (mutace vrácena inverzním sed, ne git checkout --).

…po simplification audit

Closes #777

The skill runs only when the user asks to audit the codebase or has
decided to refactor part of it, and answers with the target
representation rather than an opinion.

Four phases. Inventory every subsystem as an explicit coverage contract
— stable ID, exact non-overlapping ownership boundary, key files,
interfaces, tests, status — where a catch-all row is itself a coverage
defect. Review each subsystem inside its boundary for at most two
materially useful simplifications, each returned with all eight fields
(verdict, file:line evidence, current invalid states, proposed
representation, smallest scope, risks, validation, confidence).
Independently verify every finding against the code before accepting it,
rejecting anything vague, duplicated, semantics-misreading, or merely
relocating complexity behind a new type. Then audit the audit across
coverage, ownership overlap, materiality, schema completeness and
dependency-aware ranking, adding a real subsystem row for any omission
instead of broadening a finished boundary.

Parallel workers are used where the host provides them, sequential
inline review otherwise — the execution mode changes the wall-clock
cost, never the coverage contract. Audit-only throughout: no file
edited, no test run, nothing committed or pushed.
@pekral

pekral commented Aug 25, 2026

Copy link
Copy Markdown
Owner Author

Status: converged
Counts: Critical 0 · Moderate 0 · Minor 0 · Refactoring 0
Last updated: head 055207b

Summary: assignment conformance: conformant — issue #777 asked for a skill that fires only on an audit / refactor request and produces the cleanest achievable answer; all four phases of its brief landed verbatim in intent (coverage contract with per-subsystem ownership boundaries, bounded reviews capped at two findings carrying the eight-field schema, independent coordinator verification, and the five audit-the-audit passes), together with the six look-for patterns, the four explicit non-reasons for a recommendation, and the issue's own completion criteria as ## Done when · reviewer comments: none · linked issue #777 · non-Laravel package, so no Architecture section; no database operation, so no Database Analysis section · the diff adds no executable line, so the coverage gate reports nothing — composer build green at 391 tests / 2699 assertions / 100% coverage.

Verified during the review: every @rules/* and @skills/* path the new skill cites resolves to a real file on disk (4 rules, 6 skills); the boundary test additionally asserts file existence for the five neighbouring skills, so a renamed skill breaks the build rather than leaving a dangling pointer. Body is 184 lines against the 500-line cap and reports 100% of the token budget with no warning. The new pin was verified load-bearing by mutating **The inventory is the coverage contract.**, observing SkillsContentTest go red, and reverting with an inverse sed rather than git checkout -- (the data-loss trap recorded in PR #783).

Two documented divergences from the issue text, both deliberate:

  1. The brief says "use fresh, read-only agents where available". This package stopped shipping agent definitions in PR refactor(agents)!: drop the bundled subagent definitions, ship rules and skills only #781, so the skill carries both branches — parallel workers when the host provides a subagent facility, sequential inline review otherwise — and states explicitly that the execution mode changes wall-clock cost but never the coverage contract.
  2. The brief's "one canonical scratchpad or report" is resolved as: scratchpad in the session scratchpad directory, deleted on completion per @rules/compound-engineering/general.mdc Temporary-file hygiene; the returned Markdown report is the deliverable. Keeping the scratchpad would have left an artifact that rule forbids.

@pekral
pekral marked this pull request as ready for review August 25, 2026 14:16
@pekral
pekral merged commit e857cd2 into master Aug 25, 2026
1 check passed
@pekral
pekral deleted the codebase-simplification-audit branch August 25, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New skill

1 participant