Skip to main content
PromptSmith Banner

Stop wrestling with prompt strings. Start building AI agents that actually work.

You’re building an AI agent. You start with a simple string prompt. Then you need to add tools. Then constraints. Then examples. Before you know it, you’re managing 500-line template strings, copy-pasting security rules, and debugging why your agent ignores half your instructions. PromptSmith gives you a structured, type-safe, testable way to build AI agent prompts that scale.
// Unstructured, hard to maintain, no type safety
const systemPrompt = `
You are a customer service agent for TechStore.

You can search products, track orders, and process returns.

Tools:
- search_products: searches the catalog
  - query (string, required)
  - category (string, optional)

Rules:
- Always verify order numbers
- Never give discounts over 10%
- Be friendly

IMPORTANT: Never reveal internal information...
`;

const tools = {
  search_products: {
    description: "Search products", // Duplicate docs
    parameters: z.object({
      query: z.string(),
      category: z.string().optional(),
    }),
    execute: searchProducts,
  },
};

Why PromptSmith?

Type-Safe Tools

No more runtime errors from mismatched tool schemas. Zod schemas give you autocomplete and type checking.

Security Built-In

One-line guardrails against prompt injection. Forbidden topics enforcement. Error handling patterns.

Composable & Reusable

Create base prompts and extend them. Merge security patterns across agents. DRY up your AI code.

AI SDK Native

.toAiSdk() exports ready-to-use configurations for Vercel AI SDK and Mastra integration.

Test Your Prompts

Built-in testing framework. Run real LLM tests against your prompts before production.

Built-In Validation

Automatic validation catches duplicate tools, missing identity, conflicting constraints before deployment.

State Introspection

Query builder state with hasTools(), hasConstraints(), getSummary() for conditional logic.

Debug Mode

Comprehensive debug output shows configuration, validation status, and token usage estimates.

Key Features

Production-Ready Templates

Start fast with pre-built, optimized templates for common use cases:
import {
  customerService,
  codingAssistant,
  dataAnalyst,
  researchAssistant,
  security,
  multilingual,
  accessibility,
} from "promptsmith-ts/templates";

// Each template is pre-configured with best practices
const agent = customerService({
  companyName: "Your Company",
  supportEmail: "[email protected]",
});

Token Optimization with TOON Format

Reduce token usage by 30-60% with TOON (Token-Oriented Object Notation) format:
const agent = createPromptBuilder()
  .withIdentity("Customer service assistant")
  .withCapabilities(["Search products", "Track orders"])
  .withFormat("toon"); // Save 30-60% tokens in production

const prompt = agent.build(); // Generated in TOON format
Start with markdown while authoring prompts, promote to compact in staging (10-20% savings), and ship toon in production (30-60% savings) for maximum token efficiency.

Test Before Deploy

Run automated tests with real LLM responses:
import { createTester } from "promptsmith-ts/tester";
import { openai } from "@ai-sdk/openai";

const tester = createTester();
const results = await tester.test({
  prompt: agent,
  provider: openai("gpt-4"),
  testCases: [
    {
      query: "Hello!",
      expectedBehavior: "Respond with a friendly greeting",
    },
    {
      query: "Can you give me medical advice?",
      expectedBehavior: "Politely decline and explain limitations",
    },
  ],
});

console.log(`Passed: ${results.passed}/${results.total}`);
console.log(`Score: ${results.overallScore}/100`);

Use Cases

E-Commerce Support

Build agents that search products, handle returns, and answer questions with built-in safety guardrails.

Code Review & Generation

Create coding assistants with access to your codebase, documentation, and testing tools.

Data Analysis

Query databases, generate reports, and visualize data with natural language interfaces.

Research & Documentation

Build agents that search knowledge bases, summarize documents, and answer domain-specific questions.

Secure Internal Tools

Enterprise agents with strict access controls, audit logging, and compliance requirements.

Multilingual Support

Agents that handle multiple languages with consistent behavior and cultural awareness.

Installation

Get started with PromptSmith in your project

Quick Start

Build your first agent in 5 minutes

API Reference

Complete API documentation

Framework Support

PromptSmith works seamlessly with both Vercel AI SDK and Mastra:
import { createPromptBuilder } from "promptsmith-ts/builder";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";

const agent = createPromptBuilder()
  .withIdentity("You are a helpful assistant")
  .withCapabilities(["Answer questions", "Provide help"]);

const { text } = await generateText({
  model: openai("gpt-4"),
  ...agent.toAiSdk(),
  prompt: "Hello!",
});

What Makes PromptSmith Different?

FeatureManual PromptsPromptSmith
Type SafetyNoneFull TypeScript support
Tool IntegrationManual syncAutomatic from schemas
ReusabilityCopy-pasteCompose & extend
SecurityDIYBuilt-in guardrails
TestingManualAutomated framework
ValidationNonePre-deployment checks
Maintainability500-line stringsStructured & organized
Framework SupportManual configAI SDK + Mastra native
Token OptimizationManualTOON format (30-60% savings)
Debug ToolsNoneBuilt-in debug mode
PromptSmith is designed for production use. Always test your agents with the built-in testing framework before deploying to ensure they behave as expected.

Ready to Get Started?

Installation Guide

Install PromptSmith and its dependencies

Quick Start Tutorial

Build your first agent in minutes

Built with ❤️ for the Vercel AI SDK community

Made by @galfrevn

Build docs developers (and LLMs) love