Can I delete .ruff_cache? Yes, it's safe

Yes, it's safe to deleteDiskmack safety tier: Safe to clean
**/.ruff_cache

Yes. .ruff_cache is safe to delete on any Mac. It is the cache that Ruff, the Python linter and formatter, keeps so it can skip files that have not changed between runs, and Ruff recreates it automatically the next time it runs. The only cost is one slightly slower lint pass while the cache rebuilds.

What it is

Ruff is a fast linter and code formatter for Python, and .ruff_cache is where it remembers its work. When Ruff checks a project, it records which files it has already analyzed and what it found, keyed to the file contents and the Ruff version. On the next run it compares that record against your files and only re-lints the ones that changed. That is why a second run of ruff check on a big project finishes almost instantly. The folder holds nothing but this bookkeeping: no source code, no settings, no results you would ever open by hand.

You will usually find one .ruff_cache in the root of each project where Ruff runs, whether you invoke it from the terminal, a pre-commit hook, or an editor extension in VS Code or a similar tool. Each cache is typically small, often just a few megabytes, but a large monorepo or a machine with many Python projects can accumulate a noticeable pile of them. If you upgrade Ruff often, old version-specific entries can linger inside the cache as well, which is another reason the folders slowly grow.

Is it safe to delete?

Deleting .ruff_cache costs you nothing permanent. Your code, your Ruff configuration in pyproject.toml or ruff.toml, and your lint results all live elsewhere. The cache exists purely to make repeat runs faster. Throw it away and the next ruff check simply analyzes every file from scratch, writing a fresh cache as it goes. Ruff is quick enough that even that cold run finishes fast on most projects.

The one thing to watch is aim. The folder starts with a dot, so it sits next to other hidden items like .git, and .git is absolutely not something you want to delete. Remove only the .ruff_cache folder itself, not the project around it and not its hidden neighbors. Diskmack identifies .ruff_cache folders across your projects automatically and cleans them the safe way.

How to check its size

In Finder: Open Finder, choose Go > Go to Folder, and enter the cache path inside your project, for example ~/Projects/my-app/.ruff_cache. If you are browsing the project folder normally instead, press Command-Shift-Period to reveal hidden items. Select the folder and press Command-I to see its size.

In Terminal:

du -sh ~/Projects/my-app/.ruff_cache

For one project. Replace ~/Projects/my-app with your real project path; ~ expands to /Users/yourname. To list every .ruff_cache under your home folder with sizes, run: find ~ -type d -name .ruff_cache -prune -exec du -sh {} +.

How to clean it

  1. In Finder, choose Go > Go to Folder and enter your project path, for example ~/Projects/my-app.
  2. Press Command-Shift-Period if you do not see hidden files, so the dot folders appear.
  3. Select the .ruff_cache folder, and only that folder, then press Command-Delete to move it to the Trash.
  4. Repeat for any other projects that have one, then empty the Trash to reclaim the space.

Ruff has a built-in equivalent: run ruff clean in a project and it deletes the caches in that directory and below. Either way your configuration is safe; rules, ignores, and formatter settings live in pyproject.toml or ruff.toml and stay exactly as they are.

Will it come back?

Yes, and quickly. Ruff recreates .ruff_cache on its next run, so if you lint the project from the terminal, save a file with a Ruff editor extension active, or trigger a pre-commit hook, the folder is back within seconds. That is normal and means the cache is doing its job. Caches in projects you have abandoned stay gone, so clearing those is a real win, while active projects will regrow theirs almost immediately. Treat this as periodic tidying, not a one-time fix.

Common questions

Why does .ruff_cache keep coming back after I delete it?

Because Ruff recreates it on its next run. Editor extensions and pre-commit hooks run Ruff for you, so the folder can reappear even when you never typed a ruff command. Deleting it is harmless but temporary in any project you still work on.

Should I add .ruff_cache to .gitignore?

Yes. The cache is machine-specific generated data and does not belong in version control. Adding the line .ruff_cache/ to your .gitignore is standard practice in Python projects that use Ruff.

Will deleting the cache make linting slower?

Only once. The first ruff check after deletion re-analyzes every file instead of just the changed ones, then writes a new cache. Ruff is fast, so on most projects the difference is a moment, not minutes.

Can I stop Ruff from scattering caches through my projects?

You can run ruff check --no-cache to skip caching entirely, at the price of re-linting everything each run. You can also point the cache at one central location with the cache-dir setting in your Ruff configuration or the RUFF_CACHE_DIR environment variable, which keeps project folders clean.

Related folders