code-compaction

Detects and reduces bloated code diffs using cross-model adversarial review rounds.

4.3k|872|Updated Jan 10, 2015
One-click install
npx skills add https://github.com/dotnet/fsharp --skill code-compaction
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-compaction
Source: https://github.com/dotnet/fsharp/tree/main/.github/skills/code-compaction
Command: npx skills add https://github.com/dotnet/fsharp --skill code-compaction

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pull request diffs often accumulate bloat: copy-pasted tests, duplicated helpers, unnecessary planning files, bloated comments, and reinvented logic that should have reused existing code. This Skill provides a structured process to detect that bloat and compact the diff without losing behavioral coverage.

Core Features & Use Cases

  • Mode-based routing: Measures the diff (LOC, comment ratio, new helper count) and routes to Garbage Hunt (deletion-only), Test Compaction (parametrization and setup hoisting), or Logic Compaction (reuse-driven rewriting).
  • Cross-model adversarial review: Dispatches 3-5 parallel reviewers across different models and angles, then runs adversarial attack rounds and real prototype branches before picking a winning proposal.
  • Reuse-first compaction: A dedicated reuse-hunt subagent finds existing helpers, visitors, and smart constructors the patch should have used instead of adding new code.
  • Use Case: Before opening a PR whose diff added 150+ lines for one bugfix, run this Skill to identify duplicated logic, delete scaffolding files, and shrink the diff while keeping all tests green.

Quick Start

Review my current branch diff against main for bloat and compact it using the code-compaction process.

Frequently Asked Questions about code-compaction

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce bloat in a pull request diff?

Measure the diff against the merge-base with main to count added lines, comment ratio, and new helpers. Then route to the matching mode: Garbage Hunt for deletable scaffolding, Test Compaction for duplicated tests, or Logic Compaction for duplicated logic.

How to compact copy-pasted tests into parametrized tests?

Test Compaction rewrites repeated test methods into parametrized cases with named scenarios while hoisting shared setup and constants. Coverage must not decrease: every distinct input/output pair must still be exercised and failure messages must still identify the scenario.

When should I not use code compaction on a diff?

Skip it for legitimately large multi-subsystem features, generated artifacts, mechanical churn like dependency bumps or renames, minimal one-line bugfixes, and GitHub prose such as PR or issue text.

Why use multiple models for code review instead of one agent?

Cross-model diversity catches issues that same-model agents with different prompts miss, since three prompts from one model share the same blind spots. Cross-model agreement is treated as signal, while lone-model claims require code citations before being accepted.

What is a reuse hunt in code review?

A reuse hunt dispatches a subagent with semantic search and symbol tools to find existing helpers, visitors, or smart constructors the new code should reuse. It avoids plain grep because substring search misses functions that match by shape but not by name.