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 🙏

© 2025 – Pkg Stats / Ryan Hefner

offbs-gen

v1.0.0

Published

A Node.js CLI to generate code snippets using the Google Gemini API.

Readme

ai-gen: Code Generation CLI

ai-gen is a command-line tool that uses Google's Gemini AI to generate code snippets directly in your terminal.

Features

  • Generate code from a natural-language prompt.
  • Interactive mode if no prompt is given.
  • Specify a programming language for more accurate results.
  • Request a natural-language explanation of the generated code.
  • Securely uses your Gemini API key from a .env file.

Setup and Installation

Follow these steps to set up and run the ai-gen tool.

1. Prerequisites

2. Install Dependencies

Clone or download the project, navigate into the project directory, and install the required npm packages:

npm install

3. Set Your API Key

Create a file named .env in the root of the project directory. You can do this by copying the example file:

cp .env.example .env

Now, open the .env file and replace your_api_key_here with your actual Gemini API key.

# .env
GEMINI_API_KEY=AIzaSy...your...key...

4. Make the CLI Executable

To run the ai-gen command directly, you need to make the index.js file executable:

chmod +x index.js

5. Install Globally (Optional but Recommended)

To use the ai-gen command from anywhere on your system, link the package globally:

npm install -g .

Usage

You can now run the tool from any directory.

Basic Usage

Provide your request as a string argument.

ai-gen "Create a React button component with a click handler"

Language Specificity

Use the --lang flag to hint the programming language.

ai-gen "A function that reads a file and returns its content" --lang python

Request an Explanation

Use the --explain flag to get a brief explanation of the code below the snippet.

ai-gen "Express.js server with a single GET endpoint" --explain

Interactive Mode

Run the command without any arguments to enter interactive mode.

ai-gen

The tool will then prompt you to enter your code generation request.