A tool for safely identifying and cleaning up inactive GitHub repositories based on configurable criteria.
Caution
Remember to use this with caution, as deleting repositories is an irreversible action!
-
🔍 Smart repository analysis based on multiple criteria
- Age-based filtering
- Activity tracking
- Star/fork/download analysis
- Dependency checking
- Resource usage calculation
-
📊 Comprehensive reporting
- Markdown formatted reports
- Deletion impact assessment
- Resource usage metrics
- Activity timelines
- Interactive deletion checklist
-
🔒 Safety measures
- Multiple validation checks
- Protected branch detection
- Repository archival option
- Backup before deletion
- Detailed audit logging
-
🛠 Advanced capabilities
- Rate limit handling
- Batch processing
- Progress tracking
- Dry-run mode
- Environment-based configuration
- Python 3.9 or higher
- uv package manager
- GitHub Personal Access Token with required permissions:
repo- Full repository accessdelete_repo- For repository deletionread:org- For organization repository access (if needed)
- Install uv package manager:
curl -LsSf https://astral.sh/uv/install.sh | sh- Clone this repository:
git clone https://github.com/d-oit/github-repo-cleanup.git
cd github-repo-cleanup- Create virtual environment and install dependencies:
uv venv
source .venv/bin/activate # Unix
.venv\Scripts\activate # Windows
uv pip install -r requirements.txt- Copy the example environment file:
cp .env.example .env- Configure your environment variables in
.env:
# GitHub Authentication
GITHUB_TOKEN=your_personal_access_token
GITHUB_API_URL=https://api.github.com
# Analysis Criteria
MIN_AGE_MONTHS=6
MIN_INACTIVITY_DAYS=180
IGNORE_STARS=false
IGNORE_FORKS=true
# Safety Settings
DRY_RUN=true
BACKUP_REQUIRED=true
PROTECTED_REPOS=main-repo,docs
MIN_CONFIRMATION_WAIT=30
# Performance Tuning
BATCH_SIZE=50
MAX_CONCURRENT=5
CACHE_TTL=3600Run with dry-run mode (safe, no deletions):
python -m ghcleanup- Generate analysis report only:
python -m ghcleanup --report-only- Override environment settings via command line:
python -m ghcleanup --min-age 12 --min-inactive 90- Execute with backup:
python -m ghcleanup --backup --backup-dir ./backups- Dry Run Mode: Test without making changes
- Validation Checks: Multiple safety validations
- Protected Repos: Prevent deletion of critical repositories
- Backup Option: Archive repositories before deletion
- Audit Logging: Detailed logs of all operations
- Format code:
uv pip install black
black .- Run linter:
uv pip install ruff
ruff check .- Run type checker:
uv pip install mypy
mypy .- Run tests:
uv pip install pytest
pytestSee Architecture Documentation for detailed technical information about:
- System components
- Data flow
- Security considerations
- Error handling
- Monitoring and logging
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- GitHub API documentation and team
- Python and its community
- All contributors to this project
# Install dependencies
uv pip install -r requirements.txt
# Run the tool
python -m ghcleanupSee API Documentation for detailed information about available endpoints and usage.
See CHANGELOG.md for recent changes and updates.