ai-prompt-gen
v1.3.2
Published
Generate contextual prompts for AI assistants from your project files
Maintainers
Readme
AI Prompt Generator
🤖 Generate contextual prompts for AI assistants (ChatGPT, Claude, Gemini, etc.) from your project files with smart file filtering, wildcard patterns, and custom descriptions.
Installation
# Install in your project
npm install ai-prompt-gen --save-dev
# Or install globally
npm install -g ai-prompt-genQuick Start
# 1. Go to your project directory
cd my-project
# 2. Create intelligent config (scans current directory)
ai-prompt --init
# 3. Generate prompts immediately
ai-prompt default # All important project files
ai-prompt frontend # Default + frontend-specific files
ai-prompt backend # Default + backend-specific files
# 4. Add files when needed
ai-prompt add frontend src/NewComponent.vue
ai-prompt add frontend ./components/*.svelte "All Svelte components"
ai-prompt add backend ./api/**/*.js "All API endpoints"
ai-prompt add backend app/controllers/ApiController.php "REST API endpoints"Features
✅ Explicit file control - You define exactly which files to include
✅ Wildcard patterns - Add multiple files at once with *, **, and ? patterns
✅ File descriptions - Add context for each file to help AI understand
✅ Multiple profiles - Different contexts for different use cases
✅ Default project context - Core files automatically included in all prompts
✅ Intelligent initialization - Automatically scans your project for code files
✅ Gitignore support - Respects your .gitignore patterns automatically
✅ Easy file management - Add single files or patterns to profiles with simple commands
✅ Automatic clipboard - Generated prompts copied directly to clipboard
✅ Syntax highlighting - Proper code formatting in prompts
✅ Missing file warnings - Alerts for files that don't exist
✅ Duplicate detection - Skip files already in profiles
✅ Multi-AI support - Works with ChatGPT, Claude, Gemini, and any AI assistant
How It Works
1. Intelligent Initialization
When you run ai-prompt --init, the tool:
- Scans your current directory for code files (HTML, CSS, JS, TS, PHP, Vue, Svelte, etc.)
- Respects .gitignore - Automatically excludes files and folders listed in your .gitignore
- Creates a smart config with found files organized into logical profiles
- Generates descriptions automatically based on file types
- Sets up a default profile with your most important project files
2. Default Project Context
Every profile (except 'default' itself) automatically includes files from the 'default' profile, ensuring consistent project context across all your prompts.
3. Easy File Management
Add new files to any profile with simple commands:
# Single file
ai-prompt add frontend src/components/NewComponent.vue "Main navigation component"
# Multiple files with wildcards
ai-prompt add frontend ./components/*.svelte "All Svelte components"
ai-prompt add backend ./api/**/*.js "All API endpoints in subdirectories"Wildcard Patterns
The tool supports powerful wildcard patterns for adding multiple files at once:
| Pattern | Description | Example |
|---------|-------------|---------|
| * | Any characters (not across directories) | ./src/*.js - All .js files in src/ |
| ** | Any characters including subdirectories | ./src/**/*.ts - All .ts files in src/ and subdirs |
| ? | Single character | ./test?.js - test1.js, testA.js, etc. |
Wildcard Examples:
# All components in a directory
ai-prompt add frontend ./components/*.vue
ai-prompt add frontend ./components/*.svelte
# All files in subdirectories
ai-prompt add backend ./api/**/*.js
ai-prompt add frontend ./src/**/*.ts
# Specific patterns
ai-prompt add backend ./routes/*.route.js
ai-prompt add frontend ./pages/**/*.page.vue
# All test files
ai-prompt add testing ./tests/**/*.test.js
ai-prompt add testing ./**/*.spec.tsConfiguration
The ai-prompts.config.json file defines your prompt profiles. After running --init, it will look something like:
{
"profiles": {
"default": {
"description": "Standard Projekt-Kontext mit allen relevanten Dateien",
"files": [
{
"path": "package.json",
"description": "Project dependencies and scripts"
},
{
"path": "src/main.js",
"description": "JavaScript Module - main.js"
}
],
"context": "Du hilfst bei der Entwicklung dieses Projekts. Analysiere die bereitgestellten Dateien und gib kontextbezogene Unterstützung."
},
"frontend": {
"description": "Frontend-spezifische Entwicklung",
"files": [
{
"path": "src/components/Header.vue",
"description": "Vue Component - Header.vue"
}
],
"context": "Du hilfst bei Frontend-Entwicklung. Fokus auf UI/UX, Components und User Interaction."
}
}
}Usage in package.json
Add scripts to your package.json for easy access:
{
"scripts": {
"prompt:default": "ai-prompt default",
"prompt:frontend": "ai-prompt frontend",
"prompt:backend": "ai-prompt backend"
}
}Then use:
npm run prompt:default
npm run prompt:frontendCommands
ai-prompt <profile>- Generate prompt for specified profile (includes default files)ai-prompt default- Generate prompt with all core project filesai-prompt add <profile> <file/pattern> [description]- Add file(s) to profile (supports wildcards)ai-prompt --init- Scan current directory and create intelligent configurationai-prompt --list- Show available profilesai-prompt --help- Show help information
Examples
# Initialize in your project
ai-prompt --init
# Generate different contextual prompts
ai-prompt default # All core files
ai-prompt frontend # Default + frontend files
ai-prompt backend # Default + backend files
# Add single files to profiles
ai-prompt add frontend src/App.vue
ai-prompt add backend api/UserController.php "Handles user CRUD operations"
ai-prompt add default README.md "Project documentation"
# Add multiple files with wildcards
ai-prompt add frontend ./components/*.svelte "All Svelte components"
ai-prompt add backend ./api/**/*.js "All API endpoints"
ai-prompt add frontend ./src/*.{vue,js} "Vue and JS files in src"
ai-prompt add testing ./tests/**/*.test.js "All test files"
ai-prompt add docs ./**/*.md "All documentation files"
# Complex patterns
ai-prompt add backend ./models/**/*.model.js "Database models"
ai-prompt add frontend ./pages/**/*.page.vue "All page components"
ai-prompt add config ./*.config.js "Configuration files"Programmatic Usage
You can also use the generator programmatically:
const { AIPromptGenerator } = require('ai-prompt-gen');
const generator = new AIPromptGenerator();
generator.loadConfig();
const prompt = await generator.generatePrompt('frontend');
// Add files programmatically (supports wildcards)
generator.addFilesToProfile('frontend', './components/*.vue');Why Use This?
Problem: Manually creating AI projects and uploading files is time-consuming, especially when you want different contexts for different types of questions. You also need consistent project context across different specialized prompts.
Solution:
- Intelligent project scanning - Automatically discovers your code files
- Wildcard file matching - Add multiple files instantly with patterns
- Default project context - Core files included in every prompt for consistency
- Smart profiles - Only relevant files with helpful descriptions for specific contexts
- Instant generation - Prompts ready in your clipboard in seconds
Benefits:
- Zero setup time -
--initanalyzes your project automatically - Bulk file operations - Wildcards let you add dozens of files instantly
- Consistent context - Default files ensure AI always understands your project
- Faster workflow - Generate prompts in seconds instead of minutes
- Better AI responses - AI gets exactly the right files with descriptions
- Always current - Uses your latest file versions every time
- Token efficient - Only include relevant files for your specific question type
- Universal - Works with ChatGPT, Claude, Gemini, and any AI assistant
License
MIT
