Beautiful CLI tool to analyze project composition and count lines of code with GitHub-inspired colors
Transform your code analysis experience with stunning visuals and powerful insights
Chinese README: README_CN.md
- GitHub-inspired colors for 93+ programming languages
- Rich terminal output with ASCII art and progress bars
- Responsive design that adapts to your terminal size
- Multiple output formats: Fancy, Simple, and JSON
- Lightning fast with async directory traversal
- Smart caching for instant repeated analyses
- Real-time progress tracking with beautiful spinners
- Streaming support for large files (10MB+)
- Gamified experience with milestones and achievements
- Analysis history with growth trends
- Change comparison between analyses
- Detailed insights including largest files and language distribution
- Configuration files for project-specific settings
- Quick analysis mode for rapid feedback
- Multi-platform support (Linux, macOS, Windows)
- Lightweight with minimal dependencies
# Install globally (recommended)
npm install -g codestat
# Or use npx
npx codestat --help# Analyze current directory
codestat analyze
# Quick analysis
codestat quick
# Analyze specific path
codestat analyze /path/to/project
# Analyze a single file
codestat file ./src/index.js
# Initialize config file
codestat config --init
# Get help
codestat --help$ codestat analyze╭ CODE ANALYSIS ENGINE ╮
╠══════════════════════════════════════════════════════════╣
[STA] SUMMARY STATISTICS
┌─────────────────────────────────────────────────────────────┐
│ Total Files : 42 │
│ Directories : 12 │
│ Total Lines : 8,247 │
│ Code Lines : 6,183 │
│ Comments : 1,247 │
│ Blank Lines : 817 │
└─────────────────────────────────────────────────────────────┘
[TYP] FILE TYPE ANALYSIS
┌─────────┬───────┬──────────┬──────┬──────────┬───────┐
│ Type │ Files │ Lines │ Code │ Comments │ Blank │
├─────────┼───────┼──────────┼──────┼──────────┼───────┤
│ JS │ 24 │ 5,234 │ 4123 │ 847 │ 264 │
│ TS │ 8 │ 1,847 │ 1523 │ 234 │ 90 │
│ JSON │ 6 │ 892 │ 892 │ 0 │ 0 │
│ MD │ 4 │ 274 │ 145 │ 0 │ 129 │
└─────────┴───────┴──────────┴──────┴──────────┴───────┘
$ codestat quick╭ QUICK ANALYSIS ╮
╠════════════════════════════════════════════════════╣
│ Files : 42 │
│ Total Lines : 8,247 │
│ Code Lines : 6,183 │
│ Avg Lines/File: 196 │
╚════════════════════════════════════════════════════╝
$ codestat stats╭ CODESTAT STATISTICS ╮
╠════════════════════════════════════════════════════╣
[STA] YOUR CODING JOURNEY
┌─────────────────────────────────────────────────────┐
│ Projects Analyzed: 12 │
│ Files Analyzed: 1,247 │
│ Lines of Code: 89,247 │
│ Analyses Completed: 156 │
└─────────────────────────────────────────────────────┘
[ACH] RECENT ACHIEVEMENTS
┌─────────────────────────────────────────────────────┐
│ 🏆 100K Lines Analyzed! │
│ ⭐ 50 Projects Analyzed │
│ ⭐ 1000 Files Analyzed │
└─────────────────────────────────────────────────────┘
Create a .codestatrc file in your project root:
{
"extensions": ["js", "ts", "jsx", "tsx", "py", "java"],
"ignore": ["node_modules", ".git", "dist", "build"],
"maxFileSize": "10MB",
"output": "fancy",
"quiet": false,
"showHidden": false,
"skipBinaryFiles": true
}# Custom extensions
codestat analyze -e "js,ts,py,java"
# Ignore patterns
codestat analyze -i "node_modules,.git,dist"
# JSON output
codestat analyze --json > results.json
# Quiet mode
codestat analyze --quiet
# Clear cache
codestat analyze --clear-cache
# Simple output
codestat analyze -o simple# Analyze directory
codestat analyze [path] [options]
# Quick analysis
codestat quick [path]
# Analyze single file
codestat file <file>
# Cache management
codestat cache --stats
codestat cache --clear
# Your statistics
codestat stats
# Project history
codestat history [path]
# Configuration
codestat config --init
codestat config --showCodeStat supports 93 programming languages and file types including:
- JavaScript/TypeScript (.js, .ts, .jsx, .tsx)
- Python (.py)
- Java (.java)
- C/C++ (.c, .cpp, .h)
- Go (.go)
- Rust (.rs)
- PHP (.php)
- Ruby (.rb)
- C# (.cs)
- Swift (.swift)
- Kotlin (.kt)
- Scala (.scala)
- HTML (.html, .htm)
- CSS (.css, .scss, .sass, .less)
- Vue (.vue)
- Svelte (.svelte)
- React (.jsx, .tsx)
- JSON (.json)
- YAML (.yaml, .yml)
- TOML (.toml)
- XML (.xml)
- SQL (.sql)
- Shell scripts, Dockerfiles, Markdown, LaTeX, Assembly, and more!
Beautiful ASCII art with colors and progress bars
Clean, minimal output perfect for scripts
Machine-readable format for integration:
{
"totalFiles": 42,
"totalLines": 8247,
"codeLines": 6183,
"commentLines": 1247,
"blankLines": 817,
"byFileType": {
"js": {
"files": 24,
"totalLines": 5234,
"codeLines": 4123,
"commentLines": 847,
"blankLines": 264
}
},
"largestFiles": [
{
"path": "src/analyzer.js",
"lines": 764,
"type": "js"
}
]
}- Lines Analyzed: Track your coding journey
- Files Analyzed: Monitor file processing
- Projects Analyzed: Count unique projects
- Cache Efficiency: Track performance optimization
- Real-time progress indicators
- Achievement notifications
- Personal statistics dashboard
- Historical growth trends
Use CodeStat as a Node.js module:
const { analyzeProject } = require('codestat');
// Basic analysis
const results = await analyzeProject('/path/to/project', ['js', 'ts'], ['node_modules']);
console.log(results);
// Advanced options
const detailedResults = await analyzeProject(
'/path/to/project',
['js', 'ts', 'py'],
['node_modules', '.git'],
{
maxFileSize: 1024 * 1024 * 10, // 10MB
verbose: true,
useCache: true,
progressCallback: (progress) => {
console.log(`Progress: ${progress.progress}%`);
}
}
);git clone https://github.com/Hybriant/codestat.git
cd codestat
npm install
npm run install-global# Run all tests
npm test
# Run specific test suites
npm run test:analyzer
npm run test:cli
npm run test:language# Development
npm run dev
# Lint (auto-fix)
npm run lint
# Lint check (CI-friendly)
npm run lint:check
# Security test
npm run test:security
# Build (no-op in current version)
npm run build- Automatic caching of analysis results
- Cache invalidation on file changes
- TTL-based expiration (24 hours)
- Size management (100 entries max)
- Streaming analysis for files > 1MB
- Memory-efficient processing
- Configurable size limits
- Binary file detection
- Path traversal protection
- Input sanitization
- Command injection prevention
- Safe file operations
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Web Interface - Beautiful web dashboard
- Git Integration - Blame, history, and commit analysis
- Real-time Monitoring - Watch files as they change
- Advanced Metrics - Complexity, maintainability, technical debt
- Plugin System - Custom analyzers and formatters
- Database Export - Save results to databases
- CI/CD Integration - GitHub Actions, GitLab CI
- Team Features - Collaborative analysis and sharing
Permission Denied
# Ensure read permissions
chmod -R +r /path/to/projectLarge Files
# Increase file size limit
codestat analyze --max-size 50MBMemory Issues
# Exclude large directories
codestat analyze -i "node_modules,.git,dist,build"# Command help
codestat --help
codestat analyze --help
# Cache info
codestat cache --stats
# Configuration help
codestat config --showMIT License - see LICENSE file for details.
- GitHub for the color scheme inspiration
- Node.js community for the amazing ecosystem
- All contributors who helped make CodeStat better
- Email: within.shell@gmail.com
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
Star us on GitHub if you find CodeStat useful!