@elilands/promptune
v0.1.0
Published
An intelligent prompt generation and optimization engine aware of your codebase
Maintainers
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/promptuneQuick 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.ts2️⃣ Build Project Index
promptune index3️⃣ View Project Info
promptune infoUsage 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.tsxWhat 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.tsWhat 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 outputVia 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 speed2. 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 usage3. 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 promptProject 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 exportAdvanced 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 rebuildExtending 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 --forceDevelopment
# Install dependencies
npm install
# Build
npm run build
# Development mode
npm run dev
# Testing
npm test
# Linting
npm run lint
# Format
npm run formatRoadmap
- [ ] 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:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - 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
- Cursor IDE — AI-powered code editor
- Copilot — GitHub's AI assistant
- Codeium — Free AI code assistant
- Tabnine — AI code completion
Made with ❤️ by @elilands
