---
title: "prompts.chat Prompt Builder"
description: "A comprehensive developer toolkit for building, validating, and parsing AI prompts. Create structured prompts for chat models, image generators, video AI, and music generation with fluent, type-safe APIs."
type: skill
canonical_url: https://claudary.paisolsolutions.com/skills/readme-63
source: "Claudary"
difficulty: intermediate
author: "Claude Code Knowledge Pack"
date: 2026-07-10T11:36:48.879Z
license: CC-BY-4.0
attribution: "prompts.chat Prompt Builder — Claudary (https://claudary.paisolsolutions.com/skills/readme-63)"
---

# prompts.chat Prompt Builder
A comprehensive developer toolkit for building, validating, and parsing AI prompts. Create structured prompts for chat models, image generators, video AI, and music generation with fluent, type-safe APIs.

## Overview

# prompts.chat Prompt Builder

A comprehensive developer toolkit for building, validating, and parsing AI prompts. Create structured prompts for chat models, image generators, video AI, and music generation with fluent, type-safe APIs.

[![Playground](https://img.shields.io/badge/Playground-prompts.chat%2Ftyped--prompts--editor-blue)](https://prompts.chat/typed-prompts-editor)

## Reason

Building effective AI prompts is challenging. Developers often struggle with:

- **Inconsistent prompt structure** — Different team members write prompts differently, leading to unpredictable AI responses
- **No type safety** — Typos and missing fields go unnoticed until runtime
- **Repetitive boilerplate** — Writing the same patterns over and over for common use cases
- **Hard to maintain** — Prompts scattered across codebases without standardization
- **Multi-modal complexity** — Each AI platform (chat, image, video, audio) has different requirements

`prompts.chat` solves these problems by providing a fluent, type-safe API that guides you through prompt construction with autocomplete, validation, and pre-built templates for common patterns.

## Installation

```bash
npm install prompts.chat
```

## CLI

### Create a New Instance

Scaffold a new prompts.chat deployment with a single command:

```bash
npx prompts.chat new my-prompt-library
```

This will:
1. Clone a clean copy of the repository (removes `.github`, `.claude`, `packages/`, dev scripts)
2. Install dependencies
3. Launch the interactive setup wizard to configure branding, theme, auth, and features

### Interactive Prompt Browser

Browse and search prompts from your terminal:

```bash
npx prompts.chat
```

**Navigation:**
- `↑/↓` or `j/k` — Navigate list
- `Enter` — Select prompt
- `/` — Search prompts
- `n/p` — Next/Previous page
- `r` — Run prompt (open in ChatGPT, Claude, etc.)
- `c` — Copy prompt (with variable filling)
- `C` — Copy raw prompt
- `o` — Open in browser
- `b` — Go back
- `q` — Quit

---

## Quick Start

```typescript
import { builder, chat, image, audio, variables, quality } from 'prompts.chat';

// Build structured text prompts
const prompt = builder()
  .role("Senior TypeScript Developer")
  .task("Review the following code for bugs and improvements")
  .constraints(["Be concise", "Focus on critical issues"])
  .variable("code", { required: true })
  .build();

// Build chat prompts with full control
const chatPrompt = chat()
  .role("expert code reviewer")
  .tone("professional")
  .expertise("TypeScript", "React", "Node.js")
  .task("Review code and provide actionable feedback")
  .stepByStep()
  .json()
  .build();

// Build image generation prompts
const imagePrompt = image()
  .subject("a cyberpunk samurai")
  .environment("neon-lit Tokyo streets")
  .shot("medium")
  .lens("35mm")
  .lightingType("rim")
  .medium("cinematic")
  .build();

// Build music generation prompts  
const musicPrompt = audio()
  .genre("electronic")
  .mood("energetic")
  .bpm(128)
  .instruments(["synthesizer", "drums", "bass"])
  .build();

// Normalize variable formats
const normalized = variables.normalize("Hello {{name}}, you are [ROLE]");
// → "Hello ${name}, you are ${role}"

// Check quality locally (no API needed)
const result = quality.check("Act as a developer...");
console.log(result.score); // 0.85
```

---

## Modules

- [Variables](#-variables) — Variable detection and normalization
- [Similarity](#-similarity) — Content deduplication
- [Builder](#️-builder) — Structured text prompts
- [Chat Builder](#-chat-builder) — Chat/conversational prompts
- [Image Builder](#-image-builder) — Image generation prompts
- [Video Builder](#-video-builder) — Video generation prompts
- [Audio Builder](#-audio-builder) — Music/audio generation prompts
- [Quality](#-quality) — Prompt validation
- [Parser](#-parser) — Multi-format parsing

---

## 🔧 Variables

Universal variable detection and normalization across different formats.

```typescript
import { variables } from 'prompts.chat';

// Detect variables in any format
const detected = variables.detect("Hello {{name}}, welcome to [COMPANY]");
// → [{ name: "name", pattern: "double_curly" }, { name: "COMPANY", pattern: "single_bracket" }]

// Normalize all formats to ${var}
const normalized = variables.normalize("Hello {{name}}, you are [ROLE]");
// → "Hello ${name}, you are ${role}"

// Extract variables from ${var} format
const vars = variables.extractVariables("Hello ${name:World}");
// → [{ name: "name", defaultValue: "World" }]

// Compile template with values
const result = variables.compile("Hello ${name:World}", { name: "Developer" });
// → "Hello Developer"

// Get pattern descriptions
variables.getPatternDescription("double_bracket"); // → "[[...]]"
```

### Supported Formats

| Format | Example | Pattern Name |
|--------|---------|--------------|
| `${var}` | `${name}` | `dollar_curly` |
| `${var:default}` | `${name:World}` | `dollar_curly` |
| `{{var}}` | `{{name}}` | `double_curly` |
| `[[var]]` | `[[name]]` | `double_bracket` |
| `[VAR]` | `[NAME]` | `single_bracket` |
| `{VAR}` | `{NAME}` | `single_curly` |
| `<VAR>` | `<NAME>` | `angle_bracket` |
| `%VAR%` | `%NAME%` | `percent` |

### API Reference

| Function | Description |
|----------|-------------|
| `detect(text)` | Detect variables in any format |
| `normalize(text)` | Convert all formats to `${var}` |
| `extractVariables(text)` | Extract from `${var}` format |
| `compile(text, values, options?)` | Replace variables with values |
| `convertToSupportedFormat(variable)` | Convert a single variable |
| `getPatternDescription(pattern)` | Get human-readable pattern |

---

## 📊 Similarity

Content similarity detection for deduplication using Jaccard and n-gram algorithms.

```typescript
import { similarity } from 'prompts.chat';

// Calculate similarity score (0-1)
const score = similarity.calculate(prompt1, prompt2);
// → 0.87

// Check if prompts are duplicates (default threshold: 0.85)
const isDupe = similarity.isDuplicate(prompt1, prompt2, 0.85);
// → true

// Find groups of duplicate prompts
const groups = similarity.findDuplicates(prompts, 0.85);
// → [[prompt1, prompt3], [prompt2, prompt5]]

// Deduplicate an array (keeps first occurrence)
const unique = similarity.deduplicate(prompts, 0.85);

// Get content fingerprint for indexing
const fingerprint = similarity.getContentFingerprint(prompt);

// Normalize content for comparison
const normalized = similarity.normalizeContent(text);
```

### API Reference

| Function | Description |
|----------|-------------|
| `calculate(content1, content2)` | Calculate similarity score (0-1) |
| `isDuplicate(content1, content2, threshold?)` | Check if similar (default 0.85) |
| `findDuplicates(prompts, threshold?)` | Find groups of duplicates |
| `deduplicate(prompts, threshold?)` | Remove duplicates |
| `normalizeContent(content)` | Normalize for comparison |
| `getContentFingerprint(content)` | Get fingerprint for indexing |

---

## 🏗️ Builder

Fluent DSL for creating structured text prompts.

```typescript
import { builder, fromPrompt, templates } from 'prompts.chat';

// Build a custom prompt
const prompt = builder()
  .role("Senior Developer")
  .context("You are helping review a React application")
  .task("Analyze the code for performance issues")
  .constraints([
    "Be concise",
    "Focus on critical issues",
    "Suggest fixes with code examples"
  ])
  .output("JSON with { issues: [], suggestions: [] }")
  .variable("code", { required: true, description: "Code to review" })
  .example("const x = 1;", '{ "issues": [], "suggestions": [] }')
  .section("Additional Notes", "Consider React 18 best practices")
  .build();

console.log(prompt.content);
console.log(prompt.variables);
console.log(prompt.metadata);

// Create from existing prompt
const existing = fromPrompt("You are a helpful assistant...").build();
```

### Builder Methods

| Method | Description |
|--------|-------------|
| `.role(role)` | Set AI persona (alias: `.persona()`) |
| `.context(context)` | Set background info (alias: `.background()`) |
| `.task(task)` | Set main instruction (alias: `.instruction()`) |
| `.constraints(list)` | Add multiple constraints (alias: `.rules()`) |
| `.constraint(text)` | Add single constraint |
| `.output(format)` | Set output format (alias: `.format()`) |
| `.example(input, output)` | Add input/output example |
| `.examples(list)` | Add multiple examples |
| `.variable(name, options?)` | Define a variable |
| `.section(title, content)` | Add custom section |
| `.raw(content)` | Set raw content |
| `.build()` | Build the prompt |
| `.toString()` | Get content string |

### Pre-built Templates

```typescript
import { templates } from 'prompts.chat';

// Code review template
const review = templates.codeReview({ 
  language: "TypeScript",
  focus: ["performance", "security"]
});

// Translation template
const translate = templates.translation("English", "Spanish");

// Summarization template
const summary = templates.summarize({ 
  maxLength: 100, 
  style: "bullet" 
});

// Q&A template
const qa = templates.qa("You are answering questions about React.");
```

---

## 💬 Chat Builder

Comprehensive model-agnostic builder for conversational AI prompts. Works with GPT-4, Claude, Gemini, Llama, and any chat model.

### Quick Start

```typescript
import { chat } from 'prompts.chat';

const prompt = chat()
  .role("helpful coding assistant")
  .context("Building a React application")
  .task("Explain async/await in JavaScript")
  .stepByStep()
  .detailed()
  .build();

console.log(prompt.systemPrompt);
console.log(prompt.messages);
```

### Full Example

```typescript
import { chat } from 'prompts.chat';

const prompt = chat()
  // ━━━ Persona ━━━
  .persona({
    name: "Alex",
    role: "senior software architect",
    tone: ["professional", "analytical"],
    expertise: ["system-design", "microservices", "cloud-architecture"],
    personality: ["patient", "thorough", "pragmatic"],
    background: "15 years of experience at FAANG companies",
    language: "English",
    verbosity: "detailed"
  })
  .role("expert code reviewer")                    // Override role
  .tone(["technical", "concise"])                  // Override tone(s)
  .expertise(["coding", "engineering"])            // Override expertise
  .personality(["direct", "helpful"])              // Override personality
  .background("Specialized in distributed systems")
  .speakAs("CodeReviewer")                         // Set a name
  .responseLanguage("English")                     // Response language
  
  // ━━━ Context ━━━
  .context({
    background: "Reviewing a pull request for an e-commerce platform",
    domain: "software engineering",
    audience: "mid-level developers",
    purpose: "improve code quality and maintainability",
    constraints: ["Follow team coding standards", "Consider performance"],
    assumptions: ["Team uses TypeScript", "Project uses React"],
    knowledge: ["Existing codebase uses Redux", "Team prefers functional components"]
  })
  .domain("web development")                       // Set knowledge domain
  .audience("junior developers")                   // Target audience
  .purpose("educational code review")              // Purpose of interaction
  .constraints(["Be constructive", "Explain why"]) // Add constraints
  .constraint("Focus on security issues")          // Single constraint
  .assumptions(["Code compiles successfully"])     // Set assumptions
  .knowledge(["Using React 18", "Node.js backend"]) // Known facts
  
  // ━━━ Task ━━━
  .task({
    instruction: "Review the submitted code and provide actionable feedback",
    steps: [
      "Analyze code structure and organization",
      "Check for potential bugs and edge cases",
      "Evaluate performance implications",
      "Suggest improvements with examples"
    ],
    deliverables: ["Summary of issues", "Prioritized recommendations", "Code examples"],
    criteria: ["Feedback is specific", "Examples are provided", "Tone is constructive"],
    antiPatterns: ["Vague criticism", "No examples", "Harsh language"],
    priority: "accuracy"
  })
  .instruction("Review this React component")      // Main instruction
  .steps([                                         // Override steps
    "Check hooks usage",
    "Verify prop types",
    "Review state management"
  ])
  .deliverables(["Issue list", "Fixed code"])      // Expected deliverables
  .criteria(["Clear explanations"])                // Success criteria
  .avoid(["Being overly critical", "Ignoring context"])  // Anti-patterns
  .priority("thoroughness")                        // accuracy | speed | creativity | thoroughness
  
  // ━━━ Examples (Few-Shot) ━━━
  .example(
    "const [data, setData] = useState()",
    "Consider adding a type parameter: useState<DataType>()",
    "TypeScript generics improve type safety"
  )
  .examples([
    { input: "useEffect(() => { fetch() })", output: "Add cleanup function for async operations" },
    { input: "if(data == null)", output: "Use strict equality (===) for null checks" }
  ])
  .fewShot([                                       // Alternative few-shot syntax
    { input: "var x = 1", output: "Use const or let instead of var" },
    { input: "any[]", output: "Define specific array types" }
  ])
  
  // ━━━ Output Format ━━━
  .output({
    format: { type: "markdown" },
    length: "detailed",
    style: "mixed",
    includeExamples: true,
    includeExplanation: true
  })
  .outputFormat("markdown")                        // text | json | markdown | code | table
  .json()                                          // Shortcut for JSON output
  .jsonSchema("CodeReview", {                      // JSON with schema
    type: "object",
    properties: {
      issues: { type: "array" },
      suggestions: { type: "array" }
    }
  })
  .markdown()                                      // Markdown output
  .code("typescript")                              // Code output with language
  .table()                                         // Table output
  
  // ━━━ Output Length ━━━
  .length("detailed")                              // brief | moderate | detailed | comprehensive | exhaustive
  .brief()                                         // Shortcut for brief
  .moderate()                                      // Shortcut for moderate
  .detailed()                                      // Shortcut for detailed
  .comprehensive()                                 // Shortcut for comprehensive
  .exhaustive()                                    // Shortcut for exhaustive
  
  // ━━━ Output Style ━━━
  .style("mixed")                                  // prose | bullet-points | numbered-list | table | code | mixed | qa | dialogue
  
  // ━━━ Output Includes ━━━
  .withExamples()                                  // Include examples in response
  .withExplanation()                               // Include explanations
  .withSources()                                   // Ci

---

Source: [Claudary](https://claudary.paisolsolutions.com/skills/readme-63) · https://claudary.paisolsolutions.com
