
Repo Cleanup
- 120 installs
- 28 repo stars
- Updated June 29, 2026
- nickcrew/claude-ctx-plugin
Helps with ai & agent building tasks.
About
repo-cleanup is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.
- repo-cleanup
- AI & Agent Building
- AI-coding skill
Repo Cleanup by the numbers
- 120 all-time installs (skills.sh)
- +7 installs in the week ending Jul 26, 2026 (Skillselion tracking)
- Ranked #3,775 of 16,556 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/nickcrew/claude-ctx-plugin --skill repo-cleanupAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 120 |
|---|---|
| repo stars | ★ 28 |
| Last updated | June 29, 2026 |
| Repository | nickcrew/claude-ctx-plugin ↗ |
What it does
Helps with ai & agent building tasks.
Files
Repo Cleanup
Overview
Establish a safe, repeatable cleanup workflow for code, dependencies, docs, tests, and sprint artifacts. Minimize risk by validating usage, archiving before deletion, and verifying with tests.
When to Use
- Repository bloat (generated artifacts, caches, unused files)
- Dead code or unused dependencies suspected
- Docs drifted from actual behavior
- Tests are brittle, redundant, or mislocated
- Sprint closure needs structured archiving
Avoid when:
- Active incident response is ongoing
- The target area lacks owners or rollback coverage
Quick Reference
| Task | Load reference |
|---|---|
| Code cleanup | skills/repo-cleanup/references/code-cleanup.md |
| Dependency cleanup | skills/repo-cleanup/references/deps-cleanup.md |
| Docs cleanup | skills/repo-cleanup/references/docs-cleanup.md |
| Test cleanup | skills/repo-cleanup/references/test-cleanup.md |
| Sprint archive | skills/repo-cleanup/references/archive-sprint.md |
Workflow
1. Define scope and safety mode (safe vs aggressive). 2. Capture baseline state (git status, key tests, backups). 3. Load the relevant reference file(s) for the target area. 4. Execute cleanup steps with usage checks before removal. 5. Validate changes (tests, build, lint, or doc checks). 6. Report outcomes (actions taken, risks, follow-ups).
Output
- Summary of actions and files touched
- Validation results and remaining risks
- Follow-up recommendations or backlog items
Common Mistakes
- Deleting without confirming usage or regenerability
- Skipping baseline tests and rollback checkpoints
- Removing dependencies without updating build/test scripts
- Collapsing docs without preserving entry points
Reference: archive-sprint
Archive completed sprint artifacts
You are tasked with archiving all artifacts from a completed sprint, including plans, summaries, reports, and temporary files.
Context
The user has completed a sprint/project and wants to:
- Archive all sprint-specific documentation
- Clean up temporary files and branches
- Preserve work for future reference
- Reset workspace for next sprint
- Document sprint outcomes
Personas (Thinking Modes)
- project-manager: Sprint retrospectives, completion criteria, outcome documentation, metrics tracking
- documentation-specialist: Archive organization, summary writing, information preservation
- devops-engineer: Branch cleanup, workspace hygiene, artifact management
Delegation Protocol
This command does NOT delegate - Sprint archival is direct file operations.
Why no delegation:
- ❌ Fast file moving and copying operations (<2 minutes)
- ❌ Straightforward git branch cleanup (atomic commands)
- ❌ Template-based summary generation (fill-in-the-blanks)
- ❌ Simple directory structure creation
All work done directly:
- Bash for file operations (mv, mkdir, rm)
- Write for sprint summary creation
- Read for identifying sprint artifacts
- Git commands for branch cleanup
- TodoWrite for tracking cleanup steps
Note: While this doesn't delegate, the personas guide thinking to ensure comprehensive archival (PM for metrics, documentation for clarity, devops for cleanliness).
Tool Coordination
- Bash: File operations, git branch cleanup (direct)
- Write: Create sprint summary from template (direct)
- Read: Identify sprint artifacts and documentation (direct)
- Glob: Find sprint-related files by pattern (direct)
- TodoWrite: Track multi-step archival process (direct)
Task Requirements
1. Analysis Phase
Identify sprint artifacts:
Documentation:
- Sprint plans:
*PLAN*.md,*SPRINT*.md - Task breakdowns:
*TASKS*.md,*TODO*.md - Progress summaries:
*PROGRESS*.md,*SUMMARY*.md - Status reports:
*STATUS*.md,*REPORT*.md - POC documents:
POC_*.md,*POC*.md - Meeting notes:
*NOTES*.md,*MINUTES*.md
Code artifacts:
- Feature branches
- Experimental code:
experiments/,prototype/ - Debug scripts:
debug-*.ts,test-*.ts - Temporary utilities:
tmp-*.ts,scratch-*.ts
Generated files:
- Test reports
- Coverage reports
- Performance benchmarks
- Build artifacts
- Log files
Configuration:
- Temporary configs:
config.tmp.*,*.backup - Environment files:
.env.backup,.env.old
2. Archive Structure
Create sprint-specific archive:
docs/archive/sprints/
└── YYYY-MM-sprint-name/
├── README.md # Sprint summary
├── plans/ # Sprint planning docs
│ ├── sprint-plan.md
│ ├── task-breakdown.md
│ └── acceptance-criteria.md
├── progress/ # Progress tracking
│ ├── daily-updates/
│ ├── weekly-summaries/
│ └── blockers.md
├── poc/ # POCs and experiments
│ ├── poc-summary.md
│ └── experimental-code/
├── reports/ # Sprint reports
│ ├── completion-report.md
│ ├── metrics.md
│ └── retrospective.md
├── code-samples/ # Notable code examples
└── assets/ # Screenshots, diagrams3. Sprint Summary Template
Create docs/archive/sprints/YYYY-MM-sprint-name/README.md:
# Sprint: [Sprint Name] - [YYYY-MM]
**Duration**: [Start Date] - [End Date]
**Status**: ✅ Complete / ⚠️ Partial / ❌ Incomplete
---
## Sprint Goals
### Primary Objectives
1. [Goal 1]
2. [Goal 2]
3. [Goal 3]
### Stretch Goals
1. [Stretch 1]
2. [Stretch 2]
---
## Outcomes
### Completed ✅
- [Task 1] - [Brief description]
- [Task 2] - [Brief description]
- [Task 3] - [Brief description]
### Incomplete ❌
- [Task X] - [Reason not completed]
- [Task Y] - [Moved to next sprint]
### Success Metrics
| Metric | Target | Actual | Status |
|--------|--------|--------|--------|
| Test Coverage | 85% | 88% | ✅ |
| Tasks Completed | 15 | 14 | ⚠️ |
| Bugs Fixed | 10 | 12 | ✅ |
| Documentation | 100% | 95% | ⚠️ |
---
## Key Deliverables
1. **[Deliverable 1]**
- Location: [Path or URL]
- Description: [What was delivered]
- Status: [Deployed/Merged/Complete]
2. **[Deliverable 2]**
- Location: [Path or URL]
- Description: [What was delivered]
- Status: [Deployed/Merged/Complete]
---
## Technical Decisions
### Architecture Changes
- [Decision 1]: [Rationale]
- [Decision 2]: [Rationale]
### Technology Adopted
- [Technology]: [Why and how used]
### Deprecated/Removed
- [What was removed]: [Why]
---
## Challenges & Solutions
### Challenge 1: [Description]
**Impact**: [How it affected sprint]
**Solution**: [How it was resolved]
**Learning**: [What we learned]
### Challenge 2: [Description]
**Impact**: [How it affected sprint]
**Solution**: [How it was resolved]
**Learning**: [What we learned]
---
## Code Changes
### Files Added
- [List significant new files]
### Files Modified
- [List significantly changed files]
### Files Removed
- [List deleted files]
### Pull Requests
- #123 - [PR title and description]
- #124 - [PR title and description]
---
## Testing
### Test Coverage
- Unit tests: [X tests, Y% coverage]
- Integration tests: [X tests]
- E2E tests: [X tests]
### Known Issues
- [Issue 1]: [Description and plan]
- [Issue 2]: [Description and plan]
---
## Documentation
### Created
- [Doc 1]: [Description]
- [Doc 2]: [Description]
### Updated
- [Doc 1]: [What changed]
- [Doc 2]: [What changed]
---
## Retrospective
### What Went Well 🎉
- [Success 1]
- [Success 2]
- [Success 3]
### What Could Be Improved 🔧
- [Area 1]: [Suggestion]
- [Area 2]: [Suggestion]
### Action Items for Next Sprint
- [ ] [Action 1]
- [ ] [Action 2]
- [ ] [Action 3]
---
## Metrics
### Velocity
- Story points completed: [X]
- Story points planned: [Y]
- Velocity: [X/Y = Z%]
### Time Breakdown
- Development: [X hours]
- Testing: [Y hours]
- Code Review: [Z hours]
- Meetings: [A hours]
- Documentation: [B hours]
### Quality
- Bugs introduced: [X]
- Bugs fixed: [Y]
- Code review cycles: [Avg Z per PR]
- Build failures: [X]
---
## Team
### Contributors
- [Name 1] - [Role/Contribution]
- [Name 2] - [Role/Contribution]
### Thanks To
- [Person] - [Why thanking them]
---
## Next Steps
### Immediate (Next Sprint)
- [ ] [Task from incomplete items]
- [ ] [Follow-up work]
### Future (Backlog)
- [ ] [Long-term improvement]
- [ ] [Tech debt item]
---
## References
### Documentation
- [Link to sprint plan]
- [Link to task breakdown]
- [Link to retrospective notes]
### Code
- [Link to feature branch]
- [Link to deployment]
- [Link to merged PRs]
### External
- [Link to designs]
- [Link to requirements]---
Execution Steps
Use TodoWrite to track progress:
1. Identify sprint artifacts
- Search for sprint-related docs
- Identify temporary files
- List feature branches
- Check for POC code
2. Create archive structure
- Create sprint directory
- Create subdirectories
- Set up README template
3. Archive documentation
- Move sprint plans
- Move progress updates
- Move reports
- Move meeting notes
4. Archive code artifacts
- Archive experimental code
- Archive debug scripts
- Document removed features
- Save code samples
5. Clean temporary files
- Remove debug scripts
- Remove temporary configs
- Remove backup files
- Remove scratch files
6. Document outcomes
- Fill sprint summary
- List deliverables
- Document decisions
- Record metrics
7. Clean git branches
- List merged branches
- Delete merged branches
- Archive unmerged branches (tags)
8. Validate workspace
- Verify clean git status
- Run tests
- Run build
- Check for leftover artifacts
Success Criteria
- [ ] Sprint summary created
- [ ] All sprint docs archived
- [ ] Temporary files removed
- [ ] Code artifacts preserved
- [ ] Branches cleaned up
- [ ] Metrics documented
- [ ] Retrospective recorded
- [ ] Next steps identified
- [ ] Workspace clean for next sprint
Git Branch Cleanup
Safe branch deletion:
# List all branches
git branch -a
# List merged branches
git branch --merged main
# Delete merged branches (after confirmation)
git branch -d feature/sprint-x-task-1
git branch -d feature/sprint-x-task-2
# For unmerged but completed work, create tags
git tag archive/sprint-x-feature-y feature/sprint-x-feature-y
git branch -D feature/sprint-x-feature-y
# Delete remote branches (after confirmation)
git push origin --delete feature/sprint-x-task-1Branch archive strategy:
# Create archive tags for all sprint branches
for branch in $(git branch --list "feature/sprint-x-*"); do
tag="archive/sprint-x/$(basename $branch)"
git tag $tag $branch
echo "Archived $branch as $tag"
done
# Push archive tags
git push origin --tags
# Delete local sprint branches
git branch --list "feature/sprint-x-*" | xargs git branch -D
# Delete remote sprint branches
git branch -r --list "origin/feature/sprint-x-*" | \
sed 's/origin\///' | \
xargs -I {} git push origin --delete {}Output Format
Provide: 1. Sprint summary with key metrics 2. List of archived documentation 3. List of cleaned temporary files 4. List of deleted branches 5. Workspace validation results 6. Retrospective highlights 7. Next sprint preparation checklist 8. Git commit message
Edge Cases
If encountering:
- Unmerged work: Tag before deleting branches
- Incomplete features: Document reason in summary
- Sensitive data: Ask before archiving
- Large files: Compress or link to external storage
- Ongoing work: Clarify sprint boundaries with user
Common Sprint Types
Feature Sprint
- Focus on sprint summary completeness
- Archive POC code
- Document architecture decisions
- Preserve code samples
Bug Fix Sprint
- Document bugs fixed
- Archive debugging tools
- Record solutions
- Update known issues
Refactoring Sprint
- Document code changes
- Before/after comparisons
- Performance improvements
- Tech debt reduction
Research Sprint
- Archive research findings
- Preserve POC code
- Document recommendations
- Link to external resources
Prevention Tips
Include in summary:
- Use sprint-specific branches
- Maintain daily progress updates
- Document decisions as you go
- Clean up incrementally during sprint
- Schedule archival as last sprint task
- Automate branch cleanup in CI
Reference: code-cleanup
Clean up code directories
You are tasked with cleaning up source code directories by removing build artifacts, dead code, unused files, and organizing test/example files.
Context
The user wants to maintain clean code directories by:
- Removing build artifacts and generated files
- Identifying and removing dead/unused code
- Organizing example and test files
- Improving project structure
- Reducing repository bloat
Personas (Thinking Modes)
- developer: Code organization, dead code identification, import analysis, refactoring safety
- quality-engineer: Code health metrics, technical debt management, cleanup standards
- devops-engineer: Build artifact management, .gitignore patterns, workspace hygiene
Delegation Protocol
This command does NOT delegate - Code cleanup is direct file and tooling operations.
Why no delegation:
- ❌ Fast file removal (rm, git rm operations)
- ❌ Simple tool execution (ts-prune, depcheck, unimported)
- ❌ Straightforward file reorganization (mv, git mv)
- ❌ Direct .gitignore editing
All work done directly:
- Bash for build artifact removal and file reorganization
- Bash for running analysis tools (ts-prune, depcheck)
- Read/Write for .gitignore updates
- Grep for import/reference searching
- TodoWrite for tracking cleanup steps
Note: Personas ensure thorough cleanup (developer for safety, quality for standards, devops for automation patterns).
Tool Coordination
- Bash: Remove artifacts, reorganize files, run analysis tools (direct)
- Grep: Search for imports and references (direct)
- Glob: Find files by pattern for cleanup (direct)
- Edit/Write: Update .gitignore (direct)
- TodoWrite: Track multi-step cleanup process (direct)
Task Requirements
1. Analysis Phase
Identify files to remove or reorganize:
Remove (build artifacts & generated files):
- Build output directories:
dist/,build/,.next/,.nuxt/,out/ - Cache directories:
.vite/,.turbo/,.nx/cache/,.parcel-cache/ - Coverage reports:
coverage/,.nyc_output/,htmlcov/ - Test reports:
test-results/,junit.xml,report.html - Temporary files:
*.tmp,*.temp,.cache/,tmp-* - Lock files (if regenerable):
package-lock.jsonconflicts
Remove (OS/IDE artifacts):
.DS_Store(macOS)Thumbs.db(Windows)*.swp,*.swo(Vim).vscode/(if not shared).idea/(if not shared)
Reorganize (misplaced files):
- Example scripts not in
examples/ - Test files not in
tests/or__tests__/ - Debug scripts not in
scripts/debug/ - Documentation not in
docs/
Investigate (potential dead code):
- Files not imported anywhere
- Functions/classes not used
- Commented-out code blocks (>20 lines)
- TODO/FIXME comments (catalog)
2. Safe Removal Process
Before removing anything:
1. Run tests to establish baseline 2. Check git history for recent changes 3. Search for imports/references in codebase 4. Verify it's generated (can be rebuilt)
Removal categories:
# Safe to delete immediately
rm -rf dist/ build/ coverage/ .vite/ .DS_Store
# Move to archive before deleting (30-day hold)
mkdir -p .cleanup-archive/$(date +%Y-%m-%d)
mv SUSPICIOUS_FILE .cleanup-archive/$(date +%Y-%m-%d)/
# Ask user before removing
echo "Found potential dead code: FILE - used in 0 places"3. Code Organization
Standard structure:
src/
├── components/ # React/Vue components
├── services/ # Business logic
├── utils/ # Helper functions
├── types/ # TypeScript types
├── hooks/ # React hooks
├── store/ # State management
└── __tests__/ # Unit tests (colocated)
tests/
├── unit/ # Unit tests
├── integration/ # Integration tests
├── e2e/ # End-to-end tests
└── fixtures/ # Test data
examples/
├── basic/ # Simple examples
├── advanced/ # Complex examples
└── integrations/ # Integration examples
scripts/
├── build/ # Build scripts
├── deploy/ # Deployment scripts
└── debug/ # Debug utilitiesMove misplaced files:
# Example scripts
mv debug-*.ts examples/debug/
mv test-*.ts examples/testing/
# Test files
mv src/foo.test.ts tests/unit/
mv integration-test.ts tests/integration/
# Documentation
mv HOWTO.md docs/guides/4. Dead Code Detection
Use tools:
# TypeScript - find unused exports
npx ts-prune
# JavaScript - find unused code
npx depcheck
# Find files not imported
npx unimported
# Find unused dependencies
npx depcheck --json > unused-deps.jsonManual inspection:
1. Search for imports: grep -r "from './FILE'" . 2. Check git log: git log --follow FILE 3. Check last modified: find . -name "FILE" -mtime +180 4. Count references: grep -r "FUNCTION_NAME" . | wc -l
Decision matrix:
| Condition | Action |
|---|---|
| No imports, >6 months old | Remove |
| No imports, <6 months old | Ask user |
| Imported but unused | Investigate further |
| TODO/FIXME, >1 year old | Ask user |
| Commented code, >50 lines | Remove |
5. .gitignore Update
Ensure comprehensive .gitignore:
# Build artifacts
dist/
build/
out/
.next/
.nuxt/
# Cache
.cache/
.vite/
.turbo/
.nx/cache/
.parcel-cache/
node_modules/.cache/
# Testing
coverage/
.nyc_output/
test-results/
playwright-report/
htmlcov/
.pytest_cache/
# IDEs
.vscode/
.idea/
*.swp
*.swo
*.swn
# OS
.DS_Store
Thumbs.db
Desktop.ini
# Temporary
*.tmp
*.temp
tmp-*
.cleanup-archive/
# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*6. Documentation
Create cleanup report at docs/cleanup-reports/CODE_CLEANUP_$(date +%Y-%m-%d).md:
# Code Cleanup Report - [Date]
## Summary
- Removed X build artifacts
- Cleaned Y cache directories
- Reorganized Z misplaced files
- Identified A potential dead code files
## Actions Taken
### Removed (Build Artifacts)
- [List removed directories/files]
- Disk space saved: XXX MB
### Removed (Dead Code)
- [List removed files with justification]
### Reorganized
- [List moved files with before/after paths]
### .gitignore Updates
- [List patterns added]
## Potential Issues
- [List files needing user decision]
- [List TODO/FIXME items found]
## Validation
- [ ] Tests still passing
- [ ] Build succeeds
- [ ] No broken imports
- [ ] Git status clean
## Prevention
- [Recommendations to avoid future bloat]Execution Steps
Use TodoWrite to track progress:
1. Analyze directory structure
- List all files
- Identify build artifacts
- Find cache directories
- Check for OS/IDE files
2. Safe removal (build artifacts)
- Remove dist/build directories
- Remove cache directories
- Remove test reports
- Remove temporary files
3. Update .gitignore
- Add missing patterns
- Ensure comprehensive coverage
- Test with
git status
4. Detect dead code
- Run ts-prune/depcheck
- Search for unused imports
- Check file ages
- Catalog findings
5. Reorganize misplaced files
- Move examples to examples/
- Move tests to tests/
- Move scripts to scripts/
- Update imports
6. Remove dead code (with approval)
- Present findings to user
- Get confirmation
- Remove approved files
- Update references
7. Validate
- Run tests
- Run build
- Check for broken imports
- Verify git status
8. Document cleanup
- Create cleanup report
- List all changes
- Provide commit message
Success Criteria
- [ ] All build artifacts removed
- [ ] Cache directories cleaned
- [ ] OS/IDE artifacts removed
- [ ] .gitignore updated
- [ ] Misplaced files reorganized
- [ ] Dead code identified (and removed if approved)
- [ ] Tests passing
- [ ] Build succeeds
- [ ] Cleanup report created
- [ ] Disk space saved (>50MB typical)
Safety Rules
NEVER remove without checking:
- Files modified in last 7 days
- Files with unclear purpose
- Files that might be data/config
- Files referenced in docs
ALWAYS:
- Run tests before and after
- Use git mv for reorganization
- Create cleanup report
- Ask user for uncertain files
- Verify builds succeed
Output Format
Provide: 1. Summary table (files removed, space saved) 2. List of removed build artifacts 3. List of reorganized files 4. Dead code findings (with recommendations) 5. .gitignore updates 6. Validation results 7. Git commit message (copy-pasteable)
Edge Cases
If encountering:
- Large files (>10MB): Report size, ask before removing
- Recently modified artifacts: Verify they're truly artifacts
- Unknown file types: Ask user
- Potential configuration: Keep and ask user
- Data files: Never remove, ask user
Common Patterns
Monorepo cleanup:
# Clean all apps
for app in apps/*; do
rm -rf $app/dist $app/coverage $app/.vite
done
# Clean all packages
for pkg in packages/*; do
rm -rf $pkg/dist $pkg/coverage
doneTypeScript project:
# Remove build outputs
rm -rf dist/ build/ lib/
# Remove TypeScript cache
rm -rf .tsbuildinfo
# Regenerate
pnpm buildReact/Next.js project:
# Remove build artifacts
rm -rf .next/ out/ build/
# Remove cache
rm -rf .cache/ node_modules/.cache/
# Rebuild
pnpm buildPrevention Tips
Include in report:
- Set up pre-commit hooks to prevent committing artifacts
- Add comprehensive .gitignore early
- Configure IDE to exclude build directories
- Regular cleanup (monthly/quarterly)
- Use tools like
npx ts-prunein CI - Monitor repository size trends
Reference: deps-cleanup
Clean up dependencies and package management
You are tasked with cleaning up project dependencies, removing unused packages, updating outdated dependencies, and organizing package management files.
Context
The user wants to maintain clean dependency management by:
- Removing unused dependencies
- Updating outdated packages
- Deduplicating dependencies
- Organizing lock files
- Reducing package bloat
- Improving security
Personas (Thinking Modes)
- developer: Dependency usage analysis, import tracing, safe removal verification
- security-specialist: Vulnerability assessment, security audit, compliance checking
- devops-engineer: Package management, lock file maintenance, CI/CD integration
- performance-engineer: Bundle size optimization, install time reduction, dependency efficiency
Delegation Protocol
This command does NOT delegate - Dependency cleanup is direct tooling and file operations.
Why no delegation:
- ❌ Direct tool execution (depcheck, npm audit, npm outdated)
- ❌ Simple package operations (pnpm remove, pnpm update)
- ❌ Fast validation cycles (test after each change)
- ❌ Atomic git operations (commit per dependency change)
All work done directly:
- Bash for package manager commands (pnpm remove, update, dedupe)
- Bash for analysis tools (depcheck, npm audit)
- Read for package.json analysis
- Edit for package.json updates
- TodoWrite for tracking cleanup steps
Note: Personas ensure thorough cleanup (developer for safety, security for vulnerabilities, devops for automation, performance for efficiency).
Tool Coordination
- Bash: Package manager commands, analysis tools, testing (direct)
- Read/Edit: package.json analysis and updates (direct)
- Grep: Find package usage in codebase (direct)
- Write: Create dependency reports (direct)
- TodoWrite: Track multi-step dependency cleanup (direct)
Task Requirements
1. Analysis Phase
Identify dependency issues:
Unused dependencies:
- Packages in package.json but not imported
- DevDependencies not used in scripts/tests
- Transitive dependencies (unused by used packages)
Outdated dependencies:
- Packages with major version updates
- Packages with security vulnerabilities
- Deprecated packages
Duplicate dependencies:
- Multiple versions of same package
- Overlapping functionality (lodash + lodash-es)
- Redundant utilities
Lock file issues:
- Uncommitted lock file changes
- Corrupted lock files
- Conflicts between package managers
2. Dependency Analysis Tools
Run analysis tools:
# Find unused dependencies
npx depcheck
# Check for outdated packages
npm outdated
# or
pnpm outdated
# Find duplicate dependencies
npm ls [package-name]
# or
pnpm list --depth Infinity | grep [package-name]
# Security audit
npm audit
# or
pnpm audit
# Find deprecated packages
npm-check -u
# Analyze bundle size impact
npx webpack-bundle-analyzer
# Check license compliance
npx license-checker --summary3. Safe Removal Process
Decision matrix for removal:
| Finding | Action |
|---|---|
| Not in package.json | No action needed |
| In package.json, not imported | Remove (safe) |
| In devDependencies, not in scripts | Investigate, likely remove |
| Direct dep, only used by removed feature | Remove |
| Transitive dep | Don't remove (managed by parent) |
| Has security vulnerability | Update or remove |
| Deprecated | Find replacement |
Removal process:
# 1. Create safety branch
git checkout -b deps-cleanup
# 2. Remove suspected unused dependency
pnpm remove [package-name]
# 3. Test immediately
pnpm build
pnpm test
pnpm type-check
# 4. If tests fail, restore and investigate
git restore package.json pnpm-lock.yaml
# Find where it's actually used
grep -r "[package-name]" src/ tests/
# 5. If tests pass, commit removal
git add package.json pnpm-lock.yaml
git commit -m "chore(deps): remove unused [package-name]"4. Update Strategy
Update categories:
# Safe updates (patch versions)
pnpm update --latest
# Minor version updates (review breaking changes)
pnpm update --latest --interactive
# Major version updates (careful, test thoroughly)
pnpm update --latest [package-name]
# Update all (risky, only if comprehensive tests)
pnpm update --latest --recursiveUpdate priority:
1. Critical: Security vulnerabilities (immediate) 2. High: Deprecated packages (next sprint) 3. Medium: Outdated dev dependencies (monthly) 4. Low: Outdated production deps (quarterly)
Safe update process:
# 1. Update one at a time
pnpm update [package-name]
# 2. Run full test suite
pnpm test:all
# 3. Check for breaking changes
npm info [package-name] version
npm view [package-name] changelog
# 4. Update code if needed
# [Fix breaking changes]
# 5. Commit update
git add package.json pnpm-lock.yaml
git commit -m "chore(deps): update [package-name] from X to Y"
# 6. Repeat for next package5. Deduplication
Find duplicates:
# npm
npm dedupe
# pnpm (automatic deduplication, but verify)
pnpm dedupe
# Check for duplicates
pnpm list --depth Infinity | grep "─[─┬]" | sort | uniq -dResolve version conflicts:
# Force single version in package.json
{
"overrides": {
"package-name": "1.2.3"
}
}
# Or in pnpm-workspace.yaml
{
"pnpm": {
"overrides": {
"package-name": "1.2.3"
}
}
}6. Lock File Maintenance
Clean lock files:
# Remove node_modules and lock file
rm -rf node_modules pnpm-lock.yaml
# Reinstall from scratch
pnpm install
# Verify builds and tests
pnpm build && pnpm testFix lock file issues:
# Resolve conflicts (use theirs/ours)
git checkout --theirs pnpm-lock.yaml
pnpm install
# Validate lock file
pnpm install --frozen-lockfileLock file best practices:
- Always commit lock files
- Don't edit lock files manually
- Resolve conflicts by regenerating
- Use
--frozen-lockfilein CI - Keep lock files up to date
7. Package.json Organization
Organize dependencies:
{
"dependencies": {
// Alphabetical order
// Core framework first
"react": "^18.0.0",
"react-dom": "^18.0.0",
// UI libraries
"antd": "^5.0.0",
// Utilities
"lodash": "^4.17.21",
// APIs
"axios": "^1.0.0"
},
"devDependencies": {
// Type definitions
"@types/node": "^20.0.0",
"@types/react": "^18.0.0",
// Build tools
"vite": "^5.0.0",
// Testing
"vitest": "^1.0.0",
// Linting
"eslint": "^8.0.0"
}
}Separate concerns:
{
"dependencies": {
// Production runtime dependencies only
},
"devDependencies": {
// Development, testing, building
},
"peerDependencies": {
// Expected to be provided by consumer
},
"optionalDependencies": {
// Optional enhancements
}
}8. Dependency Report
Create docs/cleanup-reports/DEPS_CLEANUP_$(date +%Y-%m-%d).md:
# Dependency Cleanup Report - [Date]
## Summary
- Removed X unused dependencies
- Updated Y outdated packages
- Fixed Z security vulnerabilities
- Reduced package count by N%
- Reduced install size by M MB
## Actions Taken
### Removed (Unused)
| Package | Version | Reason | Size Saved |
|---------|---------|--------|------------|
| foo | 1.2.3 | Not imported | 2.3 MB |
| bar | 4.5.6 | Replaced by baz | 1.1 MB |
### Updated
| Package | From | To | Changes | Risk |
|---------|------|-----|---------|------|
| react | 17.0.0 | 18.2.0 | Breaking: [link] | Medium |
| lodash | 4.17.20 | 4.17.21 | Security fix | Low |
### Security Fixes
| Vulnerability | Package | Severity | Fix |
|---------------|---------|----------|-----|
| CVE-2023-1234 | axios | High | Updated to 1.4.0 |
### Deduplicated
| Package | Before | After |
|---------|--------|-------|
| react | 3 versions | 1 version |
| lodash | 2 versions | 1 version |
## Before/After
### Package Count
- Total packages: 245 → 198 (-47)
- Dependencies: 45 → 38 (-7)
- DevDependencies: 200 → 160 (-40)
### Install Size
- Total: 523 MB → 412 MB (-111 MB, -21%)
- node_modules: 487 MB → 385 MB (-102 MB)
### Security
- Critical vulnerabilities: 2 → 0
- High vulnerabilities: 5 → 1
- Moderate vulnerabilities: 12 → 8
## Validation
### Tests
- ✅ Unit tests: 245/245 passing
- ✅ Integration tests: 45/45 passing
- ✅ E2E tests: 12/12 passing
- ✅ Coverage: 88% (maintained)
### Builds
- ✅ Development build: Success
- ✅ Production build: Success
- ✅ Type checking: 0 errors
### Performance
- Build time: 45s → 38s (-16%)
- Install time: 2m15s → 1m48s (-20%)
## Recommendations
### Immediate
- [ ] Monitor production for issues
- [ ] Update documentation for breaking changes
- [ ] Review bundle size in production
### Next Sprint
- [ ] Evaluate replacing [heavy-package] with lighter alternative
- [ ] Consider migrating from [deprecated-package] to [recommended-package]
- [ ] Set up automated dependency updates (Renovate/Dependabot)
### Long-term
- [ ] Monthly dependency audits
- [ ] Quarterly major version updates
- [ ] Bundle size monitoring in CI---
Execution Steps
Use TodoWrite to track progress:
1. Analyze current state
- Run depcheck
- Run npm outdated
- Run npm audit
- Check for duplicates
- Document current metrics
2. Remove unused dependencies
- Identify unused packages
- Test removal (one at a time)
- Commit successful removals
- Document removals
3. Update outdated packages
- Prioritize by security/importance
- Update patch versions (safe)
- Update minor versions (test)
- Update major versions (careful)
- Document updates
4. Fix security vulnerabilities
- Audit for vulnerabilities
- Update affected packages
- Verify fixes
- Document fixes
5. Deduplicate dependencies
- Run npm dedupe
- Resolve version conflicts
- Test thoroughly
- Document deduplication
6. Clean lock files
- Remove node_modules
- Remove lock file
- Reinstall fresh
- Verify builds
7. Organize package.json
- Alphabetize dependencies
- Group by category
- Add comments if helpful
- Format consistently
8. Validate changes
- Run all tests
- Run all builds
- Check bundle size
- Verify security audit
9. Document cleanup
- Create dependency report
- List all changes
- Provide commit message
- Recommend future actions
Success Criteria
- [ ] All unused dependencies removed
- [ ] Critical security issues fixed
- [ ] Outdated packages updated (or documented why not)
- [ ] Dependencies deduplicated
- [ ] Lock files clean and valid
- [ ] All tests passing
- [ ] All builds succeeding
- [ ] Bundle size reduced or maintained
- [ ] Security audit clean
- [ ] Dependency report created
Safety Rules
NEVER:
- Remove dependencies without testing
- Update all dependencies at once
- Ignore breaking changes
- Skip testing after updates
- Commit broken lock files
ALWAYS:
- Update one dependency at a time
- Run full test suite after changes
- Read changelogs for major updates
- Commit lock file with package.json
- Document breaking changes
Output Format
Provide: 1. Dependency analysis summary 2. Table of removed packages 3. Table of updated packages 4. Security fix summary 5. Before/after metrics 6. Validation results 7. Recommendations 8. Git commit message
Edge Cases
If encountering:
- Peer dependency conflicts: Use overrides or find compatible versions
- Missing types: Install @types/* packages separately
- Build failures after update: Rollback and investigate
- Test failures: Fix tests or rollback update
- Breaking changes: Document and update code accordingly
Monorepo Considerations
For Nx/pnpm workspaces:
# Update all workspace packages
pnpm update --recursive
# Remove from specific workspace
pnpm --filter @workspace/app remove package
# Deduplicate across workspace
pnpm dedupe
# Audit entire workspace
pnpm audit --recursivePrevention Tips
Include in report:
- Set up Dependabot or Renovate for automated updates
- Add
pnpm auditto CI pipeline - Monitor bundle size in CI
- Regular dependency review (monthly)
- Use
pnpm dlx npx-check -ufor interactive updates - Document dependency decisions in ADRs
Reference: docs-cleanup
Clean up documentation directory
You are tasked with cleaning up a documentation directory (root or docs/) by archiving completed task documentation and organizing active files.
Context
The user wants to maintain a clean, organized documentation structure by:
- Archiving completed task documentation, POC summaries, and reports
- Keeping only actively-used documentation at the root level
- Improving discoverability and reducing cognitive load
Personas (Thinking Modes)
- documentation-specialist: Content categorization, archival decisions, documentation lifecycle management
- information-architect: Organization structure, discoverability, taxonomy design
- developer: Active vs historical distinction, operational documentation needs
Delegation Protocol
This command does NOT delegate - Documentation cleanup is direct file operations.
Why no delegation:
- ❌ Fast file moving operations (git mv)
- ❌ Simple directory creation (mkdir)
- ❌ Template-based summary creation
- ❌ Straightforward categorization (active vs archive)
All work done directly:
- Bash for file operations (mv, git mv, mkdir)
- Read for analyzing documentation content
- Write for creating cleanup summaries
- Glob for finding documentation files
- TodoWrite for tracking cleanup steps
Note: Personas guide documentation decisions (specialist for lifecycle, architect for organization, developer for operational needs).
Tool Coordination
- Bash: File operations, git mv for tracked files (direct)
- Read: Analyze documentation content for categorization (direct)
- Write: Create cleanup summaries (direct)
- Glob: Find documentation by pattern (direct)
- Edit: Update .gitignore (direct)
- TodoWrite: Track cleanup steps (direct)
Task Requirements
1. Analysis Phase
Identify files to archive by reading and categorizing:
Archive candidates:
- Task planning documents (e.g.,
*PLAN*.md,*TASK*.md) - Sprint/project summaries (e.g.,
*SUMMARY*.md,*PROGRESS*.md) - POC summaries (e.g.,
POC_*.md) - Cleanup/analysis reports (e.g.,
*REPORT*.md,*CLEANUP*.md) - Duplicate content (covered elsewhere)
- Historical documentation (completed initiatives)
Keep as active:
- Core guides (README, CONTRIBUTING, ARCHITECTURE)
- Onboarding documentation (QUICK_START, ONBOARDING_CHECKLIST)
- Operational guides (DEPLOYMENT, MAINTENANCE_CHECKLIST)
- Philosophy/design docs (DESIGN_PHILOSOPHY)
- Testing/development guides (TEST-REPORTING)
2. Archive Organization
Create archive structure if it doesn't exist:
mkdir -p docs/archive/completed-tasks
mkdir -p docs/archive/reports
mkdir -p docs/archive/poc
mkdir -p docs/archive/deprecatedArchive categories:
completed-tasks/- Sprint plans, task docs, project summariesreports/- Analysis reports, cleanup reports, audit reportspoc/- POC summaries and experimental demosdeprecated/- Outdated but still referenced content
3. File Movement
Use git mv for tracked files, mv for untracked:
# For tracked files
git mv FILE.md docs/archive/CATEGORY/
# For untracked files
mv FILE.md docs/archive/CATEGORY/Rules:
- Preserve file names (don't rename during archiving)
- Use git mv to maintain history for tracked files
- Group related files in same category
4. Generated Artifacts
Identify and remove (not archive):
- Generated reports with timestamps (e.g.,
link-check-reports/) - Build artifacts (e.g.,
html-report/,coverage/) - Temporary files (e.g.,
tmp-*,.cache/)
Update .gitignore to prevent future pollution:
# Reports and build artifacts
reports/
link-check-reports/
html-report/
coverage/5. Documentation
Create cleanup summary at docs/archive/[DIRECTORY]_CLEANUP_SUMMARY.md:
Include:
- Date and status
- List of archived files with rationale
- List of retained files with rationale
- Before/after metrics (file count reduction)
- Archive structure explanation
- Maintenance guidelines (when to archive)
- Suggested git commit message
Template structure:
# [Directory] Cleanup Summary
**Date**: YYYY-MM-DD
**Status**: ✅ Complete
## Actions Taken
[List what was archived and why]
## Structure (After Cleanup)
[Show clean structure]
## Success Metrics
[Before/after comparison table]
## Rationale
[Why these decisions were made]
## Maintenance Guidelines
[When to archive, criteria for active vs archive]
## Git Commit
[Suggested commit message]6. Validation
Verify:
- Correct number of files moved
- Archive structure is organized
- No broken links created
- Active files are truly active
- Git status shows renames (R) not deletions (D)
Execution Steps
Use TodoWrite to track progress:
1. Analyze directory structure
- List all markdown files
- Read files to understand content
- Categorize as active or archive candidate
2. Create archive structure
- Create necessary directories
- Verify structure
3. Archive completed tasks
- Move task plans and summaries
- Move POC summaries
- Move project completion docs
4. Archive reports
- Move cleanup reports
- Move analysis reports
- Move audit reports
5. Clean generated artifacts
- Remove timestamped reports
- Remove build artifacts
- Update .gitignore
6. Create cleanup summary
- Document all changes
- Provide rationale
- Include maintenance guidelines
- Suggest commit message
7. Validate results
- Verify file counts
- Check git status
- Confirm organization
Success Criteria
- [ ] Archive structure created and organized
- [ ] All historical docs archived appropriately
- [ ] Only active docs remain at root level
- [ ] Generated artifacts removed
- [ ] .gitignore updated
- [ ] Cleanup summary created
- [ ] File count reduced by 40-70%
- [ ] Clear separation of active vs historical
Output Format
Provide: 1. Summary table (before/after file counts) 2. List of archived files with destinations 3. List of retained files with rationale 4. Git commit message (copy-pasteable) 5. Link to cleanup summary document
Edge Cases
If encountering:
- Uncertain files: Ask user for guidance
- Large files (>100KB): Confirm before archiving
- Recently modified files: Double-check if truly historical
- Files referenced in code: Keep active or create deprecation notice
Reusability
This approach works for:
- Root-level documentation cleanup
- docs/ directory cleanup
- App-specific docs cleanup (apps/*/docs/)
- Any documentation directory needing organization
Adjust archive location based on context:
- Root cleanup →
docs/archive/ - docs/ cleanup →
docs/archive/ - App cleanup →
apps/APP/docs/archive/
Reference: test-cleanup
Clean up test directories and reports
You are tasked with organizing test files, cleaning up test reports, and improving test structure.
Context
The user wants to maintain clean test directories by:
- Organizing test files into proper structure
- Removing generated test reports
- Consolidating test configurations
- Improving test discoverability
- Archiving obsolete tests
Personas (Thinking Modes)
- test-engineer: Test organization, test categorization, test quality standards, fixture management
- quality-engineer: Test smell detection, coverage analysis, test health metrics
- developer: Test structure, import updates, test refactoring
Delegation Protocol
This command does NOT delegate - Test cleanup is direct file operations and tool execution.
Why no delegation:
- ❌ Fast artifact removal (coverage reports, screenshots)
- ❌ Simple file reorganization (mv test files)
- ❌ Direct tool execution (grep for .skip, .only)
- ❌ Template-based documentation creation
All work done directly:
- Bash for removing test artifacts (rm -rf)
- Bash for reorganizing test files (mv, mkdir)
- Grep for finding test smells (.skip, .only, missing assertions)
- Write for creating tests/README.md
- TodoWrite for tracking cleanup steps
Note: Personas guide test organization thinking (test-engineer for structure, quality for smell detection, developer for safe refactoring).
Tool Coordination
- Bash: Remove artifacts, reorganize files, create directories (direct)
- Grep: Find test smells and quality issues (direct)
- Glob: Find test files by pattern (direct)
- Write: Create test documentation (direct)
- Edit: Update .gitignore (direct)
- TodoWrite: Track multi-step cleanup process (direct)
Task Requirements
1. Analysis Phase
Identify test organization issues:
Test file locations:
- Colocated tests:
src/**/*.test.ts,src/**/*.spec.ts - Separate tests:
tests/,__tests__/,test/ - E2E tests:
e2e/,tests/e2e/,cypress/,playwright/ - Performance tests:
perf/,tests/performance/ - Integration tests:
tests/integration/,integration/
Generated test artifacts (REMOVE):
- Coverage reports:
coverage/,htmlcov/,.nyc_output/ - Test results:
test-results/,junit.xml,report.html - Screenshots:
tests/__screenshots__/,playwright-report/ - Videos:
cypress/videos/,test-videos/ - Traces:
playwright-traces/,test-traces/ - Logs:
test-logs/,*.test.log
Test configuration:
- Jest:
jest.config.js,jest.config.ts - Vitest:
vitest.config.ts,vitest.config.js - Playwright:
playwright.config.ts - Cypress:
cypress.config.ts - Other:
.mocharc.json,karma.conf.js
2. Recommended Test Structure
For unit and integration tests:
tests/
├── unit/ # Unit tests
│ ├── components/ # UI component tests
│ ├── services/ # Business logic tests
│ ├── utils/ # Helper function tests
│ └── hooks/ # Hook tests
├── integration/ # Integration tests
│ ├── api/ # API integration tests
│ ├── database/ # DB integration tests
│ └── external/ # External service tests
├── fixtures/ # Test data and mocks
│ ├── data/ # Mock data
│ ├── mocks/ # Mock implementations
│ └── factories/ # Test factories
├── helpers/ # Test utilities
│ ├── setup.ts # Test setup
│ ├── teardown.ts # Test teardown
│ └── assertions.ts # Custom matchers
└── README.md # Testing guideFor E2E tests:
tests/e2e/
├── specs/ # Test specifications
│ ├── auth/ # Authentication flows
│ ├── user/ # User workflows
│ └── admin/ # Admin workflows
├── fixtures/ # E2E test data
├── page-objects/ # Page object models
└── README.md # E2E testing guideFor performance tests:
tests/performance/
├── load/ # Load tests
├── stress/ # Stress tests
├── spike/ # Spike tests
└── endurance/ # Endurance tests3. Test File Organization
Decision tree for test placement:
Is it testing a single function/class?
├─ YES → Unit test (tests/unit/)
└─ NO → Is it testing multiple components?
├─ YES → Integration test (tests/integration/)
└─ NO → Is it testing through UI?
├─ YES → E2E test (tests/e2e/)
└─ NO → Is it testing performance?
├─ YES → Performance test (tests/performance/)
└─ NO → Consult userNaming conventions:
Unit tests:
- tests/unit/utils/string-utils.test.ts
- tests/unit/services/user-service.test.ts
Integration tests:
- tests/integration/api/user-api.test.ts
- tests/integration/database/user-repository.test.ts
E2E tests:
- tests/e2e/specs/auth/login.spec.ts
- tests/e2e/specs/user/profile-update.spec.ts
Performance tests:
- tests/performance/load/api-load.test.ts
- tests/performance/stress/database-stress.test.ts4. Cleanup Actions
Remove generated artifacts:
# Coverage reports
rm -rf coverage/ htmlcov/ .nyc_output/
# Test results
rm -rf test-results/ junit.xml report.html
# E2E artifacts
rm -rf playwright-report/ test-results/
rm -rf cypress/videos/ cypress/screenshots/
rm -rf test-videos/ test-screenshots/
# Logs
rm -rf test-logs/ *.test.logConsolidate test configs:
# Before (scattered)
jest.config.js
jest.config.unit.js
jest.config.integration.js
vitest.config.ts
playwright.config.ts
# After (organized)
tests/
├── config/
│ ├── vitest.config.ts # Main config
│ ├── vitest.unit.config.ts # Unit test config
│ ├── vitest.int.config.ts # Integration config
│ └── playwright.config.ts # E2E configArchive obsolete tests:
# Tests for removed features
mkdir -p tests/archive/obsolete/
mv tests/unit/old-feature.test.ts tests/archive/obsolete/
# Skipped tests (>6 months)
mkdir -p tests/archive/skipped/
mv tests/unit/flaky-test.test.ts tests/archive/skipped/
# Document reason
echo "Archived: Feature removed in v2.0" > tests/archive/obsolete/old-feature.README.md5. Test Quality Improvements
Identify test smells:
# Find skipped tests
grep -r "it.skip\|test.skip\|describe.skip" tests/
# Find focused tests (shouldn't be committed)
grep -r "it.only\|test.only\|describe.only" tests/
# Find tests without assertions
grep -L "expect\|assert" tests/**/*.test.ts
# Find large test files (>500 lines)
find tests/ -name "*.test.ts" -exec wc -l {} \; | sort -rn | head -10
# Find duplicate test descriptions
grep -rh "it('\|test('" tests/ | sort | uniq -dReport findings:
## Test Quality Issues
### Skipped Tests (Action Required)
- tests/unit/foo.test.ts:45 - Skipped for 8 months
- tests/integration/bar.test.ts:78 - Skipped for 3 months
### Focused Tests (Should Not Commit)
- tests/unit/baz.test.ts:23 - it.only found
- tests/e2e/qux.spec.ts:56 - test.only found
### Tests Without Assertions
- tests/unit/empty.test.ts - No expect() calls
### Large Test Files (Consider Splitting)
- tests/unit/huge.test.ts - 847 lines
- tests/integration/massive.test.ts - 623 lines6. .gitignore Update
Add test artifact patterns:
# Test coverage
coverage/
.nyc_output/
htmlcov/
.coverage
*.cover
# Test results
test-results/
junit.xml
test-report.html
report.html
# E2E artifacts
playwright-report/
test-results-*/
cypress/videos/
cypress/screenshots/
test-videos/
test-screenshots/
playwright-traces/
# Test logs
test-logs/
*.test.log
test-output.txt
# Test cache
.vitest/
.jest/
.pytest_cache/
__pycache__/
# Test temp files
tests/tmp/
tests/temp/
tests/.cache/7. Documentation
Create tests/README.md:
# Testing Guide
## Test Structure
- `unit/` - Unit tests (isolated, fast)
- `integration/` - Integration tests (multiple components)
- `e2e/` - End-to-end tests (full workflows)
- `performance/` - Performance and load tests
- `fixtures/` - Test data and mocks
- `helpers/` - Test utilities
## Running Tests
All tests
npm test
Unit tests only
npm run test:unit
Integration tests
npm run test:integration
E2E tests
npm run test:e2e
With coverage
npm run test:coverage
Watch mode
npm run test:watch
## Writing Tests
See [Testing Guide](../docs/development/testing-guide.md)
## Test Naming
- Unit: `tests/unit/path/file.test.ts`
- Integration: `tests/integration/area/feature.test.ts`
- E2E: `tests/e2e/specs/workflow/action.spec.ts`Create cleanup report at docs/cleanup-reports/TEST_CLEANUP_$(date +%Y-%m-%d).md.
Execution Steps
Use TodoWrite to track progress:
1. Analyze test structure
- Identify all test files
- Check current organization
- Find generated artifacts
- Assess test quality
2. Remove generated artifacts
- Delete coverage reports
- Delete test results
- Delete E2E artifacts
- Delete test logs
3. Reorganize test files
- Create standard structure
- Move unit tests
- Move integration tests
- Move E2E tests
- Update imports
4. Consolidate configurations
- Move configs to tests/config/
- Update references
- Deduplicate settings
5. Archive obsolete tests
- Identify removed features
- Archive skipped tests (>6mo)
- Document reasons
6. Identify quality issues
- Find skipped tests
- Find focused tests
- Find tests without assertions
- Find large test files
7. Update .gitignore
- Add artifact patterns
- Add cache patterns
- Add temp patterns
8. Create documentation
- Create tests/README.md
- Create cleanup report
- Update main testing guide
9. Validate
- Run all tests
- Verify passing
- Check coverage
- Verify imports
Success Criteria
- [ ] Standard test structure implemented
- [ ] All generated artifacts removed
- [ ] Test files properly categorized
- [ ] Test configs consolidated
- [ ] Obsolete tests archived
- [ ] Quality issues identified
- [ ] .gitignore updated
- [ ] tests/README.md created
- [ ] All tests still passing
- [ ] Cleanup report created
Safety Rules
NEVER:
- Remove test files without checking git history
- Delete tests for active features
- Move tests without updating imports
- Skip running tests after reorganization
ALWAYS:
- Run tests before cleanup
- Run tests after cleanup
- Use git mv for tracked files
- Document archived tests
- Keep test coverage stable
Output Format
Provide: 1. Test structure analysis (before/after) 2. List of removed artifacts (space saved) 3. List of reorganized tests 4. Quality issues found 5. Archived tests with reasons 6. .gitignore updates 7. Validation results 8. Git commit message
Edge Cases
If encountering:
- Failing tests: Stop and ask user
- Unknown test framework: Ask for guidance
- Mixed test styles: Propose standardization
- Tests in multiple locations: Consolidate with approval
- Custom test runners: Preserve configuration
Common Patterns
Jest to Vitest migration:
# Update imports
find tests/ -name "*.test.ts" -exec sed -i '' 's/@jest\/globals/vitest/g' {} \;
# Update test functions
find tests/ -name "*.test.ts" -exec sed -i '' 's/test(/it(/g' {} \;Monorepo test cleanup:
# Clean all apps
for app in apps/*; do
rm -rf $app/coverage $app/test-results
done
# Standardize structure
for app in apps/*; do
mkdir -p $app/tests/{unit,integration,e2e}
donePrevention Tips
Include in report:
- Add pre-commit hooks to prevent committing .only
- Configure CI to fail on skipped tests
- Set coverage thresholds
- Regular test review (quarterly)
- Monitor test execution time
- Refactor large test files