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

@elilands/promptune

v0.1.0

Published

An intelligent prompt generation and optimization engine aware of your codebase

Readme

🎯 Promptune — Intelligent Prompt Engine for Code

An intelligent prompt generation and optimization engine that understands your codebase and creates contextually-aware prompts for AI models.

Overview

Promptune solves a critical problem in AI-assisted development: generic prompts that don't understand your project. Instead of writing long, manual prompts, Promptune:

  • 📖 Reads your codebase and builds a semantic understanding
  • 🧠 Detects patterns in your code (hooks, components, services, etc.)
  • 🎨 Understands your style (naming conventions, architecture, dependencies)
  • Generates optimized prompts tailored to your project with minimal noise

Features

🔍 Smart Indexing

  • Semantic code indexing — Creates a RAG-like index optimized for code
  • Pattern detection — Automatically identifies your code patterns (React hooks, services, middleware, etc.)
  • Dependency awareness — Knows what libraries you use and avoids suggesting what doesn't exist
  • Caching — Dramatically speeds up subsequent runs

🧩 Context Pruning

  • Intelligent file selection — Includes only the most relevant code snippets
  • Token optimization — Reduces context bloat, lowers LLM costs
  • Relevance scoring — Ensures the most useful code is included

🎨 Style Mirroring

  • Naming convention detection — Replicates your camelCase/snake_case patterns
  • Code formatting preferences — Matches your semicolons, quotes, spacing
  • TypeScript awareness — Understands strict types, interfaces vs types, etc.

🚀 Model-Aware Generation

  • GPT-4/3.5 — Structured, clear instructions
  • Claude — Detailed, explanatory context
  • OpenRouter — Optimized for any model you choose

Installation

npm install -g @elilands/promptune
# or
pnpm add -g @elilands/promptune

Quick Start

1️⃣ Generate a Prompt

promptune generate "crea un hook useCart para manejar el carrito de compras"
promptune generate "refactoriza este endpoint de pagos" -f src/api/payment.ts

2️⃣ Build Project Index

promptune index

3️⃣ View Project Info

promptune info

Usage Examples

Create a New Feature

promptune generate "crea un componente React que muestre un modal de confirmación"

What happens:

  • Finds similar components in your project
  • Analyzes their structure and patterns
  • Includes relevant utilities and hooks
  • Generates a prompt that matches your exact style

Refactor Legacy Code

promptune generate "refactoriza para mejorar performance" -f src/heavy-component.tsx

What happens:

  • Analyzes the target file
  • Finds similar patterns in your codebase
  • Includes best practices from your other components
  • Suggests optimizations aligned with your project

Generate Tests

promptune generate "escribe tests completos para esta función" -f src/utils/calculate.ts

What happens:

  • Detects your testing framework
  • Includes example tests from your project
  • Matches your testing patterns and assertions
  • Generates tests that work with your actual setup

Migrate Code

promptune generate "migra esto de REST a tRPC"

What happens:

  • Finds tRPC examples in your project (if they exist)
  • Understands your API structure
  • Generates migration plan with your actual types

Configuration

Via CLI Options

promptune generate "your task" \
  --model gpt-4 \                    # GPT-4, Claude, etc.
  --tokens 4000 \                    # Max context tokens
  --file src/target.ts \             # Optional target file
  --root . \                         # Project root
  --verbose                          # More detailed output

Via Environment Variables

PROMPTUNE_MODEL=gpt-4
PROMPTUNE_MAX_TOKENS=4000
PROMPTUNE_VERBOSE=false
OPENAI_API_KEY=sk-...

How It Works Internally

1. Semantic Indexing

Your Codebase
    ↓
Extract: functions, classes, types, imports, exports
    ↓
Generate embeddings for semantic search
    ↓
Detect patterns and architecture
    ↓
Cache results for speed

2. Task Analysis

User Query: "crea un hook useCart"
    ↓
Detect action: CREATE
    ↓
Find related code: useAuth, useProducts patterns
    ↓
Extract constraints: Use Zustand, TypeScript strict mode, etc.
    ↓
Estimate token usage

3. Prompt Generation

