@taterraster-js/projectdoctor
v0.1.1
Published
๐ฉบ A production-quality CLI tool that analyzes your codebase and reports its health
Maintainers
Readme
๐ฉบ ProjectDoctor
A production-quality CLI diagnostic tool that analyzes your JavaScript / Node.js codebase and reports its health โ with zero external dependencies.
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ ๐ฉบ ProjectDoctor Report my-app โ
โ โ
โ Project Health: โ Needs Attention โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
๐ Project Stats
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Files 182
Source files 143
Lines of code 21,943
Largest file src/api.js (612 lines)
Dependencies 37
Dev dependencies 14
๐ฑ Environment
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ .env file found
โ .env.example file found
โ Missing env variables: 1
- DATABASE_URL
โ Potentially unused env variables: 3
- OLD_API_KEY
๐ง Code Mood
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
TODOs 21
FIXMEs 4
console.log calls 11
HACK markers 2
Mood ๐ฌ stressed
๐จ Possible Issues
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
src/user.js
- unused variable: tempUser (line 42)
src/api.js
- empty catch block (line 88)
- duplicate import: 'lodash' (line 112)
๐ฆ Dependencies
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Production dependencies 37
Dev dependencies 14
โ Potentially outdated: 3
- express (declared ^4.0.0, installed 3.5.0)
โ Possibly unused packages: lodashโจ Features
| Feature | Description |
|---|---|
| Project Stats | Total files, lines of code, largest file, dependency counts |
| Code Mood | Counts TODOs, FIXMEs, console.logs and assigns a mood |
| Environment Health | Detects missing / unused .env variables vs .env.example |
| Issue Finder | Finds empty catch blocks, duplicate imports, unused variables |
| Dependency Health | Detects outdated and potentially unused packages |
๐ Quick Start
Run instantly with npx โ no installation required:
npx projectdoctorOr install globally:
npm install -g projectdoctor
projectdoctor๐ฆ Requirements
- Node.js โฅ 18.0.0
- Zero runtime dependencies โ works anywhere Node runs,
npxworks immediately
๐งฐ CLI Commands
# Full diagnosis (default)
projectdoctor
# Individual sections
projectdoctor stats # ๐ Project file & line statistics
projectdoctor env # ๐ฑ Environment variable health
projectdoctor mood # ๐ง Code mood analysis
projectdoctor errors # ๐จ Possible code issues
projectdoctor deps # ๐ฆ Dependency health
# Options
projectdoctor -d ./myapp # Analyze a specific directory
projectdoctor --version # Show version
projectdoctor --help # Show help๐ What Gets Scanned
File extensions included: .js .jsx .mjs .ts .tsx .cjs
Directories ignored: node_modules, .git, dist, build, coverage, .next, .cache, .turbo, .vercel
๐ฉบ Health Levels
| Icon | Level | Condition |
|------|-------|-----------|
| โ Healthy | All clear | Score < 2 |
| โ Needs Attention | Warning | Score 2โ4 |
| โ Critical | Urgent | Score โฅ 5 |
Score is computed from: stressed mood (+2), missing env vars (+1 each), many file issues (+1โ2), many outdated deps (+1).
๐ง Code Mood Scale
| Mood | Marker Count | Meaning | |------|-------------|---------| | ๐ healthy | 0โ5 | Clean codebase | | ๐ moderate | 6โ20 | Some cleanup needed | | ๐ฌ stressed | 21+ | Technical debt accumulating |
Markers counted: TODO, FIXME, HACK, console.log/warn/error/debug
๐ฑ Environment Analysis
Compares .env against .env.example:
- Missing vars โ keys in
.env.examplenot present in.env - Unused vars โ keys in
.envnever referenced asprocess.env.KEYin source
๐จ Code Issues Detected
| Issue | How |
|-------|-----|
| Empty catch blocks | Heuristic scan for catch {} with no body statements |
| console.log/warn/error | Regex across all source files |
| Duplicate imports | Tracks seen import/require module paths per file |
| Unused variables | const x = โฆ declared once and never referenced again |
These are fast heuristic checks, not a full AST parse. Use ESLint for exhaustive analysis.
๐ฆ Dependency Analysis
- Outdated โ compares declared semver range against the version installed in
node_modules - Unused โ packages never
imported orrequired in source (with a built-in allowlist for implicit deps likedotenv,cross-env,typescript)
๐ ๏ธ Debug Mode
DEBUG=1 projectdoctorPrints full stack traces on unexpected errors.
๐ Project Structure
projectdoctor/
โโโ src/
โ โโโ cli.js # CLI entry point & arg parsing
โ โโโ index.js # Report orchestration & section printers
โ โโโ analyzers/
โ โ โโโ stats.js # File/line/dependency counts
โ โ โโโ mood.js # TODO/FIXME/console.log scanner
โ โ โโโ env.js # .env vs .env.example comparison
โ โ โโโ errors.js # Common code issue detector
โ โ โโโ deps.js # Dependency health checker
โ โโโ utils/
โ โโโ colors.js # Zero-dep ANSI color helpers
โ โโโ display.js # Terminal output (sections, rows, boxes)
โ โโโ fs.js # File system walking utilities
โโโ package.json
โโโ README.md๐ค Contributing
- Fork the repo
- Create a feature branch:
git checkout -b feat/my-feature - Commit:
git commit -m 'feat: add X' - Push and open a Pull Request
๐ License
MIT ยฉ ProjectDoctor
