Skip to content
p promptel. github ↗
v0.3 · declarative · MIT

Prompts deserve a DSL,
not an f"{string}" graveyard.

Promptel is a small, declarative framework for production LLM prompts. Author them in a typed DSL or in YAML, pick the technique as a block, run them across OpenAI, Anthropic, or Groq from the same source.

npm install promptel

What you actually get.

/// features
dsl

Two equivalent surfaces

Authoring in a curly-brace .prompt DSL parsed with Chevrotain, or in plain YAML. Convert in either direction without losing semantics.

provider

Provider-portable

One prompt, three SDKs. OpenAI, Anthropic Claude, and Groq are wired in. Switch by changing a flag, not by rewriting templates.

techniques

Techniques as first-class blocks

Chain-of-Thought, Few-Shot, Zero-Shot, Tree-of-Thoughts, ReAct, Self-Consistency. Declared, not concatenated.

harmony

Harmony channels, natively

Multi-channel responses (final / analysis / commentary) addressed in the DSL, surfaced as structured fields on the result.

types

Typed params with defaults

Declare params with types, defaults, and optionality. The executor refuses prompts that don't bind, before any token leaves your machine.

cli

CLI in the box

Execute or convert prompts from a terminal. Pipe results, feed evals, wire into CI — without owning the runtime in your test harness.

Two formats, one AST.

The DSL is for humans reading prompts during review. The YAML is for tooling: schema validation, codegen, diff-driven evals. Both parse to the same AST and execute identically.

  • parsePrompt(src) — string to AST
  • executePrompt(src, params, opts) — end-to-end
  • FormatConverter — promptToYaml / yamlToPrompt
  • createProvider({ provider }) — pluggable
.prompt DSL
YAML
prompt CodeReviewer {
  meta {
    name: "Code Reviewer"
    version: "1.0"
  }

  params {
    code: string
    language?: string = "javascript"
  }

  body {
    text`Review the following ${params.language} code
    for security, correctness, and clarity:

    ${params.code}`

    technique {
      chainOfThought {
        step("Security") { text`Check for vulnerabilities` }
        step("Logic")    { text`Identify bugs` }
        step("Style")    { text`Suggest improvements` }
      }
    }
  }

  constraints { maxTokens: 800; temperature: 0.2 }
}
name: CodeReviewer

params:
  code: { type: string, required: true }
  language: { type: string, default: "javascript" }

body:
  text: |
    Review the following ${params.language} code
    for security, correctness, and clarity:

    ${params.code}

  technique:
    chainOfThought:
      steps:
        - { name: "Security", text: "Check for vulnerabilities" }
        - { name: "Logic",    text: "Identify bugs" }
        - { name: "Style",    text: "Suggest improvements" }

constraints:
  maxTokens: 800
  temperature: 0.2

Provider-portable, on purpose.

The reason to put a layer between your application and the SDK is not novelty — it is the day you swap a provider for cost, latency, or capability and nothing else in your codebase needs to move.

openai

GPT-class models, JSON mode, Harmony channels

await executePrompt(p, args, {
  provider: 'openai'
});
claude

Anthropic SDK, long-context jobs, tool-use blocks

await executePrompt(p, args, {
  provider: 'claude'
});
groq

Groq SDK, fast inference, eval-loop friendly

await executePrompt(p, args, {
  provider: 'groq'
});

Techniques are blocks, not folklore.

Most prompt techniques are recipes pasted between repos. Promptel turns the recipe into a node in the AST, so reviewers can see which technique is in play without reading the entire string.

  • → chainOfThought
  • → fewShot
  • → zeroShot
  • → treeOfThoughts
  • → reAct
  • → selfConsistency
prompt Analyzer {
  technique {
    chainOfThought {
      step("Understand") { text`Parse the input` }
      step("Analyze")    { text`Find patterns` }
      step("Conclude")   { text`Form a hypothesis` }
    }
  }
}

Stop concatenating prompts.
Declare them.

Promptel is small enough to read in an afternoon and opinionated enough to outlast the next provider rotation. The docs are the next stop.