swab
swab is a configurable project cleaning tool.
Build artifacts, dependency caches, and generated files accumulate quickly across
projects. Running cargo clean in one project, rm -rf node_modules in another,
and hunting down .venv directories in a third gets tedious. swab automates
this by detecting project types and cleaning them with a single command.
We currently provide 21 built-in rules that cover popular ecosystems: Rust (Cargo), Node.js, Python, Go, .NET, Swift, Elixir, Zig, and many more. The rule system is designed to be easily extended with custom rules to fit any project's specific needs.
Installation
swab should run on any system, including Linux, MacOS, and Windows.
The easiest way to install it is by using cargo, the Rust package manager:
Otherwise, see below for the complete package list:
Cross-platform
Pre-built binaries
Pre-built binaries for Linux, MacOS, and Windows can be found on the releases page.
Usage
Point swab at one or more directories containing projects to clean:
Below is the output of swab --help:
A configurable project cleaning tool
Usage: swab [OPTIONS] [DIRECTORIES]... [COMMAND]
Commands:
rules List all available rules
help Print this message or the help of the given subcommand(s)
Arguments:
[DIRECTORIES]... Directories to scan for projects to clean
Options:
--dry-run Enable dry run mode
--follow-symlinks Follow symlinks during traversal
-i, --interactive Prompt before each task
-q, --quiet Suppress all output
-h, --help Print help
-V, --version Print version
Configuration
You can configure rules in a configuration file. The config file is located at:
- Linux:
~/.config/swab/config.toml - macOS:
~/.config/swab/config.toml - Windows:
C:\Users\<User>\AppData\Roaming\swab\config\config.toml
To disable specific built-in rules, add them to the disabled list:
[]
= ["node", "python"]
You can define custom rules with detection patterns and actions:
[[]]
= "my-custom-rule"
= "My Custom Rule"
= "Makefile"
= [
{ = "build" },
{ = "dist" },
]
Detection patterns can use glob syntax and can be combined with logic operators:
= "Cargo.toml"
= { = ["package.json", "yarn.lock"] }
= { = ["Dockerfile", "docker-compose.yaml"] }
= { = "*.lock" }
Actions can either remove files/directories or run commands:
= [
{ = "build" },
{ = "**/cache" },
{ = "make clean" },
]
To customize a built-in rule, define a rule with the same id:
[[]]
= "cargo"
= "Cargo (custom)"
= "Cargo.toml"
= [
{ = "target" },
{ = "cargo clean" },
]
Prior Art
This project was inspired by kondo, a similar tool for cleaning project directories. swab aims to provide more flexibility through its configurable rule system and support for custom actions.