OllamaCleanup 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global OllamaCleanup --version 0.1.0
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local OllamaCleanup --version 0.1.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=OllamaCleanup&version=0.1.0
                    
nuke :add-package OllamaCleanup --version 0.1.0
                    

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.

  • main is expected to stay buildable and packable.
  • Pull requests and pushes to main run CI.
  • Tags in the form vX.Y.Z publish to NuGet from main history.
  • The publish pipeline requires the NUGET_API_KEY GitHub 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

Dry-run is the default. No files are deleted unless --apply is present.

Examples:

dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj --
dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj -- --find-old --days 30
dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj -- --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-old

If you prefer ephemeral execution:

dnx OllamaCleanup --find-old

Command Line Options

Option Description
--find-old Show old files in the report
--remove-old Include old files 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:

  1. Merge release-ready changes to main.
  2. Confirm the NUGET_API_KEY repository secret exists.
  3. Create and push a semantic version tag such as v0.1.0.
  4. GitHub Actions packs the tool and publishes it to NuGet.
  5. Verify the publish workflow succeeded before announcing the package.

The publish workflow rejects tags that are not reachable from main.

CI/CD Files

  • .github/workflows/ci.yml validates restore, build, and pack on pull requests and main.
  • .github/workflows/publish.yml publishes 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.

You should still review the summary before deleting files because removing currently needed layers may force Ollama to download them again later.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
0.1.3 104 5/20/2026
0.1.2 99 5/19/2026
0.1.1 95 5/19/2026
0.1.0 89 5/19/2026