Skip to main content

amagi-model-shelf

Find the model files LM Studio, Ollama, llama.cpp and the Hugging Face cache have each downloaded separately, and get that disk space back. Also resolves models from your own disks before anything downloads.

amagi-model-shelf finding duplicate models across four tools

Recorded against the fixture stores from examples/make_stores.py, placed in a throwaway home folder so default discovery finds them. Real command, real output, filler-byte files.

pipx install amagi-model-shelf

Python 3.11+. Works on Windows, macOS and Linux.

Why

Every local LLM tool keeps its own model folder. Pull Qwen3 in Ollama, download the same GGUF in LM Studio, let llama.cpp fetch it with -hf, and you have three copies of one file under three different names. Nothing warns you, because none of the tools knows the others exist.

amagi-model-shelf reads all of those folders, matches files by content rather than by name, and tells you exactly how much space the copies cost. If you want, it replaces the copies with hard links: every tool keeps its path and keeps working, and the data is stored once.

Usage

The output below is a real run against examples/make_stores.py, which builds a tiny fake LM Studio / Ollama / HF cache / llama.cpp setup out of filler bytes (a few MB, not real weights). Point it at your real folders and the numbers are yours.

python examples/make_stores.py stores --mb 1

See what every tool has

$ amagi-model-shelf scan
  lmstudio      3.0 MB  bartowski/Llama-3.2-1B-Instruct-GGUF/Llama-3.2-1B-Instruct-Q8_0.gguf
  lmstudio      2.0 MB  HuggingFaceTB/SmolLM2-360M/model.safetensors
  lmstudio      8.0 MB  Qwen/Qwen3-4B-GGUF/Qwen3-4B-Q4_K_M.gguf
  lmstudio      8.0 MB  someone/Qwen3-4B-finetune-GGUF/qwen3-4b-ft-Q4_K_M.gguf
  lmstudio      5.0 MB  TheBloke/Mistral-7B-Instruct-GGUF/mistral-7b-instruct.Q4_K_M.gguf
  ollama        8.0 MB  qwen3:4b
  ollama        8.0 MB  qwen3:latest
  hf            2.0 MB  HuggingFaceTB/SmolLM2-360M model.safetensors
  hf            8.0 MB  Qwen/Qwen3-4B-GGUF Qwen3-4B-Q4_K_M.gguf
  llamacpp      3.0 MB  bartowski/Llama-3.2-1B-Instruct-GGUF/Llama-3.2-1B-Instruct-Q8_0.gguf
  llamacpp      8.0 MB  Qwen/Qwen3-4B-GGUF/Qwen3-4B-Q4_K_M.gguf

  11 model files from 4 source(s), 55.0 MB on disk

With no flags it looks in each tool's standard location and honours OLLAMA_MODELS, HF_HOME / HF_HUB_CACHE and LLAMA_CACHE. Use --root ollama=D:\ollama\models for a custom location, or --path DIR to add any folder of .gguf / .safetensors files. (The demo passes --root for each fixture store; those lines are trimmed here.)

Find the duplicates

$ amagi-model-shelf dupes --verify full
  10 model files, 55.0 MB on disk
  1 already shared (Ollama tags on one blob, symlinks, hard links: no waste)
  3 duplicate group(s), 29.0 MB reclaimable (full sha256)

  [1] 8.0 MB x4   reclaim 24.0 MB   sha256 68768aed41d9
      ollama    qwen3:4b, qwen3:latest
                stores/ollama/blobs/sha256-68768aed41d92431af4917ef4779b86fc12615619e72a0f961b8760408413e1a
      hf        stores/hf/models--Qwen--Qwen3-4B-GGUF/snapshots/0123abcd/Qwen3-4B-Q4_K_M.gguf
      lmstudio  stores/lmstudio/Qwen/Qwen3-4B-GGUF/Qwen3-4B-Q4_K_M.gguf
      llamacpp  stores/llamacpp/Qwen_Qwen3-4B-GGUF_Qwen3-4B-Q4_K_M.gguf
  [2] 3.0 MB x2   reclaim 3.0 MB   sha256 c877ea18c3a0
      lmstudio  stores/lmstudio/bartowski/Llama-3.2-1B-Instruct-GGUF/Llama-3.2-1B-Instruct-Q8_0.gguf
      llamacpp  stores/llamacpp/bartowski_Llama-3.2-1B-Instruct-GGUF_Llama-3.2-1B-Instruct-Q8_0.gguf
  [3] 2.0 MB x2   reclaim 2.0 MB   sha256 65d8d76d070f
      hf        stores/hf/models--HuggingFaceTB--SmolLM2-360M/snapshots/9f8e7d6c/model.safetensors
      lmstudio  stores/lmstudio/HuggingFaceTB/SmolLM2-360M/model.safetensors

