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

@promptenhance/cli

v0.1.5

Published

CLI for PromptEnhance - enhance developer prompts with codebase context

Readme

PromptEnhance CLI

AI Prompt Context Optimizer - Enhance your prompts with relevant codebase context

PromptEnhance CLI enhances developer prompts with relevant codebase context. It indexes your codebase, creates semantic embeddings, and intelligently retrieves relevant code snippets to enrich your prompts before sending them to LLMs.

Features

  • Semantic Code Search - Uses embeddings to find relevant code based on intent
  • Intelligent Context Addition - Automatically includes relevant files and snippets
  • Multiple Modes - One-shot enhancement, interactive mode.
  • Configurable - Support for OpenAI embeddings or local mock embeddings
  • ChromaDB Integration - Use local or cloud-hosted vector database

Installation

Global Installation (Recommended)

npm install -g @promptenhance/cli
# or
pnpm add -g @promptenhance/cli
# or
yarn global add @promptenhance/cli

npx (No Installation Required)

npx @promptenhance/cli enhance "fix the authentication bug"

Quick Start

1. Configure Your API Keys (Optional but Recommended)

PromptEnhance can work with mock embeddings, but for best results, configure your OpenAI API key:

# Interactive setup (recommended)
promptenhance config set

# Or set individual values
promptenhance config set openaiApiKey sk-your-key-here

Configuration is stored in ~/.promptenhance/config.json

2. Index Your Project

Navigate to your project directory and initialize:

cd /path/to/your/project
promptenhance init

This will scan your codebase, create embeddings, and store them in a vector database.

3. Enhance Your Prompts

promptenhance enhance "add user authentication"

The CLI will:

  1. Analyze your prompt intent
  2. Search for relevant code in your project
  3. Add context to your prompt
  4. Display the enhanced prompt

Usage

Commands

config - Manage Configuration

Configure your API keys and services:

# Interactive setup
promptenhance config set

# View current configuration
promptenhance config list

# Set specific key
promptenhance config set openaiApiKey sk-your-key

# Get specific key
promptenhance config get openaiApiKey

# Remove a key
promptenhance config unset openaiApiKey

# Show config file path
promptenhance config path

init - Initialize Project

Index your codebase:

promptenhance init [options]

Options:
  -p, --path <path>              Project path (default: current directory)
  --openai-key <key>             OpenAI API key (overrides config)
  --chroma-url <url>             ChromaDB server URL (overrides config)
  --chroma-token <token>         ChromaDB auth token
  --chroma-tenant <tenant>       ChromaDB tenant
  --chroma-db <database>         ChromaDB database

enhance - Enhance a Prompt

Enhance a single prompt with codebase context:

promptenhance enhance "<your-prompt>" [options]

Options:
  -p, --path <path>              Project path (default: current directory)
  -t, --tokens <number>          Max context tokens (default: 4000)
  --no-git                       Exclude git context
  -o, --output <file>            Save enhanced prompt to file
  --openai-key <key>             OpenAI API key (overrides config)
  --chroma-url <url>             ChromaDB server URL (overrides config)

Examples:
  promptenhance enhance "fix the authentication bug"
  promptenhance enhance "add error handling" -t 8000
  promptenhance enhance "refactor user service" -o prompt.txt

interactive - Interactive Mode

Start an interactive session for multiple prompts:

promptenhance interactive [options]
# or
promptenhance i [options]

Options:
  -p, --path <path>              Project path (default: current directory)
  --openai-key <key>             OpenAI API key (overrides config)

Type your prompts, get enhanced versions, and choose to copy, save, or continue.

info - Show Project Info

Display information about the indexed project:

promptenhance info [options]

Options:
  -p, --path <path>              Project path (default: current directory)

reindex - Re-index Project

Re-index your project after making changes:

promptenhance reindex [options]

Options:
  -p, --path <path>              Project path (default: current directory)

Configuration

PromptEnhance supports three ways to configure API keys and services, with the following priority:

  1. CLI Flags (highest priority)
  2. Environment Variables
  3. Config File (~/.promptenhance/config.json)

