PromptForge Logo
>_ Get Started

Introduction

PromptForge is a production-grade prompt engineering toolkit designed to bring type safety, immutability, and heuristics-based optimization to your AI pipeline. It was built for developers who treat prompts like real software.

The Problem

Currently, most developers build AI prompts using massive, messy string templates (e.g., const prompt = `Summarize: ${content}`). This approach is highly problematic in production environments:

  • No Type Safety: It is easy to forget a variable or inject a malformed object, confusing the LLM.
  • Token Bloat: Developers repeat rules across different prompts. The LLM processes "filler words" and duplicate constraints, wasting tokens and driving up API costs.
  • Hard to Scale: You cannot easily swap out parts of a string or share logic across a massive codebase safely.

Why PromptForge?

PromptForge solves these issues by treating prompt engineering as real software engineering.

  • Immutability & Composability: Build libraries of reusable rules (e.g., security constraints) and inject them safely without string concatenation spaghetti.
  • Validation: Intercept missing variables or conflicting formats before making expensive network requests to OpenAI or Anthropic.
  • Optimization: Our heuristic optimizer mathematically strips filler words and deduplicates rules, directly translating to lower API bills and faster response times.

Installation

Install the core builder package via pnpm:

pnpm add @promptforgee/core

API Reference

@promptforgee/core

The core package exports the `PromptBuilder` which uses a fluent API to construct prompts immutably.

import { Prompt } from '@promptforgee/core';

const prompt = Prompt.create()
  .role('Expert Developer')
  .task('Write a React component')
  .constraint('Use Tailwind CSS')
  .build();

@promptforgee/analyzer

Evaluate your prompts programmatically before sending them to an LLM.

import { analyzePrompt } from '@promptforgee/analyzer';

const report = await analyzePrompt("Write code.");
console.log(report.overallScore); // 45
console.log(report.weaknesses); // ["Missing constraints", "Missing format"]

@promptforgee/optimizer

Automatically rewrite your prompts to save tokens and strengthen logic.

import { optimizePrompt } from '@promptforgee/optimizer';

// Strips "Please", deduplicates contexts, and prefixes weak constraints with "MUST:"
const clean = await optimizePrompt(dirtyPrompt);

@promptforgee/registry

A powerful local registry to save, version, and tag your prompts.

import { LocalRegistryAdapter } from '@promptforgee/registry';

const registry = new LocalRegistryAdapter('./prompts');
await registry.save('security-review', promptState, { version: '1.0.0', tags: ['security'] });

@promptforgee/cli

The command-line interface for managing and testing your prompts right from your terminal.

npx promptforge analyze ./prompts/my-prompt.json
npx promptforge optimize ./prompts/my-prompt.json

@promptforgee/templates

A collection of battle-tested, pre-built prompt templates for common AI use cases.

import { createCodeReviewer } from '@promptforgee/templates';

const prompt = createCodeReviewer('TypeScript');