Logo: Melech Tidy

Melech Tidy

Communautéit
AdirD
melech-tidy

Adaptive diff reduction — prune dead code residue, shake prompt bloat, remove cosmetic diff noise, and propose edge-case trades that drop rare-case handling for a smaller diff before opening a PR.

Iwwersiicht

EditeurAdirD
Repositoryagent-shell-hamelech
Skill-Nummmelech-tidy
Stären
46
Forks
5
Matgeliwwert Dateien
5
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 5 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    AdirD huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Melech Tidy an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/AdirD/agent-shell-hamelech/tree/main/skills/melech-tidy
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AdirD/agent-shell-hamelech.git /tmp/agent-shell-hamelech
mkdir -p .claude/skills
cp -r /tmp/agent-shell-hamelech/skills/melech-tidy .claude/skills/melech-tidy
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Melech Tidy an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Melech Tidy automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Melech Tidy net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Tidy

You just finished coding with an AI agent. The feature works and tests might pass, but git status shows a messy diff: orphaned helpers from earlier prompts, dead types, bloated prompt instructions, cosmetic churn that obscures the real change, or retries and special cases for situations that almost never happen.

melech-tidy is the universal, adaptive diff reduction engine.

Instead of forcing you to diagnose whether your diff suffers from dead code, prompt bloat, cosmetic noise, or rare-case handling that costs more than it buys, melech-tidy audits your diff, categorizes findings into four mutually exclusive reduction lanes, presents a concrete evidentiary table, and executes surgical cleanups with your approval. Every lane only recommends; you choose what gets tidied.

Tidy subtracts; it does not move code between seams or re-architect.


The 4 Mutually Exclusive Reduction Lanes

The agent reads the requested outcome and surrounding code, decomposes the diff into findings, and evaluates each reducible finding against one strictly delineated engine. Not every changed hunk needs a recommendation.

text
                              Incoming Working Diff
                                        │
                         Decompose into isolated findings
                         (semantic edits absorb inseparable
                              cosmetic surroundings)
                                        │
                    ┌───────────────────┴───────────────────┐
                    ▼                                       ▼
          Canonical artifact unchanged?              Semantic change
                    │                                       │
                    ▼                         ┌─────────────┴─────────────┐
              Diff noise                 [Code / Config]       [Prompt / Rules]
          (Cosmetic-only churn)                 │                      │
                                  Does deleting it change              ▼
                                  observable behavior in any case?   Prompt bloat
                                     ┌──────────┴──────────┐
                                     ▼ no                  ▼ yes, a rare case
                                 Dead code           Edge-case trade

Lanes are mutually exclusive by what the proposed action changes, not by what the code looks like:

Proposed actionLane
Restores representation; canonical artifact unchangedDiff noise
Deletes or collapses code; nothing observable changesDead code
Edits prompt or instruction textPrompt bloat
Deletes or simplifies code and changes behavior in a rare caseEdge-case trade

When the same lines allow two actions (replacing hand-written code with a sibling helper that differs in one rare case), report one finding under the lane of the recommended action and name the alternative in its evidence.

User-facing labels (always lead with these — never "Lane 1/2/3" in reports, approval options, or summaries):

Short labelFull name
Dead codeDead Code & AI Residue
Prompt bloatInstruction & Prompt Bloat
Diff noiseCosmetic Diff Noise
Edge-case tradeEdge-Case Trades (80/20)

Lane numbers below are internal section anchors only.