Configuration Options

| Config Key | Environment Variable | CLI Flag | Description | | ----------------- | -------------------------------------- | ----------------- | ----------------------------------------------------- | | openaiApiKey | OPENAI_API_KEY | --openai-key | OpenAI API key for embeddings (optional) | | chromaServerUrl | CHROMA_SERVER_URL | --chroma-url | ChromaDB server URL (optional, uses local if not set) | | chromaAuthToken | CHROMA_API_KEY / CHROMA_AUTH_TOKEN | --chroma-token | ChromaDB API key (prefers CHROMA_API_KEY) | | chromaTenant | CHROMA_TENANT | --chroma-tenant | ChromaDB tenant name (for Cloud) | | chromaDatabase | CHROMA_DATABASE | --chroma-db | ChromaDB database name (for Cloud) |

Configuration Methods

Method 1: Config File (Recommended)

# Interactive setup
promptenhance config set

# Manual file creation
echo '{
  "openaiApiKey": "sk-your-key-here",
  "chromaServerUrl": "https://your-chroma-instance.com"
}' > ~/.promptenhance/config.json

Method 2: Environment Variables

export OPENAI_API_KEY=sk-your-key-here
export CHROMA_SERVER_URL=https://your-chroma-instance.com

promptenhance init

Method 3: CLI Flags

promptenhance init --openai-key sk-your-key-here --chroma-url https://your-chroma-instance.com

Using Without OpenAI API Key

PromptEnhance can work with mock embeddings if you don't have an OpenAI API key:

# Just run without configuring API keys
promptenhance init
promptenhance enhance "your prompt"

Mock embeddings use basic text similarity instead of semantic embeddings. For production use, OpenAI embeddings are recommended.

ChromaDB Options

Option 1: Local ChromaDB (Default)

If you don't configure ChromaDB settings, PromptEnhance uses a local ChromaDB instance. No additional setup required.

Option 2: ChromaDB Cloud (Recommended)

Configure ChromaDB Cloud for persistent, shared embeddings:

promptenhance config set
# Enter your ChromaDB Cloud credentials when prompted

Or set via environment variables:

# For ChromaDB Cloud (CHROMA_SERVER_URL not needed, defaults to api.trychroma.com)
export CHROMA_API_KEY=ck-your-api-key-here
export CHROMA_TENANT=your-tenant-id
export CHROMA_DATABASE=your-database-name

Examples

Example 1: Fix a Bug

promptenhance enhance "fix the authentication bug in login"

Output includes:

  • Relevant authentication code
  • Login-related files
  • Recent git changes
  • Error handling patterns

Example 2: Add a New Feature

promptenhance enhance "add password reset functionality" -t 8000

Example 3: Refactor Code

promptenhance enhance "refactor the user service to use async/await"

Example 4: Interactive Mode

promptenhance interactive

Prompt: fix the database connection error
[Enhanced prompt displayed]

What next?
> Enter another prompt
  Copy to clipboard
  Save to file
  Exit

Example 5: CI/CD Integration

# Use in scripts with CLI flags
promptenhance enhance "analyze test failures" \
  --openai-key $OPENAI_API_KEY \
  --output enhanced-prompt.txt

Troubleshooting

"No configuration set"

Run promptenhance config set to configure your API keys, or use CLI flags.

"Failed to initialize"

  • Check your OpenAI API key is valid
  • Ensure you're in a valid project directory
  • Check network connectivity for ChromaDB Cloud

"No relevant code found"

  • Make sure you ran promptenhance init first
  • Try re-indexing: promptenhance reindex
  • Use more specific prompts

Mock Embeddings Warning

If you see "Using mock embeddings", you haven't configured an OpenAI API key. Mock embeddings work but are less accurate than semantic embeddings.

Security Best Practices

  1. Never commit API keys - Use config file or environment variables
  2. Use environment variables in CI/CD - Don't hardcode keys in scripts
  3. Rotate keys regularly - Update your OpenAI API key periodically
  4. Secure config file - The ~/.promptenhance/config.json file contains sensitive data

License

MIT