OllamaCleanup 0.1.3

dotnet tool install --global OllamaCleanup --version 0.1.3
                    
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.3
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=OllamaCleanup&version=0.1.3
                    
nuke :add-package OllamaCleanup --version 0.1.3
                    

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
  • LM Studio style .studio_links references that should protect shared blobs from orphan cleanup
  • standalone LM Studio cache files stored under .studio_links

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

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 -- --find-studio-cache
dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj -- --remove-orphaned --apply
dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj -- --remove-old --days 30 --apply --yes
dotnet run --project src/OllamaCleanup/OllamaCleanup.csproj -- --remove-studio-cache --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
--find-studio-cache Show standalone LM Studio cache files under .studio_links
--remove-old Include old files in the deletion set
--remove-orphaned Include orphaned blobs in the deletion set
--remove-studio-cache Include standalone LM Studio cache files under .studio_links in the deletion set
--days <n> Age threshold in days, default 180
--apply Perform deletion
--yes Skip the confirmation prompt for non-interactive or automated deletion
--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, orphaned blobs are only deleted when --remove-orphaned is also supplied, and standalone LM Studio cache files are only deleted when --remove-studio-cache is also supplied.

If .studio_links exists, it is treated as a live-reference source. Linked blobs are excluded from orphan cleanup because deleting the backing blob could break external model integrations even when Ollama manifests no longer reference it.

Some LM Studio files under .studio_links are standalone cache files rather than links to Ollama blobs. The tool reports those separately so they can be reviewed with --find-studio-cache and removed explicitly with --remove-studio-cache --apply. In non-interactive shells, add --yes because the tool cannot prompt for confirmation.

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 103 5/20/2026
0.1.2 98 5/19/2026
0.1.1 95 5/19/2026
0.1.0 89 5/19/2026