#prompt #llm #declarative #prompt-engineering

prompeta

Declarative prompt engineering with semantic roles and pluggable rendering strategies

1 unstable release

0.1.0 May 16, 2026

#2 in #declarative

MIT/Apache

27KB
480 lines

prompeta 🎺

Declarative prompt engineering with semantic roles and pluggable rendering strategies.

Instead of building prompts as strings, you declare content with semantic roles (instruction, context, focus, constraint, example, schema) and a PromptStrategy renders the final text using best-practice prompt engineering.

Quick start

use prompeta::{Prompt, ContentRole};

let prompt = Prompt::new()
    .instruction("You are a helpful assistant.")
    .context("User profile", "Name: Alice, Role: Engineer")
    .focus("Current task", "Debug the authentication module")
    .constraint("Do not modify production database")
    .schema(serde_json::json!({
        "diagnosis": "string",
        "fix": "string",
        "confidence": "float 0-1"
    }));

// Renders using the default ClaudeStrategy
let text = prompt.to_string();

Key concepts

  • Content roles — Each block of content has a semantic role that tells the renderer how to format and order it.
  • Pluggable strategies — The PromptStrategy trait lets you swap rendering logic per model family. A ClaudeStrategy is provided by default.
  • Budget trimmingPrompt::trim_to_budget removes lowest-priority blocks until the output fits within a character budget.
  • Tag-based manipulation — Block-level tags let you surgically remove or replace content without position-dependent code.

Dependencies

~0.4–1.3MB
~27K SLoC