Combine sections:
  1. Base instruction (adapted to model)
  2. Project context
  3. Code style guide
  4. Examples from repo
  5. Relevant files
  6. Constraints
  7. Specific instructions
    ↓
Result: Highly contextualized prompt

Project Structure

src/
├── cli/                    # CLI interface
│   ├── index.ts           # Command definitions
│   └── core.ts            # Main orchestrator
├── indexer/               # Code indexing engine
│   └── index.ts           # Semantic indexing
├── analyzer/              # Task understanding
│   └── index.ts           # Context analysis
├── generator/             # Prompt generation
│   └── index.ts           # Prompt builder
├── embeddings/            # RAG & semantic search
│   └── index.ts           # Embedding utilities
├── types/                 # TypeScript definitions
│   └── index.ts           # Core types
├── utils/                 # Helper functions
│   └── file.ts            # File utilities
└── index.ts              # Main export

Advanced Usage

Programmatic API

import { PromptuneCore } from '@elilands/promptune';

const promptune = new PromptuneCore({
  root: '/path/to/project',
  aiModel: 'gpt-4',
  maxContextTokens: 4000,
  indexCacheDir: '.promptune',
  verbose: false,
  includePatterns: [],
  excludePatterns: ['node_modules', 'dist'],
});

// Generate prompt
const result = await promptune.generatePrompt(
  'crea un componente Button reutilizable',
  'src/components/index.ts' // optional target file
);

if (result.success && result.prompt) {
  console.log(result.prompt.prompt);
  console.log(`Relevance: ${result.prompt.metadata.relevanceScore}%`);
  console.log(`Tokens: ${result.prompt.metadata.tokenCount}`);
}

// Get project info
const info = await promptune.getProjectInfo();
console.log(info.metadata);
console.log(info.patterns);

// Build/update index
await promptune.buildIndex(true); // force rebuild

Extending Promptune

import {
  CodeIndexer,
  TaskAnalyzer,
  PromptGenerator,
  SemanticIndex,
} from '@elilands/promptune';

// Load index
const indexer = new CodeIndexer('/project/root');
const index = await indexer.buildIndex();

// Analyze task
const analyzer = new TaskAnalyzer(index);
const taskContext = await analyzer.analyzeTask('your query');

// Generate custom prompt
const generator = new PromptGenerator(index, 4000);
const prompt = generator.generatePrompt(taskContext, 'gpt-4');

Supported Models

  • OpenAI: gpt-4, gpt-3.5-turbo
  • Anthropic: claude-3-opus, claude-3-sonnet, claude-3-haiku
  • OpenRouter: Any model via OpenRouter API
  • Local: Local LLMs (via OpenRouter or custom setup)

Performance

Promptune is designed for speed:

  • First run: ~2-5 seconds (depending on project size)
  • Subsequent runs: <100ms (with cache)
  • Memory: Minimal footprint (~50-100MB for typical projects)

Caching

Promptune automatically caches the semantic index in .promptune/:

# Clear cache
promptune clean

# Force rebuild index
promptune index --force

Development

# Install dependencies
npm install

# Build
npm run build

# Development mode
npm run dev

# Testing
npm test

# Linting
npm run lint

# Format
npm run format

Roadmap

  • [ ] Vector embeddings — Integration with OpenAI embeddings API
  • [ ] Prompt evolution — Learn from which prompts generate better results
  • [ ] VS Code integration — Generate prompts directly from editor
  • [ ] Prompt templates — Pre-built templates for common tasks
  • [ ] Team settings — Share project configuration across teams
  • [ ] Web UI — Visual prompt builder and preview
  • [ ] Git integration — Understand recent changes context
  • [ ] Multi-language support — Better support for non-JavaScript projects

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License — see LICENSE file for details

Support

Why Promptune?

Traditional prompt engineering is:

  • ❌ Manual and tedious
  • ❌ Generic across all projects
  • ❌ Requires understanding both code AND prompting
  • ❌ Hard to maintain as projects evolve

Promptune solves this by:

  • ✅ Automating prompt generation
  • ✅ Understanding YOUR codebase
  • ✅ Matching your exact code style
  • ✅ Evolving with your project
  • ✅ Reducing LLM token usage (= lower costs)

See Also


Made with ❤️ by @elilands