agentleFS
r-irber-irbe/proof-skills/skills/lean-proof-refactor/SKILL.md

lean-proof-refactor

Skill3 starsChanged 24 days agoApache-2.0View on GitHub

USE FOR: slimming long proofs after they are proven (decomposition into reusable lemmas). DO NOT USE FOR: reviewing proofs for correctness (@lean-proof-review). TRIGGERS: long-proof, decompose proof, slim proof, helper-lemma extraction.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    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
  1. Very specific:

    If a candidate helper extraction fails to compile or increases total proof complexity without reuse, revert the cut and record a …

    line 41

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Lean Proof Refactoring (post-hoc proof slimming)

A proven proof that is long is a maintenance liability and a reuse opportunity. This skill runs the campaign loop that turns long proofs into short callers plus named, reusable lemmas - without regressions.

Routing

  • USE FOR: finding and adjudicating long-proof findings; extracting shared lemmas; running multi-batch refactor campaigns.
  • DO NOT USE FOR: first-time proving, correctness review, tautology triage.

Workflow

  1. Find - scan the corpus for long proofs. A generic scanner exists: scripts/lean/proof_quality.py --lean-dir <dir> --output <report.md> (line count + branch points + style classes). Repos wrap it with their own config defaults; never edit the scanner per-repo.
  2. Adjudicate each finding against one test: can a generic block be named once and called elsewhere? Three verdicts:
    • CUT - extract the shared lemma (see 3).
    • CONSIDERED-NEGATIVE - the proof is single-use glue; record the reason in the tracking doc. Forcing a cut creates single-use lemmas (the bundle effect: extraction that only relocates length).
    • DEFER - branchy or threshold-sitting proofs wait for a calmer window (2 branch points + 50 lines is the sweet spot).

Recovery & STOP

  • If a candidate helper extraction fails to compile or increases total proof complexity without reuse, revert the cut and record a CONSIDERED-NEGATIVE entry in the batch ledger.
  • On transient stale-.olean errors in shared build directories, retry the targeted build once before diagnosing a proof regression.

Handoffs

  • Predecessors: lean-proof (the proof exists), lean-quality-engine (findings).
  • Successors: lean-proof-review (audit the extraction), lean-proof (fix the caller).

Detailed reference

Full encyclopedic reference, decision trees, and lookup tables live in references/lean-proof-refactor-handbook.md .

See also

  • ../../references/lean-proof-refactor-handbook.md -- Complete lean-proof-refactor Handbook
  • ../lean-gateway/SKILL.md -- Top-level skill router

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.