A fully-featured starter boilerplate for building and publishing your own CLI tools using Node.js + npm.
Use the prebuilt cli inside an existing web application, or rebrand this boilerplate to create your own CLI with extra automation tools. Rebranding aims to boost automation for web app development and is perfect for DevOps workflows.
- Publish-ready scoped CLI
cliglobal command and modular generators- AI chat command for natural-language scaffolding (dev-only)
cli bumpversion bump tool--dry-runmode- Git commit + tag + push
- Optional
npm publish - GitHub release note generation
- GitHub Releases automation
- Semantic release support
- Modular code generators for components, pages, hooks, layouts, services, contexts, styles, and tests
- Framework detection with per-framework templates and a
--frameworkoverride - Extensible through a plugin system
- Optional TypeScript templates via
--ts - Jest test suite for generators
- Banner, help menu, and badges
- Ideal for open-source CLI products
- DevOps-friendly automation for releases and scaffolding
Choose the workflow that fits your needs.
npm install -g @greenarmor/cli-boilerplate
cd path/to/your-existing-project
cli generate:component ButtonThe generators detect your framework and drop files into your project automatically.
- Set Git identity (optional but recommended):
git config --global user.name "your_github_username"
git config --global user.email "your_email@example.com"- Scaffold a new CLI, ready to receive more automation tools:
npx @greenarmor/cli-boilerplate my-cli- (Optional) Include extras during creation:
--with-emoji– show emoji-enhanced output--full-stack– add ESLint, Prettier, Husky, Lint-Staged, Jest, ZX, Inquirer, Update Notifier, and more CLI polish libraries
npx @greenarmor/cli-boilerplate my-cli --with-emoji --full-stack- Link and try your branded CLI:
cd my-cli
npm install
npm link
my-cli --helpChat with the CLI using natural language to run allowed generator commands.
npm run chat
# or
cli chatRequires OPENAI_API_KEY in your environment. Put the key in a .env or export it globally:
- macOS/Linux:
echo 'export OPENAI_API_KEY="sk-..."' >> ~/.bashrc && source ~/.bashrc - Windows:
setx OPENAI_API_KEY "sk-..."
NODE_ENV=production disables chat mode.
Within chat mode you can type natural phrases and the CLI will map them to commands:
AI> generate a component called Button
AI> scan the project with the npm scanner
AI> initialize the scanner config
AI> list patches
AI> apply patch readme-fix.patch
AI> bump the version
AI> generate the changelog
AI> install shell completion
AI> start the mcp server
AI> index docs for rag
AI> query rag for authentication
Start the MCP server directly (development only):
NODE_ENV=development cli mcp:servecli generate:component Button
cli generate:hook useAuth
cli generate:context Auth
cli generate:authlogin authOther supported generators:
page– scaffold a new page componentlayout– create a layout templateservice– generate a service modulestyle– add a stylesheet filetest– create a test filecontext– create a context moduleauthlogin– scaffold a JWT auth server, client helpers, and auserstable schema
Run cli --help to see available generator commands.
Use the --ts flag to scaffold TypeScript files instead of JavaScript:
cli generate:component Button --tscli generate:authlogin creates a JWT-ready authentication system:
auth/
client.js # login helpers and token storage
server.js # Express server with JWT + bcrypt
schema.sql # PostgreSQL users table
Install runtime dependencies before running the server:
npm install express jsonwebtoken bcrypt pgConfigure your database connection and set JWT_SECRET, then start the server:
node auth/server.jsLog in with a POST /login containing email and password to receive a JWT
token. The token can be used via the Authorization header or the generated
client helper's fetchWithAuth. Apply the database schema with:
psql -f auth/schema.sqlRun cli scan:init to generate a .cli-scannersrc file with sample scanner
definitions.
The cli scan command runs pluggable security tools. Register scanners under
cli.scanners in package.json or provide defaults in .cli-scannersrc.
Install required scanners first (ZAP is not bundled):
- npm – uses
npm auditto inspect dependencies. Requires Node.js and npm (v7+) in yourPATH. - OWASP ZAP – dynamic application testing via
zap-baseline.pyorzap.sh. Download ZAP or install with a package manager (brew install zaproxy) or Docker.
Run a registered scanner against a project directory or URL:
# run npm audit on the current project
cli scan --scanner npm --target .
# run OWASP ZAP against a URL, save an HTML report, and only show high issues
cli scan --scanner zap --target https://example.com \
--report zap-report.html --severity highUse --report <file> to write findings to a JSON or HTML report. The
--severity <level> flag filters results below the threshold (info, low,
moderate, high, critical).
Configure defaults or pass arguments per scanner in your project:
Include cli scan in CI pipelines to fail builds on severe vulnerabilities:
cli scan --scanner npm --severity highAlways scan only systems you own or have explicit permission to test.
cli bump [--github-release] [-u] [-r <count>]Supports:
- Select bump type (patch, minor, major)
- Git log + changelog preview
- Optional GitHub push + npm publish
- GitHub release notes preview (
-ufor Unreleased heading) - Optional GitHub release (
--github-release, requiresGITHUB_TOKEN) --dry-runsupport
To create a release on GitHub as part of the bump workflow:
export GITHUB_TOKEN=ghp_YourTokenHere
cli bump --github-releaseThis flag runs scripts/release-to-github.js after pushing commits and tags. You can also run the script directly if needed:
node scripts/release-to-github.jsThis project includes semantic-release support out of the box:
- Automated changelog
- GitHub Releases
- npm publishing
Requirements:
NPM_TOKENin GitHub Actions secretsGITHUB_TOKENin GitHub Actions secrets
- This CLI is a development tool. Install as a devDependency and do not import it in app runtime.
- Add secrets locally in
.env(never commit). Copy from.env.example. - AI chat / RAG / MCP commands are disabled when
NODE_ENV=production. - CI uses GitHub Secrets (Settings → Secrets and variables → Actions).
-
.envignored by git -
OPENAI_API_KEYonly in local.envor CI secrets -
NODE_ENV=productionfor production workflows - Dev-only commands (
chat,mcp:*,rag:*) blocked in prod - CLI installed as devDependency in app repos
-
.npmignore/export-ignoreexclude docs/examples/tests from npm - CI avoids printing secrets; no echoing keys
- Allowed commands enforced for AI chat
- Writes constrained to
./srcfor generators
MIT — Customize and distribute freely under your own CLI brand.
{ "cli": { "scanners": { "npm": "./scripts/scanners/npm.js", "zap": "./scripts/scanners/zap.js" } }, "scan": { "severity": "moderate", "zap": { "args": ["-r", "zap-report.html"] } } }