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.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ccswitchSkill
- code-rulesSkill
- learn-math-by-lean-notebookSkill
- lmfdb-cliSkill
- mathlib-styleSkill
- mathlib-workflowSkill
- openclaw-rssSkill
- pre-initSkill
- pr-worktree-workflowSkill
- sshSkill
- tmuxSkill
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
- Distinctive: line 8
Use LeanMgr as a local project-fleet tool for Lean 4 cache lifecycle work.
- Very specific: line 12
Treat .lake as disposable, recoverable cache.
- Distinctive: line 13
Do not modify Lean source files unless the user explicitly asks.
- Distinctive: line 14
Do not rewrite Git history.
- Distinctive: line 15
Run dry-runs before destructive cleanup.
- Very specific: line 16
Prefer leanmgr doctor, leanmgr size, and leanmgr clean --dry-run before deletion.
- Very specific: line 17
Prefer leanmgr gc --dry-run for fleet-wide reclamation.
- Very specific: line 28
Use leanmgr restore to call lake exe cache get after cache deletion.
- Very specific: line 32
Use leanmgr gitignore to ensure .lake/ is ignored before recommending cleanup.
- Very specific: line 36
When leanmgr list shows missing in the STATUS column, suggest leanmgr remove --missing --dry-run first.
- Distinctive: line 89
Keep the index tidy after projects are moved or deleted:
- Distinctive: line 97
Use AI-oriented context output before making recommendations:
- Very specific: line 105
Prefer --format json for programmatic pipelines and --format codex or --format claude for coding-agent prompts.
- Very specific: line 126
Do not propose shared local mathlib or symlinked .lake/packages/mathlib as a default fix.
≈ “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.
Files
LeanMgr Cache Manager
Use LeanMgr as a local project-fleet tool for Lean 4 cache lifecycle work.
Rules
- Treat
.lakeas 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, andleanmgr clean --dry-runbefore deletion. - Prefer
leanmgr gc --dry-runfor fleet-wide reclamation; it skips unrecoverable caches (nolake-manifest.json, nolakefile.toml/lakefile.lean, or emptylean-toolchain) unless--include-unrecoverableis given. - With a size budget, pair
--targetwith--unused-days(for exampleleanmgr gc --target 20GiB --unused-days 14 --dry-run);--targetalone takes the largest caches first even if the user is working in them. leanmgr doctoralso reports shared caches (Mathlib downloads, elan toolchains) and toolchainselan toolchain gcconsiders unused. Suggestelan toolchain gc --deleteorlake exe cache clean!only as commands for the user to run; LeanMgr never deletes shared caches itself.- Use
leanmgr restoreto calllake exe cache getafter 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 withlake build). Preview withleanmgr restore ... --dry-run. - Use
leanmgr gitignoreto ensure.lake/is ignored before recommending cleanup. - A project selector must name an indexed project;
clean,restore,size,remove, andgitignore <project>error out on an unknown selector rather than no-op. - When
leanmgr listshowsmissingin the STATUS column, suggestleanmgr remove --missing --dry-runfirst. It only edits the index, but a project on an unmounted drive also looks missing, so let the user confirm.
Workflow
- Inspect indexed projects (and find unindexed ones elan knows about):
leanmgr list
leanmgr size --all
leanmgr doctor
leanmgr scan --from-elan- Check project hygiene:
leanmgr gitignore --all --dry-run
leanmgr toolchain check
leanmgr worktree doctor
leanmgr worktree prune --dry-runleanmgr 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.
- 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- Execute only after the user accepts the plan or explicitly requests execution:
leanmgr clean --tag archived --level hard- Restore cache when returning to a project:
leanmgr restore --tag active --dry-run
leanmgr restore <project>
leanmgr restore --tag active- Keep the index tidy after projects are moved or deleted:
leanmgr remove --missing --dry-runAI Context
Use AI-oriented context output before making recommendations:
leanmgr ai context --format codex
leanmgr ai context --format claude
leanmgr ai context --format jsonPrefer --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.
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
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.

