npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

create-cli4ai

v1.0.0

Published

Create fully typed and validated cli4ai tools

Readme

create-cli4ai

Create fully typed and validated cli4ai tools with a single command.

Usage

# Interactive mode
npx create-cli4ai

# With package name
npx create-cli4ai my-awesome-tool

# Quick mode with defaults
npx create-cli4ai my-tool -y

What it generates

A complete cli4ai package with:

  • run.ts - CLI entry point with Commander.js
  • lib.ts - Core logic separated from CLI handling
  • schema.ts - Zod schemas for input validation (optional)
  • lib.test.ts - Vitest test suite
  • cli4ai.json - Package manifest
  • package.json - npm package config
  • tsconfig.json - TypeScript config
  • README.md - Documentation

Interactive prompts

The CLI will ask you:

  1. Package name - lowercase, hyphens allowed (e.g., my-tool)
  2. Description - what your tool does
  3. Author - optional
  4. Use Zod? - for input validation
  5. Commands - define each command with:
    • Name
    • Description
    • Arguments (name, required, type)
  6. Environment variables - if your tool needs API keys, etc.

Example

$ npx create-cli4ai

create-cli4ai v1.0.0

? Package name: github-stats
? Description: Get GitHub repository statistics
? Author: yourname
? Use Zod for input validation? Yes

Commands
Define the commands for your tool. Press Enter with empty name to finish.

? Command 1 name: repos
? Description: List repositories for a user
  Arguments (press Enter with empty name to finish):
    ? Arg 1 name: username
    ? Required? Yes
    ? Description: GitHub username
    ? Type: string
    ? Arg 2 name:

? Command 2 name: stats
? Description: Get stats for a repository
  Arguments (press Enter with empty name to finish):
    ? Arg 1 name: repo
    ? Required? Yes
    ? Description: Repository name (owner/repo)
    ? Type: string
    ? Arg 2 name:

? Command 3 name:

Environment Variables
Define required env vars. Press Enter with empty name to finish.

? Env var 1 name: GITHUB_TOKEN
? Required? No
? Description: GitHub personal access token
? Env var 2 name:

Done! Created github-stats

Next steps:
  cd github-stats
  npm test
  npx tsx run.ts --help

Generated structure

github-stats/
├── cli4ai.json      # cli4ai manifest
├── package.json     # npm package
├── run.ts           # CLI entry point
├── lib.ts           # Core logic
├── lib.test.ts      # Tests
├── schema.ts        # Zod validation schemas
├── tsconfig.json    # TypeScript config
├── vitest.config.ts # Test config
├── README.md        # Documentation
└── .gitignore

Options

| Option | Description | |--------|-------------| | -y, --yes | Skip prompts, use defaults | | -d, --dir <dir> | Output directory (defaults to package name) | | --no-git | Skip git initialization | | --no-install | Skip npm install |

Why separate lib.ts?

Keeping business logic in lib.ts separate from CLI handling in run.ts:

  1. Testable - Easy to unit test without CLI overhead
  2. Reusable - Import functions in other projects
  3. Clean - Clear separation of concerns
  4. MCP-ready - Logic works the same via CLI or MCP

Zod validation

When you enable Zod, the generated code includes:

  • Input validation for command arguments
  • Environment variable validation
  • Type inference from schemas
  • Helpful error messages
// Generated schema.ts
export const envSchema = z.object({
  GITHUB_TOKEN: z.string().optional(),
});

// Generated lib.ts
export const reposInputSchema = z.object({
  username: z.string(),
});

License

MIT