This repository includes an automated maintenance system for easy end-of-session cleanup.
npm run maintainThis single command will:
- Clean all temporary files and build artifacts
- Update API documentation
- Lint and format code
- Run tests
- Check git status
- Run security audits
Full Maintenance (recommended for end-of-session):
npm run maintainRuns: cleanup → docs → quality checks → git check → security audit
Quick Maintenance (faster, skips tests initially):
npm run maintain:quickRuns: cleanup → lint/format fixes → git status
Deep Maintenance (monthly recommended):
npm run maintain:deepRuns: deep clean (including node_modules) → full maintenance → dependency check
npm run clean:all # Remove temp files, logs, dist, coverage
npm run clean:temp # Remove *.tmp, test-*.md, RESUME_HERE.md
npm run clean:logs # Remove *.log files
npm run clean:dist # Remove dist/ directory
npm run clean:coverage # Remove coverage/ directory
npm run clean:deep # Deep clean including node_modulesnpm run docs:update # Generate API docs + lint markdown
npm run docs:generate # Generate TypeDoc API documentation
npm run docs:lint # Lint all markdown files
npm run docs:lint:fix # Auto-fix markdown issuesnpm run git:check # Show git status and branches
npm run git:status # Short git status
npm run git:branches # List branches with tracking info
npm run git:prune # Clean up stale remote branches
npm run git:optimize # Optimize git repositorynpm run security:check # Run security audit (moderate+ severity)
npm run security:audit # Full npm audit
npm run deps:check # Check for available dependency updates
npm run deps:update # Update dependencies interactivelynpm run quality:check # typecheck + lint + format check + test
npm run quality:fix # lint fix + format + testnpm run cleanup:analyze # Dry-run: show what would be deleted
npm run cleanup:execute # Actually delete identified filesGit hooks run automatically when you commit or push:
- lint-staged: Lints and formats only staged files
- typecheck: Runs TypeScript type checking
- test: Runs Jest test suite
- security: Runs npm audit
If you need to skip hooks (not recommended):
LEFTHOOK=0 git commit -m "message"
LEFTHOOK=0 git pushlefthook.yml- Git hooks configuration.lintstagedrc.json- Pre-commit file processingtypedoc.json- API documentation generation.markdownlint.json- Markdown linting rulesscripts/cleanup-repo.js- Custom cleanup utility
- Make your changes
- Commit (pre-commit hooks run automatically)
- Before ending session:
npm run maintain - Push (pre-push hooks run automatically)
npm run maintain # Full maintenance
npm run git:prune # Clean stale branchesnpm run maintain:deep # Includes dependency updates
npm run deps:update # Review and update dependenciesHooks taking too long?
- Pre-push hook runs tests which can be slow
- Skip with
LEFTHOOK=0 git pushif needed - Consider disabling test hook in
lefthook.yml
Linting errors?
- Run
npm run quality:fixto auto-fix - Check specific errors with
npm run lint
Documentation not generating?
- Ensure
src/core/index.tsexists - Check TypeDoc configuration in
typedoc.json
Time Savings: ~85 minutes per week per developer
| Task | Before | After | Savings |
|---|---|---|---|
| Manual cleanup | 10 min | 1 min | 9 min |
| Doc updates | 30 min | 2 min | 28 min |
| Security checks | 20 min | 1 min | 19 min |
| Code formatting | 15 min | 0 min | 15 min |
| Weekly Total | 75 min | 4 min | 71 min |
This maintenance system is designed to be portable. To use in other repositories:
-
Copy these files:
package.json(scripts section)lefthook.yml.lintstagedrc.jsontypedoc.json(if using TypeScript).markdownlint.jsonscripts/cleanup-repo.js
-
Install dependencies:
npm install -D lefthook lint-staged npm-run-all rimraf \ typedoc typedoc-plugin-markdown markdownlint-cli npm-check-updates
-
Initialize:
npx lefthook install
-
Customize cleanup patterns in
scripts/cleanup-repo.js
For issues or questions:
- Check the generated docs:
docs/api/ - Run
npm run cleanup:analyzeto see what will be cleaned - Use
--helpwith any command for details