Two Ollama tags pointing at one blob are not waste, so they count once. The fixture also plants a same-size "finetune" that differs by 4 KiB in the middle. Full verification keeps it out of group 1.

How matching works:

  1. Files that are already the same file on disk (hard links, symlinks) are collapsed first.
  2. Only files with identical sizes are compared.
  3. The default --verify quick hashes the size plus three 1 MiB samples (start, middle, end). On a 40 GB file that is 3 MiB of reading, and the report says "fingerprint match, not yet verified".
  4. --verify full hashes every byte. Ollama blobs and HF cache blobs are named after their sha256, so those are reused instead of re-read.

--json gives the same report in machine-readable form.

Reclaim the space

$ amagi-model-shelf dedupe
  planned      8.0 MB  stores/hf/models--Qwen--Qwen3-4B-GGUF/snapshots/0123abcd/Qwen3-4B-Q4_K_M.gguf
                       -> stores/ollama/blobs/sha256-68768aed41d92431af4917ef4779b86fc12615619e72a0f961b8760408413e1a
  planned      8.0 MB  stores/lmstudio/Qwen/Qwen3-4B-GGUF/Qwen3-4B-Q4_K_M.gguf
                       -> stores/ollama/blobs/sha256-68768aed41d92431af4917ef4779b86fc12615619e72a0f961b8760408413e1a
  planned      8.0 MB  stores/llamacpp/Qwen_Qwen3-4B-GGUF_Qwen3-4B-Q4_K_M.gguf
                       -> stores/ollama/blobs/sha256-68768aed41d92431af4917ef4779b86fc12615619e72a0f961b8760408413e1a
  planned      3.0 MB  stores/llamacpp/bartowski_Llama-3.2-1B-Instruct-GGUF_Llama-3.2-1B-Instruct-Q8_0.gguf
                       -> stores/lmstudio/bartowski/Llama-3.2-1B-Instruct-GGUF/Llama-3.2-1B-Instruct-Q8_0.gguf
  planned      2.0 MB  stores/lmstudio/HuggingFaceTB/SmolLM2-360M/model.safetensors
                       -> stores/hf/models--HuggingFaceTB--SmolLM2-360M/snapshots/9f8e7d6c/model.safetensors

  dry run: nothing changed. --apply links 5 copies and frees 29.0 MB.
  Every path keeps working; the copies just share one file on disk.

dedupe is a dry run until you add --apply. It always does a full sha256 check first, whatever --verify says. Each copy is swapped for a hard link atomically (link to a temp name, then rename over), so a crash mid-run never leaves a missing file. Hard links can't cross drives, so copies on a different drive are reported and skipped.

One thing to know: after linking, the paths are one file. If a tool edits a model in place, every path sees the edit. Inference tools only read weights, but if you fine-tune in place, keep that copy out.

Put everything on one shelf

amagi-model-shelf import                 # dry run
amagi-model-shelf import --apply         # hard-link onto the shelf
amagi-model-shelf import --mode copy     # shelf on another drive

import lays the models from LM Studio, Ollama, the HF cache and llama.cpp onto your shelf in the gguf/<publisher>/<repo>/<file> layout (Ollama models land under gguf/ollama/<name>/). It never overwrites an existing file. --mode symlink is also available.

Resolve before downloading

The original model-shelf job still works the same way. An agent (or you) asks for a model; it comes from your disks if it's anywhere on them, and downloads to the shelf only on a miss.

