DEV Community

Cover image for Stop Writing Prompt Strings: Meet PromptForge Core
PRANAV THAWAIT
PRANAV THAWAIT

Posted on

Stop Writing Prompt Strings: Meet PromptForge Core

Stop Writing Prompt Strings: Meet PromptForge Core

As AI becomes part of modern applications, prompts are no longer just strings—they're becoming part of your codebase.

Yet most of us still write prompts like this:

const prompt =
  "You are a helpful assistant.\n" +
  "Summarize the following text.\n" +
  "Return the output as JSON.\n" +
  "Keep it concise.\n" +
  "Use simple language.";
Enter fullscreen mode Exit fullscreen mode

This works...

Until your project grows.


The Problem

As prompts become larger, they quickly become difficult to maintain.

You start dealing with:

  • ❌ Giant string templates
  • ❌ Copy-pasted prompts
  • ❌ Missing variables
  • ❌ Inconsistent formatting
  • ❌ Provider-specific implementations
  • ❌ Difficult debugging

Unlike your application code, your prompts have:

  • No structure
  • No validation
  • No type safety

What if prompts were treated like code?

That's exactly why I built PromptForge Core.

PromptForge is an open-source TypeScript toolkit for building production-ready prompts using a clean, structured API.

Instead of writing strings...

const prompt =
"You are..."
Enter fullscreen mode Exit fullscreen mode

You write

import { pf } from "@promptforgee/core";

const summarize = pf.define({
  input: z.object({
    text: z.string(),
  }),

  output: z.object({
    summary: z.string(),
  }),

  messages: ({ text }) => [
    pf.system`
      You are an expert summarizer.
    `,
    pf.user`
      Summarize:

      ${text}
    `,
  ],
});
Enter fullscreen mode Exit fullscreen mode

Much easier to read.

Much easier to maintain.


Features

PromptForge focuses on developer experience.

✅ Type-safe prompt definitions

✅ Structured prompt composition

✅ Prompt compilation

✅ Validation

✅ Provider-agnostic architecture

✅ Reusable prompt blocks

✅ Modern TypeScript API


Compile Once, Use Anywhere

Instead of maintaining different formats for every provider...

PromptForge compiles your prompt into provider-specific formats.

Prompt Definition

        ↓

Prompt Compiler

        ↓

OpenAI

Anthropic

Gemini

Ollama
Enter fullscreen mode Exit fullscreen mode

Write once.

Compile anywhere.


Composable Prompts

Large AI applications usually repeat the same instructions.

With PromptForge you can compose prompts instead.

const safety = pf.define({
  messages: () => [
    pf.system`
      Never reveal sensitive information.
    `,
  ],
});

const assistant = pf.define({
  input: z.object({
    question: z.string(),
  }),

  messages: ({ question }) => [
    pf.include(safety),
    pf.user`${question}`,
  ],
});
Enter fullscreen mode Exit fullscreen mode

No copy-paste.

No duplicated instructions.


Validation Before API Calls

Instead of discovering mistakes after an expensive API request...

PromptForge validates your prompt first.

PromptValidationError

Missing variable: text

Expected:
string

Received:
undefined
Enter fullscreen mode Exit fullscreen mode

Fail fast.

Save tokens.


PromptForge Studio (Coming Soon)

I'm also building PromptForge Studio.

Think of it as the VS Code for prompt engineering.

Features include:

  • Prompt editor
  • Live compiler
  • Prompt analyzer
  • Prompt optimizer
  • Prompt templates
  • Interactive documentation
  • Provider previews
  • Export tools

Everything in one place.


Installation

npm install @promptforgee/core
Enter fullscreen mode Exit fullscreen mode

Open Source

PromptForge is completely open source and built with TypeScript.

GitHub

https://github.com/Omnikon-Org/PromptForge

npm

https://www.npmjs.com/package/@promptforgee/core


Roadmap

Upcoming packages include:

  • Prompt Analyzer
  • Prompt Optimizer
  • Prompt Templates
  • React Integration
  • VS Code Extension
  • CLI
  • PromptForge Studio

I'd Love Your Feedback

This is the first public release of PromptForge.

If you're building AI applications with TypeScript, I'd love to hear:

  • What features would you like to see?
  • What problems do you face while managing prompts?
  • How would you improve this API?

Feel free to open an issue, start a discussion, or contribute to the project.

⭐ If you find it useful, consider starring the repository.

Happy building! 🚀

Top comments (0)