delphi-clean is a PowerShell utility designed for Delphi developers to help remove
build artifacts, intermediate files, and IDE-generated clutter.
# Preview cleanup
pwsh -File .\delphi-clean.ps1 -WhatIf
# Perform cleanup
pwsh -File .\delphi-clean.ps1
# CI usage
pwsh -File .\delphi-clean.ps1 -Level full -Json- Three cleanup levels:
lite,build,full - CI-friendly output with optional JSON mode
- Optional structured output via
-PassThru - Supports the
-WhatIfdry-run mode - Add extra file patterns with
-IncludeFilePattern - Exclude directories by wildcard pattern with
-ExcludeDirPattern - Send items to the recycle bin / trash instead of permanent deletion with
-RecycleBin
Runs on the widely available Windows PowerShell 5.1 (powershell.exe) and the newer PowerShell 7+ (pwsh).
Run the script from its directory, or provide a path explicitly.
pwsh -File .\delphi-clean.ps1Defaults to:
- Level:
lite - Root: parent directory of the script
pwsh -File .\delphi-clean.ps1 -Level lite
pwsh -File .\delphi-clean.ps1 -Level build
pwsh -File .\delphi-clean.ps1 -Level fullpwsh -File .\delphi-clean.ps1 -RootPath C:\code\my-projectpwsh -File .\delphi-clean.ps1 -WhatIfShows what would be deleted without making changes.
pwsh -File .\delphi-clean.ps1 -Verbosepwsh -File .\delphi-clean.ps1 -PassThruReturns objects describing each item processed.
pwsh -File .\delphi-clean.ps1 -JsonOutputs a JSON summary including:
- Files found
- Directories found
- Files deleted
- Directories deleted
- Item-level details
Disposition(PermanentorRecycle Bin) andRecycleBinflag
pwsh -File .\delphi-clean.ps1 -ExcludeDirectories .git,.vs,.ideaMatches exact directory names. Default exclusions are .git, .vs, and .claude.
pwsh -File .\delphi-clean.ps1 -Level lite -IncludeFilePattern '*.res'
pwsh -File .\delphi-clean.ps1 -Level lite -IncludeFilePattern '*.res','*.mab'Appends additional glob patterns to the level's built-in file list. Useful for project-specific artifacts not covered by the standard levels.
pwsh -File .\delphi-clean.ps1 -ExcludeDirPattern 'vendor*'
pwsh -File .\delphi-clean.ps1 -ExcludeDirPattern 'vendor*','assets'Skips any directory whose name matches one of the given wildcard patterns.
Unlike -ExcludeDirectories, patterns are matched with -like so wildcards
(*, ?) are supported.
pwsh -File .\delphi-clean.ps1 -RecycleBin
pwsh -File .\delphi-clean.ps1 -Level build -RecycleBinSends 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.
- see: /docs/cleanup-levels.md for breakdown of each level
Safe cleanup of common transient files.
Includes:
.dcu,.tmp,.bak,.identcache__history
Removes build outputs and generated artifacts.
Includes everything in lite, plus:
- Compiled binaries (
.exe,.bpl, etc.) - Debug and release folders
- Intermediate files
More aggressive cleanup
Includes everything in build, plus:
- Backup files (
*.~*) - FinalBuilder related files (logs, breakpoint, lock)
- TestInsight custom settings
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 improving engineering discipline for long-lived Delphi systems.