amagi-model-shelf init                                   # pick or detect a shelf
amagi-model-shelf resolve "Qwen/Qwen3-14B-GGUF" --quant Q4_K_M --json
amagi-model-shelf find "qwen 3 4b mlx 4-bit" --format mlx --limit 5
amagi-model-shelf list

Format is detected from the repo id (*-GGUF is gguf and needs --quant, mlx-community/* or *-mlx is mlx, anything else is safetensors). Lookup checks the configured shelf, then every mounted drive with a ModelShelf/models folder, then ~/.cache/model-shelf/models. On Windows, every drive letter other than the system drive counts as a mounted drive. Exit codes: 0 found or downloaded, 1 missing.

Config lives at ~/.config/model-shelf/config.toml (override with $MODEL_SHELF_CONFIG or --config). It's the same file upstream model-shelf uses, so an existing setup carries over. See config.example.toml.

Windows fix

Upstream model-shelf writes a Windows path such as shelf_root = "D:\Models\ModelShelf" into its TOML config without escaping. TOML treats each backslash as the start of an escape sequence (\M is invalid, \U expects eight hex digits), so the very next command crashes with TOMLDecodeError (Unescaped '\' in a string, or Invalid hex value for any path under the Users folder). This fork escapes paths when writing, and repairs an already-broken config in memory when reading (with a warning telling you to re-run init). A regression test runs init C:\... and then list.

Claude Code

The repo ships a Claude Code plugin with a skill that routes model downloads through resolve and knows the audit commands. The skill tells the agent never to run dedupe --apply or import --apply without asking you first.

/plugin marketplace add amagilabs/amagi-model-shelf
/plugin install amagi-model-shelf@amagilabs

Development

pip install -e ".[dev]"
pytest

The tests build fixture stores for all four tools and run the real CLI against them, including the impostor file, Ollama multi-tag blobs, cross-drive skips and the Windows config crash.

If this saved you time, a star helps others find it.

More from AmagiLabs

What changed from upstream

Forked from model-shelf v0.14.0.

  • Fixed: Windows paths in the config crashed every command after init (upstream #2, #7).
  • Added: Windows drive-letter discovery for multi-shelf lookup.
  • Added: scan across LM Studio, Ollama, the HF cache and llama.cpp (upstream #3 asked for LM Studio).
  • Added: dupes and dedupe, the duplicate report and hard-link reclaim.
  • Added: import from all four tools onto the shelf (upstream #9).
  • Renamed: package amagi-model-shelf, command amagi-model-shelf. The config path is unchanged.

License

MIT. See LICENSE.

Based on model-shelf by Alex Ziskind (MIT).

Metadata

Release files for amagi-model-shelf 0.15.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for amagi-model-shelf 0.15.0
File Size Uploaded Provenance Actions
amagi_model_shelf-0.15.0.tar.gz 2.6 MB Without provenance Details for amagi_model_shelf-0.15.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for amagi-model-shelf 0.15.0
File Interpreter ABI Platform Actions
amagi_model_shelf-0.15.0-py3-none-any.whl Python 3 none any Details for amagi_model_shelf-0.15.0-py3-none-any.whl

Total release size: 2.6 MB

Release files / amagi_model_shelf-0.15.0.tar.gz

Download URL amagi_model_shelf-0.15.0.tar.gz
Size 2.6 MB
Tags Source
SHA-256 checksum
How to use checksums
99591ed6d588e8c75e083022ed44374e87cf1cb647498f4eac21273a374fdf65
BLAKE2b-256 checksum
How to use checksums
e93959d36ff148cedb46c3cdc35888342654b3e7e445d2011f3b4974493afbcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / amagi_model_shelf-0.15.0-py3-none-any.whl

Download URL amagi_model_shelf-0.15.0-py3-none-any.whl
Size 36.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d4ce79541dd06ae21d192b605e61b409944e40ae0274f20ffa53237232850a1
BLAKE2b-256 checksum
How to use checksums
65cd1189485f9624157ec2c995183afeff6b616853373154fd31bd7a8a70608d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for amagi-model-shelf 0.15.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.15.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page