delphi-clean is a PowerShell utility for Delphi developers to remove build
artifacts, intermediate files, and IDE-generated clutter, with support for
preview, validation, and CI workflows.
If delphi-clean is on your PATH:
delphi-clean -Level standardOtherwise, run it directly:
pwsh -File .\delphi-clean.ps1 -Level standard
# or
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\delphi-clean.ps1 -Level standardRuns on the widely available Windows PowerShell 5.1 (powershell.exe)
and the newer PowerShell 7+ (pwsh).
- Specify cleanup levels:
basic,standard,deepvia-Level - CI-friendly output with optional
-Jsonmode - Optional structured output via
-PassThru - Supports the
-WhatIfdry-run mode - Add extra file patterns with
-IncludeFilePattern - Exclude directories by wildcard pattern with
-ExcludeDirectoryPattern - Send items to the recycle bin / trash instead of permanent deletion with
-RecycleBin - Use
-OutputLevelto adjust how much detail is shown. - Check for cleanup artifacts without modifying files using
-Check.
Run delphi-clean from the current working directory,
or specify a different root with -RootPath
delphi-cleanRoot path defaults to the current working directory (via Get-Location),
or you can provide it explicitly.
Example:
delphi-clean -RootPath C:\code\my-projectPreview cleanup without making changes. (Dry Run Mode)
delphi-clean -WhatIfShows what would be deleted without making changes.
Extra output for debugging purposes
delphi-clean -VerboseStructured Output: Returns objects describing each item processed.
delphi-clean -PassThruOutputs a JSON summary including:
- Files found
- Directories found
- Files deleted
- Directories deleted
- Item-level details
Disposition(PermanentorRecycle Bin) andRecycleBinflag
delphi-clean -JsonAppends additional glob patterns to the level's built-in file list. Useful for project-specific artifacts not covered by the standard levels.
delphi-clean -Level basic -IncludeFilePattern '*.res'
delphi-clean -Level basic -IncludeFilePattern '*.res','*.mab'Skips any directory whose name matches one of the given wildcard patterns.
Patterns are matched with -like so wildcards (*, ?) are supported.
Specific directories are excluded by default: .git, .vs, and .claude.
delphi-clean -ExcludeDirectoryPattern 'vendor*'
delphi-clean -ExcludeDirectoryPattern 'vendor*','assets'Sends items to the platform trash instead of permanently deleting them.
| Platform | Destination |
|---|---|
| Windows | Recycle Bin (Microsoft.VisualBasic.FileIO) |
| macOS | ~/.Trash/ |
| Linux | ~/.local/share/Trash/ (FreeDesktop spec) |
Combine with -WhatIf to preview which items would be recycled without
making any changes.
delphi-clean -RecycleBin
delphi-clean -Level standard -RecycleBinSafe cleanup of common transient files.
Includes:
.dcu,.tmp,.bak,.identcache__history
Removes build outputs and generated artifacts.
Includes everything in basic, plus:
- Compiled binaries (
.exe,.bpl, etc.) - Debug and release folders
- Intermediate files
More aggressive cleanup
Includes everything in standard, plus:
- Backup files (
*.~*) - FinalBuilder related files (logs, breakpoint, lock)
- TestInsight custom settings
Examples:
delphi-clean -Level basic
delphi-clean -Level standard
delphi-clean -Level deepSee /docs/cleanup-levels.md for breakdown of what is included by default in each level
Use -OutputLevel to control how much information delphi-clean writes
during execution or check mode.
-
detailed(default)Shows full output including headers, per-item actions (or matches in -Check), and summary totals.
-
summarySuppresses per-item output and shows only high-level information and totals.
-
quietSuppresses all normal output. Only warnings and errors are displayed. Intended for automation scenarios where the exit code is the primary signal.
- Applies to both normal cleanup runs and
-Checkmode - Does not affect JSON output (
-Jsonalways returns structured data) - Warnings and errors are never suppressed, even with quiet
Show full detail (default):
delphi-cleanShow only totals:
delphi-clean -OutputLevel summarySilent run for CI:
delphi-clean -Level standard -OutputLevel quietdetailedis useful for interactive use and troubleshootingsummaryis ideal for large repositories to reduce noisequietis best for scripts where only the exit code matters
Use -Check to audit a project folder without making any changes.
In check mode, delphi-clean performs a full scan using the selected cleanup level
and reports any files or directories that would be removed during a normal run.
No files are deleted, moved, or modified.
delphi-clean -CheckOutput controlled by -OutputLevel:
- detailed (default): lists matching items and summary
- summary: totals only
- quiet: no output (use exit code only)
Example: use in CI to validate a workspace
delphi-clean -Check -OutputLevel quiet
if ($LASTEXITCODE -ne 0) {
throw "Repository contains build artifacts"
}Example: view detailed list of matching files:
delphi-clean -Level deep -Check -OutputLevel detailedNotes:
-Checkcannot be combined with-WhatIf-RecycleBinhas no effect in check mode- For a simulated run that shows what would be deleted during execution, use
-WhatIf
Check vs WhatIf:
- Use
-WhatIfto preview what a cleanup run would do - Use
-Checkto determine whether cleanup is needed (with exit code support)
0 = success: cleanup completed, WhatIf completed, or Check found no artifacts
1 = dirty: check mode found artifacts (validation failure)
2 = partial: the script reached the removal phase but at least one item could not
be deleted or recycled;
Note: successfully removed items are not rolled back
3 = fatal: unhandled exception before or during the scan phase - bad root path,
unsupported platform for -RecycleBin, scan error, etc.
This repository is currently incubator and is under active development.
It will graduate to stable once:
- At least one downstream consumer exists.
Until graduation, breaking changes may occur
This tool is part of the Continuous-Delphi ecosystem, focused on strengthening Delphi’s continued success

