@mazhu/prompt-vault
v1.0.0
Published
A lightweight AI prompt manager — store, version, tag, search, and render prompts with template variables. Zero dependencies.
Maintainers
Readme
🏦 prompt-vault
A lightweight AI prompt manager — store, version, tag, search, and render prompts with template variables. Zero dependencies.
Why?
If you work with AI (ChatGPT, Claude, GPT-4 API, etc.), you have prompts scattered everywhere — notes, docs, code comments. prompt-vault gives them a home:
- 📦 Store prompts with IDs, names, descriptions, tags
- 🔖 Template variables —
{{language}},{{topic}}, etc. - 📜 Version history — every edit is tracked
- 🔍 Search & filter — by tag, keyword, or name
- 💾 File persistence — save/load from JSON
- 🖥️ CLI — manage prompts from the terminal
- 🪶 Zero dependencies — just Node.js
Install
npm install prompt-vaultQuick Start
const { PromptVault } = require('prompt-vault');
const vault = new PromptVault({ name: 'my-prompts' });
// Add prompts
vault.add({
id: 'code-review',
template: 'Review this {{language}} code for bugs and suggest improvements:\n\n{{code}}',
tags: ['coding', 'review'],
defaults: { language: 'JavaScript' },
});
vault.add({
id: 'blog-post',
template: 'Write a {{length}} blog post about {{topic}} in {{tone}} tone',
tags: ['writing', 'blog'],
defaults: { length: '500-word', tone: 'professional' },
});
// Render with variables
console.log(vault.render('code-review', { code: 'function add(a,b) { return a-b }' }));
// → "Review this JavaScript code for bugs and suggest improvements:
// function add(a,b) { return a-b }"
// Search
vault.list({ tag: 'coding' });
vault.list({ search: 'blog' });
// Stats
console.log(vault.stats());CLI
# Add a prompt
npx prompt-vault add code-review "Review this {{language}} code: {{code}}" --tag=coding
# Render
npx prompt-vault render code-review language=Python code="print('hello')"
# List all
npx prompt-vault list
# Filter by tag
npx prompt-vault list --tag=coding
# Show details
npx prompt-vault get code-review
# Remove
npx prompt-vault remove code-review
# Export / Import
npx prompt-vault export prompts.json
npx prompt-vault import prompts.jsonAPI
new PromptVault({ name, path })
Creates a new vault. path sets the default file for save()/load().
vault.add(opts) / vault.set(id, template, opts)
Add a prompt. set() will update if the id already exists.
vault.add({
id: 'summarize',
template: 'Summarize this {{type}} in {{length}} words:\n{{content}}',
name: 'Summarizer',
description: 'Universal summarization prompt',
tags: ['writing', 'summary'],
defaults: { type: 'article', length: '100' },
meta: { author: 'team', version: '2.0' },
});vault.get(id) → PromptEntry | null
vault.render(id, values) → string
Renders the prompt template with provided values (merged with defaults).
vault.update(id, template, opts)
Updates a prompt. Creates a new version entry automatically.
vault.remove(id) → boolean
vault.list({ tag, search, sort, limit }) → PromptEntry[]
tag— filter by tag (string or array)search— search in id, name, description, templatesort—'name','created', or'updated'limit— max results
vault.stats() → { name, total, tags }
vault.save(path?) / vault.load(path?)
File persistence (Node.js only). Requires vault.path or passing a path.
vault.stringify(indent?) / vault.parse(json)
JSON export/import.
PromptEntry
Each prompt has:
| Property | Type | Description |
|-------------|------------|----------------------------------|
| id | string | Unique identifier |
| template | string | Template with {{var}} syntax |
| name | string | Human-readable name |
| description | string | Description |
| tags | string[] | Tags for filtering |
| defaults | object | Default variable values |
| meta | object | Arbitrary metadata |
| vars | string[] | Auto-extracted template variables|
| versions | array | Version history |
| created | number | Creation timestamp |
| updated | number | Last update timestamp |
entry.render(values?)
Renders the template. Missing variables throw an error.
entry.update(template, opts?)
Updates the prompt and appends to version history.
entry.version(n)
Get a specific version (1-indexed, negative counts from end).
Real-World Patterns
Shared Team Prompt Library
// On a shared drive / git repo
const vault = new PromptVault({ path: './team-prompts.json' });
vault.load();
// Everyone uses the same vetted prompts
const prompt = vault.render('api-docs', { endpoint: '/users', method: 'GET' });Prompt A/B Testing
vault.add({ id: 'summarize-v1', template: 'Summarize: {{text}}', tags: ['experiment-a'] });
vault.add({ id: 'summarize-v2', template: 'Create a concise summary of: {{text}}', tags: ['experiment-b'] });
// Track which performs better via version historyCI/CD Integration
// Generate release notes with a consistent prompt
const vault = new PromptVault();
vault.load('./prompts.json');
const prompt = vault.render('release-notes', { commits: commitLog, version: '2.0.0' });License
MIT
