PCompiler
A declarative prompt engineering framework that transforms high-level DSL definitions into optimized, model-specific LLM prompts.
Install / Use
/learn @marcosjimenez/PCompilerREADME
pCompiler
pCompiler is a declarative prompt engineering framework that transforms high-level DSL definitions into optimized, model-specific LLM prompts. It bridges the gap between raw text prompting and structured, versioned, and secure prompt management.
🌟 What the project does
pCompiler allows developers to treat prompts as code. By defining prompts in a structured YAML Domain Specific Language (DSL), you can:
- Generate starting specifications from natural language descriptions.
- Advanced Templating: Support for Jinja2 in user input templates (loops, conditionals).
- Validate prompts for ambiguities, contradictions, and security risks.
- Optimize content for specific LLM backends (OpenAI, Anthropic, Gemini).
- Estimate Costs before execution with real-time pricing and latency analytics.
- Automate quality control with built-in evaluation suites.
- Deploy versioned, reproducible prompt payloads to your applications.
✨ Why pCompiler?
In a world where LLM prompts are increasingly complex and critical to application logic, pCompiler provides the tools to make them robust:
- Type Safety & Validation: Uses Pydantic to ensure your specifications are always valid.
- Smart Optimization: Automatically applies semantic compression, Chain-of-Thought policies, and section reordering tailored to each model's strengths.
- Security by Design: Native protection against prompt injection and system prompt leakage.
- Collaborative Engineering: Versioned YAML files make it easy for teams to track changes and collaborate via Git.
- RAG Ready: Built-in support for multiple context sources, including local files, vector stores, and web search.
🚀 How to get started
Installation
# Clone the repository
git clone https://github.com/marcosjimenez/pCompiler.git
cd pCompiler
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
Quick Start
-
Auto-generate a DSL spec:
pcompile create "Summarize a medical report focusing on patient history." --output medical.yaml -
Refine your DSL specification (
medical.yaml):task: summarize model_target: gpt-4o constraints: tone: professional cot_policy: auto instructions: - text: "Highlight patient history and active medications." priority: 100 -
Compile to a model-ready payload:
pcompile compile medical.yaml --target gpt-4o -
Run automated evaluations:
pcompile eval medical.yaml --mock
📖 Where to get help
- DSL Reference: Detailed documentation of the YAML schema and attributes.
- Advanced Templating: Using Jinja2 for loops, conditionals, and complex logic.
- CLI Guide: Full list of commands and options.
- Cost & Latency Estimator: How to estimate prompt costs before execution and manage pricing data.
- Auto-Evals System: How to build and run automated prompt quality tests.
- Context Engineering: Strategies for RAG and dynamic background information.
- Integrated CI/CD: Automating validation and testing in your pipeline.
- Packaging: How to build and distribute pCompiler on your own registry.
- Plugin System: Guide on how to use, write and manage backend plugins and their associated models.
👥 Who maintains & contributes
Maintainer
- Marcos Jiménez - GitHub Profile
Contributing
We welcome contributions! Please feel free to open an issue or pull request to suggest improvements or report bugs.
pCompiler — Optimize your prompts, automate your evaluations.
