https://github.com/terror/swab
A configurable project cleaning tool
https://github.com/terror/swab
Last synced: 5 months ago
JSON representation
A configurable project cleaning tool
- Host: GitHub
- URL: https://github.com/terror/swab
- Owner: terror
- License: cc0-1.0
- Created: 2025-12-29T06:32:58.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-12-30T04:07:27.000Z (5 months ago)
- Last Synced: 2026-01-01T03:47:03.035Z (5 months ago)
- Language: Rust
- Size: 1.03 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING
- License: LICENSE
Awesome Lists containing this project
README
## swab
[](https://github.com/terror/swab/releases/latest)
[](https://github.com/terror/swab/actions/workflows/ci.yaml)
[](https://codecov.io/gh/terror/swab)
[](https://github.com/terror/swab/releases)
**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](https://github.com/terror/swab/tree/master/src/rule) 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](https://doc.rust-lang.org/cargo/index.html), the Rust package manager:
```bash
cargo install swab
```
Otherwise, see below for the complete package list:
#### Cross-platform
Package Manager
Package
Command
Cargo
swab
cargo install swab
Homebrew
terror/tap/swab
brew install terror/tap/swab
### Pre-built binaries
Pre-built binaries for Linux, MacOS, and Windows can be found on
[the releases page](https://github.com/terror/swab/releases).
## Usage
Point `swab` at one or more directories containing projects to clean:
```bash
swab ~/projects
```
Below is the output of `swab --help`:
```present cargo run -- --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\\AppData\Roaming\swab\config\config.toml`
To disable specific built-in rules, add them to the `disabled` list:
```toml
[default]
disabled = ["node", "python"]
```
You can define custom rules with detection patterns and actions:
```toml
[[rules]]
id = "my-custom-rule"
name = "My Custom Rule"
detection = "Makefile"
actions = [
{ remove = "build" },
{ remove = "dist" },
]
```
Detection patterns can use glob syntax and can be combined with logic operators:
```toml
detection = "Cargo.toml"
detection = { any = ["package.json", "yarn.lock"] }
detection = { all = ["Dockerfile", "docker-compose.yaml"] }
detection = { not = "*.lock" }
```
Actions can either remove files/directories or run commands:
```toml
actions = [
{ remove = "build" },
{ remove = "**/cache" },
{ command = "make clean" },
]
```
To customize a built-in rule, define a rule with the same `id`:
```toml
[[rules]]
id = "cargo"
name = "Cargo (custom)"
detection = "Cargo.toml"
actions = [
{ remove = "target" },
{ command = "cargo clean" },
]
```
## Prior Art
This project was inspired by [kondo](https://github.com/tbillington/kondo), a
similar tool for cleaning project directories. **swab** aims to provide more
flexibility through its configurable rule system and support for custom actions.