agentleFS
FrankieeWFrankieeW/agent-skills/leanmgr-cache-manager/SKILL.md

leanmgr-cache-manager

Skill0 starsChanged 8 months agoMITView on GitHub

Use when managing many Lean 4 projects with LeanMgr, especially .lake disk usage, cache cleanup, restore, gitignore, doctor, toolchain, or worktree workflows.

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 6 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use LeanMgr as a local project-fleet tool for Lean 4 cache lifecycle work.

    line 8
  2. Very specific:

    Treat .lake as disposable, recoverable cache.

    line 12
  3. Distinctive:

    Do not modify Lean source files unless the user explicitly asks.

    line 13
  4. Distinctive:

    Do not rewrite Git history.

    line 14
  5. Distinctive:

    Run dry-runs before destructive cleanup.

    line 15
  6. Very specific:

    Prefer leanmgr doctor, leanmgr size, and leanmgr clean --dry-run before deletion.

    line 16
  7. Very specific:

    Prefer leanmgr gc --dry-run for fleet-wide reclamation.

    line 17
  8. Very specific:

    Use leanmgr restore to call lake exe cache get after cache deletion.

    line 28
  9. Very specific:

    Use leanmgr gitignore to ensure .lake/ is ignored before recommending cleanup.

    line 32
  10. Very specific:

    When leanmgr list shows missing in the STATUS column, suggest leanmgr remove --missing --dry-run first.

    line 36
  11. Distinctive:

    Keep the index tidy after projects are moved or deleted:

    line 89
  12. Distinctive:

    Use AI-oriented context output before making recommendations:

    line 97
  13. Very specific:

    Prefer --format json for programmatic pipelines and --format codex or --format claude for coding-agent prompts.

    line 105
  14. Very specific:

    Do not propose shared local mathlib or symlinked .lake/packages/mathlib as a default fix.

    line 126

≈ “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

LeanMgr Cache Manager

Use LeanMgr as a local project-fleet tool for Lean 4 cache lifecycle work.

Rules

  • Treat .lake as disposable, recoverable cache.
  • Do not modify Lean source files unless the user explicitly asks.
  • Do not rewrite Git history.
  • Run dry-runs before destructive cleanup.
  • Prefer leanmgr doctor, leanmgr size, and leanmgr clean --dry-run before deletion.
  • Prefer leanmgr gc --dry-run for fleet-wide reclamation; it skips unrecoverable caches (no lake-manifest.json, no lakefile.toml/ lakefile.lean, or empty lean-toolchain) unless --include-unrecoverable is given.
  • With a size budget, pair --target with --unused-days (for example leanmgr gc --target 20GiB --unused-days 14 --dry-run); --target alone takes the largest caches first even if the user is working in them.
  • leanmgr doctor also reports shared caches (Mathlib downloads, elan toolchains) and toolchains elan toolchain gc considers unused. Suggest elan toolchain gc --delete or lake exe cache clean! only as commands for the user to run; LeanMgr never deletes shared caches itself.
  • Use leanmgr restore to call lake exe cache get after cache deletion. It only runs for Mathlib and projects that depend on it; other projects and missing paths are skipped with a reason (they rebuild with lake build). Preview with leanmgr restore ... --dry-run.
  • Use leanmgr gitignore to ensure .lake/ is ignored before recommending cleanup.
  • A project selector must name an indexed project; clean, restore, size, remove, and gitignore <project> error out on an unknown selector rather than no-op.
  • When leanmgr list shows missing in the STATUS column, suggest leanmgr remove --missing --dry-run first. It only edits the index, but a project on an unmounted drive also looks missing, so let the user confirm.

Workflow

  1. Inspect indexed projects (and find unindexed ones elan knows about):
leanmgr list
leanmgr size --all
leanmgr doctor
leanmgr scan --from-elan
  1. Check project hygiene:
leanmgr gitignore --all --dry-run
leanmgr toolchain check
leanmgr worktree doctor
leanmgr worktree prune --dry-run

leanmgr worktree doctor and worktree prune operate across every indexed project, so they surface and clear stale worktrees fleet-wide, not just in the current directory. Projects sharing one repository are audited once; missing paths and directories outside Git are listed as skipped, not as failures. Without --force, worktree prune shows Git's dry run and asks before pruning.

  1. Plan cleanup before deleting:
leanmgr clean --tag archived --level hard --dry-run
leanmgr clean <project> --level soft --dry-run
leanmgr gc --unused-days 90 --dry-run
leanmgr gc --target 20GiB --dry-run
  1. Execute only after the user accepts the plan or explicitly requests execution:
leanmgr clean --tag archived --level hard
  1. Restore cache when returning to a project:
leanmgr restore --tag active --dry-run
leanmgr restore <project>
leanmgr restore --tag active
  1. Keep the index tidy after projects are moved or deleted:
leanmgr remove --missing --dry-run

AI Context

Use AI-oriented context output before making recommendations:

leanmgr ai context --format codex
leanmgr ai context --format claude
leanmgr ai context --format json

Prefer --format json for programmatic pipelines and --format codex or --format claude for coding-agent prompts.

Skill Installation

leanmgr ai skill show --format <codex|claude> adapts this SKILL.md body to the receiving agent's task contract header. The codex flag ensures the body opens with # Codex Task Contract; claude opens with # Claude Code Task Context. If the body already starts with the matching header it is passed through; a different leading heading is replaced; a missing leading heading is prepended.

Boundaries

LeanMgr complements official tools:

  • Lake owns build, dependency, and artifact cache behavior.
  • Elan owns Lean toolchain installation and selection.
  • Git owns repositories and worktrees.
  • LeanMgr owns cross-project indexing, reporting, dry-run cleanup planning, and safe orchestration.

Do not propose shared local mathlib or symlinked .lake/packages/mathlib as a default fix. That belongs in an explicit experimental workflow because it can break reproducibility across projects pinned to different Lean or mathlib versions.

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.