The thothctl project cleanup command helps you maintain clean and organized projects by removing residual files and directories that are not needed for the project’s operation. This includes temporary files, build artifacts, and other unnecessary items that can clutter your project.
thothctl project cleanup [OPTIONS]
| Option | Description |
|---|---|
-cfd, --clean-additional-folders TEXT |
Add folders to clean, specified as a comma-separated list (e.g., -cfd folder_1,folder_2) |
-cfs, --clean-additional-files TEXT |
Add files to clean, specified as a comma-separated list (e.g., -cfs file_1,file_2) |
--help |
Show help message and exit |
By default, the project cleanup command removes common temporary files and directories that are typically not needed in a clean project, such as:
.terraform directories (Terraform cache).terragrunt-cache directories (Terragrunt cache).terraform.lock.hcl files (Terraform dependency locks)terraform.tfstate and terraform.tfstate.backup files (local state files).DS_Store files (macOS metadata)__pycache__ directories (Python bytecode cache).pytest_cache directories (pytest cache)You can extend the default cleanup behavior by specifying additional files and directories to remove:
# Clean up default items plus custom folders
thothctl project cleanup --clean-additional-folders node_modules,dist,build
# Clean up multiple specific folders
thothctl project cleanup -cfd logs,temp,output
# Clean up default items plus custom files
thothctl project cleanup --clean-additional-files config.local.json,secrets.txt
# Clean up multiple specific files
thothctl project cleanup -cfs *.log,*.tmp,*.bak
You can combine both options to clean up both additional folders and files:
# Clean up custom folders and files
thothctl project cleanup -cfd node_modules,dist -cfs *.log,*.tmp
# Navigate to your project directory
cd my-project
# Run basic cleanup
thothctl project cleanup
# Clean up Terraform-specific files and directories
thothctl project cleanup -cfd .terraform,.terragrunt-cache -cfs terraform.tfstate,terraform.tfstate.backup,.terraform.lock.hcl
# Clean up build artifacts
thothctl project cleanup -cfd build,dist,target -cfs *.jar,*.war,*.class
# Clean up temporary files
thothctl project cleanup -cfs *.tmp,*.temp,*.bak,*.swp
.gitignore files to prevent committing temporary files rather than cleaning them repeatedlyYou can add a cleanup step to your pre-commit hook to ensure your commits don’t include unnecessary files:
# Create a pre-commit hook
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/bash
echo "Cleaning up project..."
thothctl project cleanup
git add .
EOF
chmod +x .git/hooks/pre-commit
You can include cleanup in your CI/CD pipeline to ensure clean builds:
# GitHub Actions example
name: Build and Test
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install thothctl
- name: Clean up project
run: thothctl project cleanup
- name: Build and test
run: |
# Your build and test commands here
Clean up unnecessary files before deploying to reduce package size:
# Clean up before packaging
thothctl project cleanup
# Package the application
tar -czf app.tar.gz .
Remove large temporary directories to free up disk space:
# Clean up large directories
thothctl project cleanup -cfd node_modules,.terraform,target
Clean up before submitting code for review to focus on relevant changes:
# Clean up before creating a pull request
thothctl project cleanup
git add .
git commit -m "feat: Add new feature"
git push
Clean up cached files when troubleshooting build or runtime issues:
# Clean up caches to start fresh
thothctl project cleanup
# Rebuild the project
./build.sh