Auto-generate beautiful README files from your project structure.
Writing a good README takes time. This tool analyzes your project and generates a solid starting point automatically.
- Detects project type (Node.js, Python, Go, Rust)
- Generates file structure tree
- Extracts metadata from config files
- Detects license automatically
- Creates installation and usage instructions
- Identifies test setup
- Clean, professional output
npm install -g readme-genOr use without installing:
npx readme-genGenerate README for current directory:
readme-genGenerate for a specific project:
readme-gen ./path/to/projectChoose from 4 different template styles:
Minimal - Just the essentials:
readme-gen --template minimalStandard (default) - Comprehensive but not overwhelming:
readme-gen --template standardDetailed - Includes examples, API docs, and troubleshooting:
readme-gen --template detailedComprehensive - Everything including roadmap, changelog, and more:
readme-gen --template comprehensivePreview without writing to file:
readme-gen --no-writeSpecify output file:
readme-gen --output DOCS.mdAdd badges to your README automatically:
# Add npm version and downloads badges
readme-gen --npm
# Add all common badges (npm, CI, coverage, quality, GitHub stars)
readme-gen --all-badges
# Add specific CI badge
readme-gen --ci github-actions # or circleci, travis
# Add coverage badge
readme-gen --coverage codecov # or coveralls
# Add code quality badge
readme-gen --quality codeclimate # or codefactor
# Add GitHub stars badge
readme-gen --github
# Combine multiple options
readme-gen --npm --ci github-actions --coverage codecovSupported badges:
- 📦 npm version and downloads
- ✅ CI/CD status (GitHub Actions, CircleCI, Travis CI)
- 📊 Code coverage (Codecov, Coveralls)
- 💎 Code quality (Code Climate, CodeFactor)
- ⭐ GitHub stars
- 📄 License
Example output with --all-badges:
[](https://www.npmjs.com/package/package)
[](https://www.npmjs.com/package/package)
[](https://opensource.org/licenses/MIT)
[](https://github.com/owner/repo/actions)
[](https://codecov.io/gh/owner/repo)
[](https://codeclimate.com/github/owner/repo/maintainability)
[](https://github.com/owner/repo)$ cd my-new-project
$ readme-gen
Analyzing project...
Detected project type: node
Extracting package.json metadata...
Generating file tree...
✓ README.md created successfully!Generated sections:
- Project title and description from package.json
- Installation instructions with npm/yarn
- Usage examples from scripts
- Project file structure
- Contributing guidelines
$ readme-gen --no-write
# my-awesome-cli
Command-line tool for awesome things.
## Installation
npm install -g my-awesome-cli
## Usage
...
(full README printed to stdout)Use case: Review generated content before committing, or pipe to another tool for processing.
$ cd python-api
$ readme-gen
Analyzing project...
Detected project type: python
Found requirements.txt with 12 dependencies
Found pytest configuration
✓ README.md created successfully!Generates Python-specific content:
pip installinstructions- Virtual environment setup
requirements.txtreference- pytest usage examples
$ readme-gen ./packages/frontend
Analyzing project...
Detected project type: node
Framework: React (detected in dependencies)
Build tool: Vite
✓ README.md created successfully!
$ readme-gen ./services/api
Analyzing project...
Detected project type: go
Found go.mod with module: github.com/myorg/api
✓ README.md created successfully!Use case: Generate consistent READMEs for each package in a monorepo.
$ readme-gen --output docs/PROJECT_OVERVIEW.md
Analyzing project...
Detected project type: rust
Found Cargo.toml
✓ docs/PROJECT_OVERVIEW.md created successfully!Use case: Generate documentation files for tools that expect specific filenames or locations.
Before:
my-project/
├── src/
├── package.json
└── (no README)
After:
readme-gen
# Analyzing project...
# Detected project type: node
# README generated: README.mdNow you have a complete README with:
- Project name and description
- Badges
- Installation instructions
- Usage examples
- Project structure
- Contributing guidelines
- Node.js - Detects package.json, extracts scripts and dependencies
- Python - Detects setup.py, pyproject.toml, requirements.txt
- Go - Detects go.mod
- Rust - Detects Cargo.toml
- Unknown - Still generates basic structure
Usage: readme-gen [options] [path]
Arguments:
path Path to the project directory (default: ".")
Options:
-V, --version output the version number
-o, --output <file> Output file path (default: "README.md")
--no-write Print to stdout instead of writing to file
-h, --help display help for command
readme-gen/
├── src/
│ ├── analyzer.ts # Project analysis logic
│ ├── cli.ts # CLI entry point
│ ├── detector.ts # Project type detection
│ ├── fileTree.ts # File tree generator
│ ├── template.ts # README template generator
│ ├── types.ts # TypeScript types
│ └── *.test.ts # Test files
├── dist/ # Compiled output
├── package.json
├── tsconfig.json
└── README.md
git clone https://github.com/muin-company/readme-gen.git
cd readme-gen
npm installnpm run buildnpm testWatch mode:
npm run test:watchCoverage:
npm run test:coveragenpm run build
node dist/cli.jsOr link globally:
npm link
readme-genBatch generate READMEs for all projects in a workspace:
# Generate README for each subdirectory
for dir in ./projects/*/; do
readme-gen "$dir"
echo "✓ Generated README for $dir"
doneAuto-update README on every push:
# .github/workflows/readme.yml
name: Update README
on:
push:
branches: [main]
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Generate README
run: npx readme-gen
- name: Commit if changed
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add README.md
git diff --staged --quiet || git commit -m "chore: auto-update README"
git pushReview generated content before overwriting existing README:
# Preview in terminal
readme-gen --no-write | less
# Compare with existing
readme-gen --no-write > README.new.md
diff README.md README.new.md
# Merge manually if satisfied
mv README.new.md README.mdGenerate different formats for various needs:
# Main README
readme-gen
# Docs site version (without badges)
readme-gen --output docs/README.md
# Minimal version for npm
readme-gen --output NPM_README.mdGenerate READMEs for all packages in a monorepo:
# From monorepo root
for pkg in packages/*/; do
echo "Processing $pkg"
readme-gen "$pkg" --output "$pkg/README.md"
done
# Or with more control
find packages -maxdepth 1 -type d -not -path packages | while read dir; do
if [ -f "$dir/package.json" ]; then
readme-gen "$dir"
fi
doneStart a new project with a professional README from day one:
# Create new project
mkdir my-awesome-tool && cd my-awesome-tool
npm init -y
# Write some code...
mkdir src
echo "export const hello = () => 'world'" > src/index.ts
# Generate README immediately
npx readme-gen
# Now you have:
# - package.json
# - src/index.ts
# - README.md (professional, auto-generated)Ensure README stays updated using git hooks:
# .git/hooks/pre-commit
#!/bin/bash
readme-gen --no-write > /dev/null 2>&1
if [ $? -eq 0 ]; then
readme-gen
git add README.md
fiOr with husky:
{
"husky": {
"hooks": {
"pre-commit": "readme-gen && git add README.md"
}
}
}Problem: Running readme-gen in directory without package.json or equivalent.
Solution:
# Verify project type is detectable
ls -la
# For Node.js projects:
npm init -y # Creates package.json
# For Python projects:
touch setup.py
# or
touch pyproject.toml
# For Go projects:
go mod init github.com/user/project
# For Rust projects:
cargo init
# Then run readme-gen:
readme-genProblem: Output lacks detail or specific information.
Solution:
# Use detailed template:
readme-gen --template detailed
# Or comprehensive:
readme-gen --template comprehensive
# Add more metadata to package.json:
{
"name": "my-app",
"description": "A detailed description helps generate better README",
"keywords": ["cli", "tool", "productivity"],
"repository": "https://github.com/user/my-app",
"author": "Your Name <email@example.com>",
"scripts": {
"start": "node index.js",
"test": "jest",
"build": "webpack"
}
}
# Then regenerate:
readme-gen --template detailedProblem: readme-gen identifies wrong project type or falls back to "unknown".
Debug:
# Check what files exist:
ls -la
# Node.js requires:
# - package.json
# Python requires:
# - setup.py OR pyproject.toml OR requirements.txt
# Go requires:
# - go.mod
# Rust requires:
# - Cargo.toml
# If none exist, create the appropriate config fileSolution:
# For Node.js:
npm init -y
# For Python:
touch setup.py
# or better:
cat > pyproject.toml <<EOF
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "myproject"
version = "0.1.0"
EOF
# For Go:
go mod init github.com/user/project
# Then run:
readme-genProblem: Accidentally overwrote hand-written README.
Prevention:
# Always preview first:
readme-gen --no-write
# Or save to different file:
readme-gen --output README.new.md
# Compare:
diff README.md README.new.md
# Merge manually if satisfiedRecovery:
# If using git:
git checkout HEAD -- README.md
git restore README.md
# Or check git history:
git log --all --full-history -- README.md
git show <commit>:README.md > README.recovered.mdProblem: File tree includes node_modules, dist, build folders.
Workaround:
# Current workaround: manually edit .gitignore-style filtering
# Feature request: Add --exclude option
# (Not yet implemented)
# Manual fix - edit generated README and remove unwanted paths:
nano README.md
# Delete lines with node_modules/, dist/, etc.
# Or use sed:
sed -i '/node_modules/d' README.md
sed -i '/dist\//d' README.mdFuture feature (vote for it!):
# Planned:
readme-gen --exclude node_modules,dist,buildProblem: --template flag not recognized or doesn't change output.
Solution:
# Check version:
readme-gen --version
# Update to latest:
npm update -g readme-gen
# Valid templates:
readme-gen --template minimal
readme-gen --template standard # default
readme-gen --template detailed
readme-gen --template comprehensive
# If still not working, check spelling:
readme-gen --template=detailed # Try with = instead of spaceProblem: npm badges show wrong package name or 404.
Cause: package.json name field doesn't match npm package name.
Solution:
# Check package.json:
cat package.json | jq '.name'
# Should match published npm package:
npm view <package-name>
# If they don't match, update package.json:
{
"name": "@your-scope/correct-name",
...
}
# Or if package isn't published yet, badges will 404 (expected)
# Remove --npm flag:
readme-gen --template detailed # Without --npmProblem: GitHub Actions commits README changes, causing merge conflicts.
Solution:
# Better approach - only update on main branch:
name: Update README
on:
push:
branches: [main] # Only main, not PRs
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check if README needs update
id: check
run: |
readme-gen --no-write > README.new
if diff -q README.md README.new > /dev/null; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Update README
if: steps.check.outputs.changed == 'true'
run: |
mv README.new README.md
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add README.md
git commit -m "docs: auto-update README [skip ci]"
git pushProblem: Can't write to README.md file.
Solution:
# Check file permissions:
ls -la README.md
# If read-only:
chmod 644 README.md
# If owned by another user:
sudo chown $(whoami) README.md
# Or write to different location:
readme-gen --output /tmp/README.mdProblem: --json flag not producing valid JSON.
Current limitation:
# JSON output not yet implemented
readme-gen --json
# Error: Unknown option '--json'
# Workaround - parse markdown output:
readme-gen --no-write | pandoc -f markdown -t json
# Or feature request for future versionProblem: Running from monorepo root analyzes root package.json instead of specific package.
Solution:
# Always specify path:
readme-gen packages/frontend
readme-gen packages/backend
readme-gen services/api
# Or cd into package:
cd packages/frontend
readme-gen
# Batch generate for all packages:
for pkg in packages/*/; do
echo "Generating README for $pkg"
readme-gen "$pkg"
doneProblem: README references old dependency versions or removed scripts.
Solution:
# Clean and reinstall dependencies:
rm -rf node_modules package-lock.json
npm install
# Update package.json scripts:
npm pkg set scripts.start="node index.js"
npm pkg set scripts.test="vitest"
# Remove obsolete fields:
npm pkg delete devDependencies.old-package
# Regenerate:
readme-gen --template detailedContributions welcome! Feel free to:
- Report bugs
- Suggest features
- Submit pull requests
MIT License - see LICENSE file for details.
Built by MUIN