OllamaCleanup 0.1.2
See the version list below for details.
dotnet tool install --global OllamaCleanup --version 0.1.2
dotnet new tool-manifest
dotnet tool install --local OllamaCleanup --version 0.1.2
#tool dotnet:?package=OllamaCleanup&version=0.1.2
nuke :add-package OllamaCleanup --version 0.1.2
OllamaCleanup
OllamaCleanup is a .NET 10 command-line tool for inspecting reclaimable Ollama model storage and deleting known-safe disk waste when explicitly requested.
It currently detects:
- orphaned blobs
- incomplete partial downloads
- old blob files based on an age threshold
Status
This repository is now set up as a real .NET tool package rather than a file-based demo script.
mainis expected to stay buildable and packable.- Pull requests and pushes to
mainrun CI. - Tags in the form
vX.Y.Zpublish to NuGet frommainhistory. - The publish pipeline requires the
NUGET_API_KEYGitHub Actions secret.
Why This Exists
Ollama stores models under ~/.ollama/models or the path pointed to by OLLAMA_MODELS.
Typical layout:
~/.ollama/models
├── blobs/
└── manifests/
Storage grows over time when downloads are interrupted, manifests stop referencing older blobs, or partial transfers are left behind. This tool gives you a safe dry-run summary first, then lets you apply deletion intentionally.
Requirements
- .NET 10 SDK
- Local access to the Ollama model storage directory
Local Usage
Run from source:
dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj -- --find-old
No arguments shows help. Inspection is non-destructive unless --apply is present.
Examples:
dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj -- --help
dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj -- --find-old --days 30
dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj -- --find-orphaned
dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj -- --remove-orphaned --apply
dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj -- --remove-old --days 30 --apply --yes
Install As A Tool
After a tagged release has been published to NuGet:
dotnet tool install --global OllamaCleanup
OllamaCleanup --find-orphaned
If you prefer ephemeral execution:
dnx OllamaCleanup --find-orphaned
Command Line Options
| Option | Description |
|---|---|
--find-old |
Show old files in the report |
--find-orphaned |
Show orphaned blobs in the report |
--remove-old |
Include old files in the deletion set |
--remove-orphaned |
Include orphaned blobs in the deletion set |
--days <n> |
Age threshold in days, default 180 |
--apply |
Perform deletion |
--yes |
Skip the confirmation prompt |
--help |
Show usage text |
Publish And Release
Local package check:
dotnet restore src/OllamaCleanup/OllamaCleanup.csproj
dotnet build src/OllamaCleanup/OllamaCleanup.csproj -c Release
dotnet pack src/OllamaCleanup/OllamaCleanup.csproj -c Release
Repository release flow:
- Merge release-ready changes to
main. - Confirm the
NUGET_API_KEYrepository secret exists. - Create and push a semantic version tag such as
v0.1.0. - GitHub Actions packs the tool and publishes it to NuGet.
- Verify the
publishworkflow succeeded before announcing the package.
The publish workflow rejects tags that are not reachable from main.
CI/CD Files
.github/workflows/ci.ymlvalidates restore, build, and pack on pull requests andmain..github/workflows/publish.ymlpublishes version tags to NuGet.
Known Gaps
These areas are intentionally not advertised as finished features yet:
- obsolete-model detection is not implemented
- manifest integrity validation is not implemented
- JSON or machine-readable reporting is not implemented
- automated tests are still missing
Safety
Deletion is opt-in. The tool is dry-run only unless --apply is passed, and orphaned blobs are only deleted when --remove-orphaned is also supplied.
You should still review the summary before deleting files because removing currently needed layers may force Ollama to download them again later.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.