Lane 1: Dead Code & AI Residue (Garbage Collection)

  • Target: Code added or modified during AI iteration that is uncalled, orphaned, or unneeded.
  • Core Philosophy: Inverted Burden of Proof. Every added symbol is assumed guilty (residue/dead code) until proven innocent.
  • The 4 Evidentiary Proofs:
    1. Reachability Proof: Can runtime execution actually reach this from an active entrypoint (route, UI component, CLI command, export, or event handler)? If not → Purge.
    2. Requirement Proof: Which explicit user prompt required this? If the answer is "in case we need it later" → Strip YAGNI.
    3. Non-Duplication Proof: Does an existing helper, sibling feature, standard library utility, or dependency option already do this? Search by purpose, not only by name, and read dependency source when a branch guards against something the dependency may already handle. If so → Collapse.
    4. Breakage Proof: If deleted right now, does any test or behavior break? If nothing fails and no behavior shifts → Remove.
  • Action: Subtraction only (delete dead functions, types, props, imports, and zombie chains).
  • Deep playbook: references/lane-1-dead-code.md — inverted burden of proof, the 4-tier residue classification, and call-graph/zombie-chain tracing.

Lane 2: Instruction & Prompt Bloat (Prompt Shake)

  • Target: System prompts, skill files (SKILL.md), rule instructions (.cursorrules, AGENTS.md), and markdown prompt docs in the diff.
  • Core Philosophy: Minimal-that-covers beats maximal. Every line is guilty until proven load-bearing. Subtraction, not redesign.
  • The 5 Prompt Proofs:
    1. Coverage: If cut, does a real required case fall through? If not → Cut.
    2. Redundancy: Is this already stated elsewhere in the instruction? If so → Collapse.
    3. Subsumption: Is this rule a subset of a broader rule present? If so → Fold in.
    4. Default Knowledge: Would a competent model do this unprompted? If so → Cut.
    5. Load-Bearing: Does agent output actually degrade without this line? If not → Cut.
  • Action: Subtraction inside the diff window (strip filler, redundant edge cases, and over-explanation).
  • Deep playbook: references/lane-2-prompt-shake.md — the targets it hunts, the 5 proofs in full, and the leanness-≠-lossy guardrails.

