# PromptCraft
<div align="center">




**A powerful GUI tool for crafting structured prompts with file integration**
*Built for efficient communication with AI assistants*
</div>
## β¨ Features
### π **Structured Prompt Sections**
- **Pre-prompt**: Set the initial context and tone
- **Role**: Define the AI's persona and expertise
- **Context**: Provide background information and constraints
- **Mission**: Specify the primary objective and goals
- **Rules**: Establish guidelines and constraints
- **Post-prompt**: Add final instructions and formatting
### π **File System Integration**
- Interactive file tree with checkboxes for selection
- Language filtering (Python, C/C++, or all files)
- Intelligent ignore patterns via `.excludes` file
- Preserve selections across directory changes
### π§ **Other Features**
- **One-click crafting**: Combine sections and files into formatted prompts
- **Auto-copy to clipboard**: Results are automatically copied for immediate use
- **File syntax highlighting**: Code blocks with appropriate language tags
- **Configurable defaults**: Load and save section templates
- **Dark theme**: Modern, eye-friendly interface
## π Quick Start
### Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
### Installation Options
#### Option 1: Automatic Setup (Linux/macOS)
If you're on Linux or macOS, use the provided setup script:
```bash
# Make the setup script executable
chmod +x setup_venv.sh
# Run the setup script
./setup_venv.shThe setup_venv.sh script will:
- Check if Python 3.8+ is installed
- Create a virtual environment in
venv/ - Upgrade pip to the latest version
- Install all required dependencies from
requirements.txt - Provide instructions for activating the virtual environment
For Windows users or if you prefer manual setup:
-
Clone the repository
git clone https://github.com/LoganSeven/promptcraft.git cd promptcraft -
Create and activate virtual environment
# Windows python -m venv venv venv\Scripts\activate # Linux/macOS python3 -m venv venv source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
After setup, run the application:
# Ensure virtual environment is activated
# On Linux/macOS:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
# Run the application
python main.py| Platform | Activation Command | Run Command |
|---|---|---|
| Linux/macOS | source venv/bin/activate |
python main.py |
| Windows | venv\Scripts\activate |
python main.py |
-
Load a Project Directory
- Click the folder icon in the file tree panel
- Select your project directory
-
Configure Prompt Sections
- Edit each section with your specific requirements
- Use the Load/Save/Clear buttons for template management
- Default templates load automatically from
default_*.txtfiles
-
Select Files to Include
- Browse the file tree on the right panel
- Check files you want to include in the prompt
- Use "Select All"/"Deselect All" for bulk operations
- Filter by language using the dropdown (Python, C/C++, or all files)
-
Craft Your Prompt
- Click the Craft button in the Result section
- The formatted prompt appears in the Result area
- The prompt is automatically copied to your clipboard
- A status message shows file count and character count
- Files are filtered based on the language setting in the dropdown
- Hidden files and directories are automatically excluded using patterns in
.excludes - You can customize ignore patterns by editing the
.excludesfile - Selections are preserved when refreshing or changing directories
- The tree automatically expands to show all directories
| Action | Shortcut |
|---|---|
| Switch between sections | Tab / Shift+Tab |
| Select all files | Ctrl+A (in file tree) |
| Craft prompt | Ctrl+Enter (when in Result section) |
| Clear current section | Ctrl+Delete |
Place these files in your project root to pre-load section content on startup:
| File | Purpose | Example Content |
|---|---|---|
default_pre_prompt.txt |
Initial context and tone | Hello comrade, happy to work with you |
default_role.txt |
AI persona definition | You are an experienced Python developer... |
default_context.txt |
Background information | You are working on a GUI application... |
default_mission.txt |
Primary objectives | You need to implement a feature that... |
default_rules.txt |
Guidelines and constraints | 1. Write clean, commented code... |
default_post_prompt.txt |
Final instructions | Please provide the complete solution... |
The application uses a .excludes file to determine which files/directories to hide. You can edit this file directly in the application or manually:
# Example .excludes file content
__pycache__/
*.pyc
.venv/
venv/
env/
build/
dist/
*.log
.git/
.vscode/
.idea/The application automatically generates a default .excludes file based on your selected language filter.
The application can also parse exclude patterns from a display_folder_tree.sh script if present:
EXCLUDE_PATTERNS=(
"*.pyc"
"__pycache__"
".git"
"venv/"
)promptcraft/
βββ main.py # Application entry point
βββ requirements.txt # Python dependencies (PySide6)
βββ setup_venv.sh # Automatic setup script (Linux/macOS)
βββ .gitignore # Git ignore rules
βββ README.md # This documentation
β
βββ config/ # Configuration modules
β βββ __init__.py
β βββ constants.py # Constants, defaults, and language mappings
β βββ language_config.py # Language-specific patterns and configurations
β
βββ core/ # Core business logic
β βββ __init__.py
β βββ file_operations.py # File I/O with encoding fallbacks
β βββ ignore_patterns.py # Pattern matching and ignore logic
β βββ tree_model.py # File tree model and builder classes
β
βββ ui/ # User interface components
β βββ __init__.py
β βββ main_window.py # Main application window and layout
β βββ style.qss # Qt Style Sheet for dark theme
β βββ utils.py # UI utility functions
β βββ components/ # Reusable UI widgets
β βββ __init__.py
β βββ file_tree_widget.py # Interactive file tree with controls
β βββ text_section.py # Text section with buttons
β
βββ assets/ # Optional asset files (icons)
βββ folder.png # Folder icon for directory button
βββ refresh.png # Refresh icon for refresh button
The application uses Qt Style Sheets (QSS) for theming. You can customize the appearance:
- Edit the main stylesheet: Modify
ui/style.qssto change colors, borders, and spacing - Inline styles: Some components have inline styles that can be modified in the code
- Fallback styles: If
style.qssis not found, embedded fallback styles are used
Example style modification in ui/style.qss:
QPushButton {
background-color: #2d2d30;
color: #ffffff;
border: 1px solid #3a3a3a;
border-radius: 3px;
padding: 2px 8px;
min-height: 22px;
max-height: 22px;
}
QPushButton:hover {
background-color: #3e3e42;
border: 1px solid #2196F3;
}To add support for a new programming language:
-
Update
config/constants.py:LANGUAGE_EXTENSIONS: Dict[str, Set[str]] = { "python": {".py", ".pyw", ".pyx"}, "c/cpp": {".c", ".cpp", ".h", ".hpp"}, "javascript": {".js", ".jsx", ".ts", ".tsx"}, # Add new language # Add more languages as needed } LANGUAGE_DISPLAY_NAMES = { "python": "Python files only", "c/cpp": "C/C++ files only", "javascript": "JavaScript/TypeScript files", # Add display name }
-
Add language-specific patterns in
config/language_config.py:def get_language_specific_patterns(language_filter: str) -> List[str]: if language_filter == "javascript": return [ "", "# JavaScript/TypeScript", "node_modules/", "dist/", "build/", "*.js.map", "*.ts.buildinfo", "package-lock.json", "yarn.lock", ]
-
Add to
SECTION_ORDERinconfig/constants.pyif needed.
We welcome contributions! Here's how you can help:
- Report Issues: Open a GitHub issue for bugs or problems
- Request Features: Suggest new features through the issue tracker
- Submit Pull Requests: Implement improvements or fixes
# Activate virtual environment
source venv/bin/activate # or venv\Scripts\activate on Windows
# Install development tools
pip install black flake8 mypy
# Format code (follows PEP 8)
black .
# Check code quality and style
flake8 .
# Run type checking
mypy .
# Test the application
python main.py- Follow PEP 8 conventions
- Use type hints for function signatures
- Add docstrings for public functions and classes
- Keep functions focused and modular
- Use descriptive variable and function names
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with PySide6 - The official Qt for Python binding
- Inspired by the growing need for structured AI prompt engineering
- Color scheme inspired by VsCodium's dark theme
-
"ModuleNotFoundError: No module named 'PySide6'"
- Ensure virtual environment is activated:
source venv/bin/activate - Reinstall requirements:
pip install -r requirements.txt
- Ensure virtual environment is activated:
-
Application crashes on startup
- Check Python version:
python --version(needs 3.8+) - Try running with
python3 main.pyifpythonpoints to Python 2
- Check Python version:
-
File tree not showing files
- Check that you've selected a directory with the folder button
- Verify language filter setting
- Check
.excludesfile for overly restrictive patterns
-
Buttons or text cut off
- This is usually a DPI scaling issue on high-resolution displays
- Try adjusting your system's display scaling settings
- Or modify button heights in
ui/components/text_section.py
- GitHub Issues: Report bugs or request features
- Pull Requests: Submit fixes or improvements
- Documentation: Check this README first for common solutions
- Repository: github.com/LoganSeven/promptcraft
- Issues: GitHub Issue Tracker
- Discussions: Feature requests and questions
Made with β€οΈ for developers and AI enthusiasts
Craft better prompts, write better code π