$git clone https://github.com/galfrevn/promptsmith---
| 1 | <div align="center"> |
| 2 | <picture> |
| 3 | <source media="(prefers-color-scheme: dark)" srcset="./assets/promptsmith-white.svg"> |
| 4 | <source media="(prefers-color-scheme: light)" srcset="./assets/promptsmith-black.svg"> |
| 5 | <img src="./assets/promptsmith-black.svg" alt="PromptSmith Logo" width="160" height="160"> |
| 6 | </picture> |
| 7 | |
| 8 | <h1 align="center">PromptSmith</h1> |
| 9 | |
| 10 | <p align="center"> |
| 11 | <strong>Type-Safe System Prompt Builder for Production AI Agents</strong> |
| 12 | <br /> |
| 13 | Stop wrestling with prompt strings. Start building AI agents that actually work. |
| 14 | </p> |
| 15 | |
| 16 | <p align="center"> |
| 17 | <a href="https://github.com/galfrevn/promptsmith/graphs/contributors"> |
| 18 | <img src="https://img.shields.io/github/contributors/galfrevn/promptsmith?style=for-the-badge" alt="Contributors"> |
| 19 | </a> |
| 20 | <a href="https://github.com/galfrevn/promptsmith/stargazers"> |
| 21 | <img src="https://img.shields.io/github/stars/galfrevn/promptsmith?style=for-the-badge" alt="Stars"> |
| 22 | </a> |
| 23 | <a href="https://github.com/galfrevn/promptsmith/issues"> |
| 24 | <img src="https://img.shields.io/github/issues/galfrevn/promptsmith?style=for-the-badge" alt="Issues"> |
| 25 | </a> |
| 26 | </p> |
| 27 | </div> |
| 28 | |
| 29 | --- |
| 30 | |
| 31 | <div align="center"> |
| 32 | <img src="./assets/banner-short.png" alt="PromptSmith Banner" width="100%" style="max-width: 1200px; border-radius: 8px;"> |
| 33 | </div> |
| 34 | |
| 35 | --- |
| 36 | |
| 37 | ## What is PromptSmith? |
| 38 | |
| 39 | A type-safe, composable prompt builder for the [Vercel AI SDK](https://sdk.vercel.ai/). Build production-ready AI agents with built-in security, tool integration, and token optimization. |
| 40 | |
| 41 | **For package documentation and API reference, see [apps/core/README.md](./apps/core/README.md)** |
| 42 | |
| 43 | ## Quick Example |
| 44 | |
| 45 | ```typescript |
| 46 | import { createPromptBuilder } from "promptsmith-ts/builder"; |
| 47 | import { generateText } from "ai"; |
| 48 | import { openai } from "@ai-sdk/openai"; |
| 49 | import { z } from "zod"; |
| 50 | |
| 51 | // Build your agent with a fluent API |
| 52 | const agent = createPromptBuilder() |
| 53 | .withIdentity("You are a helpful customer service assistant") |
| 54 | .withCapabilities(["Answer questions", "Process returns"]) |
| 55 | .withTool({ |
| 56 | name: "search_products", |
| 57 | description: "Search product catalog", |
| 58 | schema: z.object({ |
| 59 | query: z.string().describe("Search query"), |
| 60 | }), |
| 61 | execute: async ({ query }) => { |
| 62 | return await db.products.search({ query }); |
| 63 | }, |
| 64 | }) |
| 65 | .withGuardrails(); // Built-in security |
| 66 | |
| 67 | // Deploy in one line |
| 68 | const response = await generateText({ |
| 69 | model: openai("gpt-4"), |
| 70 | ...agent.toAiSdk(), |
| 71 | prompt: "Find me a laptop under $1000", |
| 72 | }); |
| 73 | ``` |
| 74 | |
| 75 | ## Project Structure |
| 76 | |
| 77 | This is a monorepo managed with [Turbo](https://turbo.build/) and [Bun](https://bun.sh/). |
| 78 | |
| 79 | ``` |
| 80 | promptsmith/ |
| 81 | ├── apps/ |
| 82 | │ ├── core/ # Main library package (promptsmith-ts) |
| 83 | │ │ ├── src/ |
| 84 | │ │ │ ├── builder.ts # SystemPromptBuilder class |
| 85 | │ │ │ ├── schemas.ts # Zod schema utilities |
| 86 | │ │ │ ├── tester.ts # Testing framework |
| 87 | │ │ │ ├── templates/ # Pre-built templates |
| 88 | │ │ │ └── types.ts # TypeScript definitions |
| 89 | │ │ └── __tests__/ # Test suite |
| 90 | │ └── docs/ # Documentation site (Next.js + Fumadocs) |
| 91 | ├── assets/ # Logo and branding |
| 92 | ├── CONTRIBUTING.md # Contributing guidelines |
| 93 | └── package.json # Monorepo configuration |
| 94 | ``` |
| 95 | |
| 96 | ## Tech Stack |
| 97 | |
| 98 | - **[TypeScript](https://www.typescriptlang.org/)** - Full type safety |
| 99 | - **[Zod](https://zod.dev/)** - Runtime validation |
| 100 | - **[Vercel AI SDK](https://sdk.vercel.ai/)** - AI model integration |
| 101 | - **[Bun](https://bun.sh/)** - Fast runtime and package manager |
| 102 | - **[Turbo](https://turbo.build/)** - Monorepo build system |
| 103 | - **[Biome](https://biomejs.dev/)** - Linting and formatting |
| 104 | |
| 105 | |
| 106 | |
| 107 | ## Development |
| 108 | |
| 109 | ### Setup |
| 110 | |
| 111 | ```bash |
| 112 | # Clone the repository |
| 113 | git clone https://github.com/galfrevn/promptsmith.git |
| 114 | cd promptsmith |
| 115 | |
| 116 | # Install dependencies |
| 117 | bun install |
| 118 | ``` |
| 119 | |
| 120 | ### Available Commands |
| 121 | |
| 122 | ```bash |
| 123 | # Development |
| 124 | bun dev # Start all apps in development mode |
| 125 | bun dev:docs # Start documentation site |