Lane 3: Cosmetic Diff Noise (Canonical-Equivalence Cleanup)

  • Target: Standalone, cosmetic-only findings whose representation changed but whose canonical artifact and intended meaning did not.
  • Core Philosophy: Context first, proof or keep. A moved line is not noise merely because it moved. Read the requirement and surrounding code, then prove canonical equivalence with repository-appropriate tools. If proof is unavailable or the change mixes with a semantic edit, keep it out of this lane.
  • The 4 Evidentiary Proofs:
    1. Intent Proof: Is the change unrelated to the required behavior or instruction effect? A declaration moved to fix scope, timing, or ordering is semantic and does not qualify.
    2. Canonical-Equivalence Proof: Are the before/after artifacts structurally identical after only safe normalization (for example, the same parsed code structure, Markdown structure plus instruction text, or resolved dependency graph)?
    3. Significance Proof: Is the changed whitespace, order, line ending, or metadata inert for this language and repository? Never assume imports, indentation, file modes, comments, snapshots, or generated output are cosmetic.
    4. Revert-Safety Proof: Can the cosmetic delta be restored to the base representation while required formatter, generator, build, and test checks remain green?
  • Action: Restore representation only (revert cosmetic hunks or regenerate with the repository's expected tool). Never rewrite semantics or hand-edit generated output under this lane.
  • Deep playbook: references/lane-3-diff-noise.md — finding decomposition, canonical proofs by artifact type, mixed-hunk ownership, and fail-closed traps.

Lane 4: Edge-Case Trades (80/20)

  • Target: Live, working code in code/config files whose only job is a rare case: retries for rare races, special-case error messages, defensive try/catch around recoverable steps, and guards stricter than the repo's precedent.
  • Core Philosophy: Name the loss, then let the user trade. Find code that can go if we accept losing a rare case, so the diff shrinks where it buys the least. Never present a trade as equivalent.
  • The 5 Trade Proofs (all must hold):
    1. Frequency: What triggers the case, and how rare is it? Unknown frequency raises the risk.
    2. Consequence: Without the handling, does the user see a visible, recoverable error? Silent wrong results, data loss, duplicate charges, or leaks are not tradable.
    3. Recovery: Is there a cheap way out, such as retrying or pasting again?
    4. Precedent: How do sibling features handle the same case? Handling above precedent is tradable; below it is not, and handling required by a repo rule stays.
    5. Savings: Which lines, tests, constants, helpers, and concepts disappear? Small savings with a real loss is not worth recommending.
  • Hard floor: Security and auth, tenant or user isolation, data integrity, money, and privacy may only come down to the repo's precedent, never below it, and the finding says a security reviewer should confirm.
  • Action: Recommend the trade with its loss stated; once approved, delete the handling and everything that only served it, and update docs that describe the dropped case.
  • Deep playbook: references/lane-4-edge-case-trade.md — targets, the 5 proofs, the hard floor, and example rows.

Workflow

text
1. Resolve Scope  ──►  2. Adaptive Diagnosis  ──►  3. Present Evidence  ──►  4. Ask Approval  ──►  5. Tidy & Verify
  (Prompt or Flag)      (Route by lane name)        Unified Table             (ask_question)       (Tests green)

Step 1: Resolve Scope

Confirm the diff boundary before auditing. Default to uncommitted changes unless specified:

  • Uncommitted working tree (staged + unstaged git diff) — default
  • Branch vs base (e.g. origin/main...HEAD or main...HEAD)
  • Last N commits (e.g. HEAD~2..HEAD)
  • Specific file or path

If the target is ambiguous, prompt the user with ask_question.


Step 2: Adaptive Diagnosis & Lane Routing

Inspect the requested outcome, surrounding context, and diff. Route reducible findings, not files blindly:

  1. Decompose the diff:
    • Use git diff hunks as input, then separate independent findings when safe.
    • If cosmetic lines are inseparable from a semantic edit, the semantic lane owns the whole finding.
    • Keep intentional, necessary, well-placed changes without manufacturing a tidy recommendation.
  2. Check standalone cosmetic candidates across all file types:
    • Compare base and changed artifacts with repository-appropriate parsers, formatters, or normalized representations.
    • Route to Diff noise only when all 4 proofs hold. No proof means keep it out of this lane.
  3. For semantic changes in code/config files (.ts, .py, .go, .rs, etc.):
    • Trace the call graph upwards to find callers. Flag unreferenced symbols and zombie chains under Dead code.
    • Search sibling features, the standard library, and dependency options by purpose for anything new code reimplements. Flag duplicates under Dead code.
    • List the cases each branch, catch, retry, fallback, special message, and extra check exists for. Run the 5 trade proofs and flag rare-case handling worth giving up under Edge-case trade. Run this lane on every tidy, even when the user did not ask for trade-offs.
  4. For semantic changes in prompt/instruction files (.md, .prompt, .cursorrules, etc.):
    • Audit changed lines against the 5 prompt proofs under Prompt bloat.

Step 3: Present Unified Evidence & Diagnosis Table

Output a clean, scannable table grouped by lane before modifying any code. In the Lane column, use the short labels (Dead code, Prompt bloat, Diff noise, Edge-case trade) — never lane numbers. What we lose is — for every lane except Edge-case trade, where it states the lost case from the user's side.

markdown
### 🧹 Tidy Audit Results (Scope: uncommitted diff)

| Lane | Target | Issue / Evidence | Proposed Action | What we lose | Risk |
|---|---|---|---|---|---|
| **Dead code** | `src/utils/date.ts:L40` (`formatDateV2`) | **Reachability**: 0 callers across repo. | Delete dead helper | — | Low |
| **Dead code** | `src/types/user.ts:L15` (`DraftRole`) | **Breakage**: Unreferenced enum variant. | Delete variant | — | Low |
| **Prompt bloat** | `skills/deploy/SKILL.md:L18` | **Default Knowledge**: Explains how git commit works to the model. | Cut line | — | Low |
| **Diff noise** | `src/routes/admin.ts:L20-L45` | **Canonical equivalence**: Formatter-only delta; parsed structure is unchanged and format check passes after restore. | Restore base formatting | — | Low |
| **Edge-case trade** | `src/connect/service.ts:L120-L134` (retry on 400) | **Frequency**: only when two users connect the same site within a second. **Recovery**: connecting again succeeds. **Precedent**: no other connector retries. | Drop retry, `RETRY_DELAY_MS`, `delay()`, and its test | One of two simultaneous connects fails and must be retried | Low |

If no rare-case handling passes the 5 trade proofs, say so in one line under the table instead of omitting the lane silently.


Step 4: Request Explicit User Approval

Never alter files or delete code without human sign-off.

Prompt the user using ask_question:

  • Question: "How would you like to proceed with the tidy recommendations?"
  • Options:
    1. (Recommended) Apply all recommendations (dead code, prompt bloat, diff noise, and edge-case trades)
    2. Apply only behavior-preserving cleanup (dead code + prompt bloat + diff noise; skip edge-case trades)
    3. Let me select specific items from the table
    4. Cancel (Keep working tree unchanged)

Omit option 2 when there are no edge-case trades.


Step 5: Surgical Tidy & Verification

Once approved:

  1. Apply diff noise: Restore approved cosmetic-only findings to their base representation; use the expected generator/formatter instead of hand-editing generated files.
  2. Apply dead code: Delete dead functions, types, and unreferenced imports.
  3. Apply prompt bloat: Strip bloat from prompt/instruction docs within the diff window.
  4. Apply edge-case trades: Delete the approved handling and everything that only served it (constants, helpers, imports, tests). Keep a test that the main path still works, and update docs and comments that describe the dropped case.
  5. Preserve Load-Bearing Context: Keep load-bearing comments and intent notes intact.
  6. Run Verification:
    • Run tests (npm test, pytest, cargo test, go test).
    • Run type checks / builds (tsc, mypy, cargo check).
    • If tests fail, fix immediately or revert the offending change.
  7. Report Summary (lead with lane names, not numbers):
    • What changed under Dead code, Prompt bloat, Diff noise, and Edge-case trade
    • For each applied trade, the case the code no longer handles
    • Lines removed / added
    • Files cleaned or reverted to clean state
    • Verification status (e.g. All 36 tests passing green)

Do / Don't

  • Do treat dead-code deletion (Dead code), prompt shaking (Prompt bloat), cosmetic restoration (Diff noise), and rare-case trades (Edge-case trade) as distinct, mutually exclusive disciplines.
  • Don't rewrite a working architecture; tidy subtracts.
  • Do prove reachability with a concrete call graph before claiming code is dead.
  • Don't say "this looks unneeded" without citing callers and requirements.
  • Do search sibling features by purpose before keeping new code that solves a problem the repo already solved.
  • Don't cut behavior outside Edge-case trade, and never call a trade equivalent or "minimized"; every trade names what is lost.
  • Don't trade security, isolation, data integrity, money, or privacy below the repo's precedent.
  • Do read why a line moved and prove canonical equivalence before calling it cosmetic.
  • Don't classify imports, declaration moves, whitespace, generated files, or file modes as noise from appearance alone.
  • Do fail closed: uncertain cosmetic candidates stay in the diff and out of Diff noise.
  • Do require explicit human approval via ask_question before modifying code.

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Melech Tidy?

Adaptive diff reduction — prune dead code residue, shake prompt bloat, remove cosmetic diff noise, and propose edge-case trades that drop rare-case handling for a smaller diff before opening a PR.

Firwat Melech Tidy op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Melech Tidy besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Melech Tidy an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/AdirD/agent-shell-hamelech/tree/main/skills/melech-tidy an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Melech Tidy benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Melech Tidy benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Melech Tidy domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Melech Tidy gratis?

Jo. AdirD huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