https://github.com/marcosjimenez/pcompiler
A declarative prompt engineering framework that transforms high-level DSL definitions into optimized, model-specific LLM prompts.
https://github.com/marcosjimenez/pcompiler
cicd context-engineering prompt-engineering python tools
Last synced: about 2 months ago
JSON representation
A declarative prompt engineering framework that transforms high-level DSL definitions into optimized, model-specific LLM prompts.
- Host: GitHub
- URL: https://github.com/marcosjimenez/pcompiler
- Owner: marcosjimenez
- License: mit
- Created: 2026-02-23T00:09:33.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-02-27T02:58:59.000Z (about 2 months ago)
- Last Synced: 2026-02-27T03:58:03.760Z (about 2 months ago)
- Topics: cicd, context-engineering, prompt-engineering, python, tools
- Language: Python
- Homepage:
- Size: 106 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pCompiler
[](pyproject.toml)
[](LICENSE)
**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
```bash
# 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
1. **Auto-generate a DSL spec:**
```bash
pcompile create "Summarize a medical report focusing on patient history." --output medical.yaml
```
2. **Refine your DSL specification (`medical.yaml`):**
```yaml
task: summarize
model_target: gpt-4o
constraints:
tone: professional
cot_policy: auto
instructions:
- text: "Highlight patient history and active medications."
priority: 100
```
3. **Compile to a model-ready payload:**
```bash
pcompile compile medical.yaml --target gpt-4o
```
4. **Run automated evaluations:**
```bash
pcompile eval medical.yaml --mock
```
## π Where to get help
- [**DSL Reference**](docs/dsl.md): Detailed documentation of the YAML schema and attributes.
- [**Advanced Templating**](docs/dsl.md#advanced-templating-jinja2): Using Jinja2 for loops, conditionals, and complex logic.
- [**CLI Guide**](docs/cli.md): Full list of commands and options.
- [**Cost & Latency Estimator**](docs/cost_estimation.md): How to estimate prompt costs before execution and manage pricing data.
- [**Auto-Evals System**](docs/evals.md): How to build and run automated prompt quality tests.
- [**Context Engineering**](docs/dsl.md#context): Strategies for RAG and dynamic background information.
- [**Integrated CI/CD**](docs/cicd.md): Automating validation and testing in your pipeline.
- [**Packaging**](docs/packaging.md): How to build and distribute pCompiler on your own registry.
- [**Plugin System**](docs/plugins.md): Guide on how to use, write and manage backend plugins and their associated models.
## π₯ Who maintains & contributes
### Maintainer
- **Marcos JimΓ©nez** - [GitHub Profile](https://github.com/marcosjimenez)
### 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.*