Magic Prompt
A TUI and CLI tool that enriches short, vague prompts into detailed, structured prompts using Groq API and your project's actual file structure and codebase.
Features
- 📁 Project-Aware: Scans your project's file structure, config files, and extracts code signatures
- 🧠 AI-Powered: Uses Groq's fast LLM API to intelligently expand prompts
- ⚡ Real-Time Streaming: Watch the enriched prompt generate in real-time
- 🖥️ Dual Mode: Interactive TUI or headless CLI for shell scripting
- 🗂️ Workspace Management: Save and switch between multiple project workspaces
- 🎯 Dynamic Model Selection: Automatically fetch and select from available Groq models
- 📊 Status Bar: Real-time display of current mode, model, and settings
Installation
From PyPI
pip install ai-magic-prompt
Or with uv:
uv tool install ai-magic-prompt
Raycast Extension
The easiest way to install the Raycast extension is using the built-in command:
# Print the script to your terminal
magic-prompt --install-raycast
# Or save it directly to your Raycast scripts folder
magic-prompt --install-raycast ~/path/to/raycast/scripts
This will generate a script that automatically uses your current magic-prompt installation.
From Source
git clone https://github.com/arterialist/magic-prompt.git
cd magic-prompt
pip install -e .
Setup
Get your Groq API key from console.groq.com/keys.
Set it as an environment variable:
export GROQ_API_KEY=gsk_...
Configuration
Magic Prompt saves your preferences in ~/.config/magic-prompt/config.json. You can configure these via the CLI:
Model Selection
Set your preferred Groq model (default: llama-3.3-70b-versatile):
magic-prompt --model llama-3.1-8b-instant
Debounce Time
Adjust the real-time enrichment delay in milliseconds (default: 800):
magic-prompt --debounce 500
Default Directory
Save your current project directory as the default:
magic-prompt --save-dir .
View Current Config
magic-prompt --show-config
Or create a .env file in your project directory:
GROQ_API_KEY=your_api_key_here
Usage
Headless CLI Mode
Run from anywhere as a shell command:
# Basic usage - enrich a prompt
magic-prompt "add user authentication"
# Pipe prompt from stdin
echo "add logging" | magic-prompt
# Specify project directory
magic-prompt -d /path/to/project "refactor the API"
# Quiet mode - only output result (good for piping)
magic-prompt -q "add tests" > enriched.md
CLI Options
| Option | Description |
|---|---|
-d, --directory |
Project directory (default: from config or cwd) |
-t, --tui |
Launch interactive TUI mode |
-q, --quiet |
Only output result, no progress |
--retrieval |
File retrieval mode: tfidf, heuristic, none |
--model |
Groq model to use (e.g., llama-3.3-70b-versatile) |
--debounce MS |
Set debounce time for real-time mode |
--save-dir DIR |
Save default directory for future runs |
--show-config |
Show current configuration |
Interactive TUI Mode
magic-prompt --tui
# OR just run without arguments:
magic-prompt
- Enter your project's root directory path
- Type a short prompt (e.g., "add user authentication")
- Watch the enriched, project-aware prompt stream in real-time
- Press
Ctrl+Yto copy the enriched prompt
TUI Keyboard Shortcuts
| Key | Action |
|---|---|
Enter |
Submit prompt |
Ctrl+T |
Toggle real-time |
Ctrl+Y |
Copy to clipboard |
Ctrl+U |
Clear Input |
Ctrl+L |
Clear Output |
Ctrl+R |
Cycle retrieval mode |
F5 |
Rescan project |
Ctrl+S |
Open Settings |
Ctrl+M |
Cycle enrichment mode |
Ctrl+W |
Manage workspaces |
Ctrl+D |
Cycle through workspaces |
Ctrl+Q |
Quit |
How It Works
- Scans your project directory structure
- Extracts docstrings, function signatures, and imports
- Retrieves the most relevant files based on your prompt (configurable)
- Sends context + your prompt to Groq's LLM
- Streams an enriched version that references actual files and APIs
Retrieval Modes
Magic Prompt uses intelligent file retrieval to select the most relevant files from your project context before sending to the LLM. This is especially important for monorepos and large projects where including all files would exceed context limits.
Available Modes
| Mode | Description | Best For |
|---|---|---|
tfidf |
Hybrid TF-IDF + heuristic scoring (default) | Large projects, balanced accuracy |
heuristic |
Path and content-based structural matching | Monorepos, explicit file targeting |
none |
Include all files without filtering | Small projects (<50 files) |
Setting Retrieval Mode
CLI (one-time):
magic-prompt --retrieval heuristic "add user auth"
Config (persistent):
# In TUI: Press Ctrl+R to cycle through modes
# Or edit ~/.config/magic-prompt/config.json:
{
"retrieval_mode": "tfidf"
}
Working Principle
TF-IDF Mode (Hybrid):
- Computes TF-IDF vectors for all files based on path, docstrings, functions, and classes
- Blends TF-IDF similarity (5%) with heuristic scoring (95%)
- Produces relevance percentages shown in the LLM context (e.g.,
[95% relevant])
Heuristic Mode:
- Matches query keywords against file paths, function names, and class names
- Boosts exact path segment matches
- Considers file recency (recently modified files rank higher)
None Mode:
- Includes all scanned files up to
max_fileslimit - No filtering or ranking applied
- Use only for small projects where context fits
Recommendations
| Scenario | Recommended Mode | Reason |
|---|---|---|
| Monorepo with multiple projects | heuristic |
Best at isolating the correct subproject |
| Large single project | tfidf |
Balanced keyword + structural matching |
| Small project (<50 files) | none |
Full context fits, no filtering needed |
| Targeting specific files by path | heuristic |
Highest weight on path segments |
| General feature requests | tfidf |
Good at keyword relevance |
Configuration Options
{
"retrieval_mode": "tfidf", // "tfidf" | "heuristic" | "none"
"top_k_files": 20, // Max files to include in context
"max_files": 5000, // Max files to scan (increase for monorepos)
"max_depth": 8 // Directory traversal depth
}
License
GNU General Public License v3.0 - see LICENSE for details.
Metadata
Release files for ai-magic-prompt 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ai_magic_prompt-0.5.1.tar.gz | 1.3 MB | With provenance | Details for ai_magic_prompt-0.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ai_magic_prompt-0.5.1-py3-none-any.whl | Python 3 | none | any | Details for ai_magic_prompt-0.5.1-py3-none-any.whl |
Total release size: 1.3 MB
Release files / ai_magic_prompt-0.5.1.tar.gz
| Download URL | ai_magic_prompt-0.5.1.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07371ef234a75da3b497771264712b654a2aa02b5e2e243011eecf1564d27a4d
|
|
BLAKE2b-256 checksum How to use checksums |
e7cfc9e53ddb4f9c564fa43aebb6735d3199e7f45fb16d3171c0f584b444cb5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 25, 2026.
Transparency logRelease files / ai_magic_prompt-0.5.1-py3-none-any.whl
| Download URL | ai_magic_prompt-0.5.1-py3-none-any.whl |
|---|---|
| Size | 50.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c73a01e8b30b0c8dd5607e909d3235c730d1d149b53f4b82d99ac74a2566b79
|
|
BLAKE2b-256 checksum How to use checksums |
c285e29c187928ac05c5e08fa176226ac5aa3e2d0d79975ea60d5e9fcb105991
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 25, 2026.
Transparency logSecurity for ai-magic-prompt 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ai_magic_prompt-0.5.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.