---
title: "API Reference"
description: "> Auto-generated from TypeScript source files"
type: skill
canonical_url: https://claudary.paisolsolutions.com/skills/api
source: "Claudary"
difficulty: intermediate
author: "Claude Code Knowledge Pack"
date: 2026-07-10T11:07:07.924Z
license: CC-BY-4.0
attribution: "API Reference — Claudary (https://claudary.paisolsolutions.com/skills/api)"
---

# API Reference
> Auto-generated from TypeScript source files

## Overview

# API Reference

> Auto-generated from TypeScript source files

## Table of Contents

- [variables/index](#variables/index)
  - [detectVariables](#detectvariables)
  - [convertToSupportedFormat](#converttosupportedformat)
  - [convertAllVariables](#convertallvariables)
  - [getPatternDescription](#getpatterndescription)
  - [extractVariables](#extractvariables)
  - [compile](#compile)
- [similarity/index](#similarity/index)
  - [normalizeContent](#normalizecontent)
  - [calculateSimilarity](#calculatesimilarity)
  - [isSimilarContent](#issimilarcontent)
  - [getContentFingerprint](#getcontentfingerprint)
  - [findDuplicates](#findduplicates)
  - [deduplicate](#deduplicate)
- [quality/index](#quality/index)
  - [check](#check)
  - [validate](#validate)
  - [isValid](#isvalid)
  - [getSuggestions](#getsuggestions)
- [parser/index](#parser/index)
  - [parse](#parse)
  - [toYaml](#toyaml)
  - [toJson](#tojson)
  - [getSystemPrompt](#getsystemprompt)
  - [interpolate](#interpolate)
- [builder/index](#builder/index)
  - [PromptBuilder](#promptbuilder)
  - [builder](#builder)
  - [fromPrompt](#fromprompt)
- [builder/chat](#builder/chat)
  - [ChatPromptBuilder](#chatpromptbuilder)
  - [chat](#chat)
- [builder/media](#builder/media)
  - [ImagePromptBuilder](#imagepromptbuilder)
  - [image](#image)
- [builder/video](#builder/video)
  - [VideoPromptBuilder](#videopromptbuilder)
  - [video](#video)
- [builder/audio](#builder/audio)
  - [AudioPromptBuilder](#audiopromptbuilder)
  - [audio](#audio)

---

## variables/index

Variable Detection Utility
Detects common variable-like patterns in text that could be converted
to our supported format: ${variableName} or ${variableName:default}

### Types

#### `VariablePattern`

```typescript
type VariablePattern = | "double_bracket"      // [[name]] or [[ name ]]
  | "double_curly"        // {{name}} or {{ name }}
  | "single_bracket"      // [NAME] or [name]
  | "single_curly"        // {NAME} or {name}
  | "angle_bracket"       // <NAME> or <name>
  | "percent"             // %NAME% or %name%
  | "dollar_curly"
```

### Interfaces

#### `DetectedVariable`

Variable Detection Utility
Detects common variable-like patterns in text that could be converted
to our supported format: ${variableName} or ${variableName:default}

| Property | Type | Description |
|----------|------|-------------|
| `original` | `string` | - |
| `name` | `string` | - |
| `defaultValue` | `string` | - |
| `pattern` | `VariablePattern` | - |
| `startIndex` | `number` | - |
| `endIndex` | `number` | - |

### Functions

#### `detectVariables()`

Detect variable-like patterns in text
Returns detected variables that are NOT in our supported format

```typescript
detectVariables(text: string): DetectedVariable[]
```

**Parameters:**

- `text`: `string`

**Returns:** `DetectedVariable[]`

#### `convertToSupportedFormat()`

Convert a detected variable to our supported format

```typescript
convertToSupportedFormat(variable: DetectedVariable): string
```

**Parameters:**

- `variable`: `DetectedVariable`

**Returns:** `string`

#### `convertAllVariables()`

Convert all detected variables in text to our supported format

```typescript
convertAllVariables(text: string): string
```

**Parameters:**

- `text`: `string`

**Returns:** `string`

#### `getPatternDescription()`

Get a human-readable pattern description

```typescript
getPatternDescription(pattern: VariablePattern): string
```

**Parameters:**

- `pattern`: `VariablePattern`

**Returns:** `string`

#### `extractVariables()`

Extract variables from our supported ${var} or ${var:default} format

```typescript
extractVariables(text: string): Array<{ name: string; defaultValue?: string }>
```

**Parameters:**

- `text`: `string`

**Returns:** `Array<{ name: string; defaultValue?: string }>`

#### `compile()`

Compile a prompt template with variable values

```typescript
compile(template: string, values: Record<string, string>, options?: { useDefaults?: boolean }): string
```

**Parameters:**

- `template`: `string`
- `values`: `Record<string, string>`
- `options`: `{ useDefaults?: boolean }` (optional) = `{}`

**Returns:** `string`

### Constants

#### `normalize`

Alias for convertAllVariables - normalizes all variable formats to ${var}

```typescript
normalize = convertAllVariables
```

#### `detect`

Alias for detectVariables

```typescript
detect = detectVariables
```

---

## similarity/index

Content similarity utilities for duplicate detection

### Functions

#### `normalizeContent()`

Content similarity utilities for duplicate detection

```typescript
normalizeContent(content: string): string
```

**Parameters:**

- `content`: `string`

**Returns:** `string`

#### `calculateSimilarity()`

Combined similarity score using multiple algorithms
Returns a value between 0 (completely different) and 1 (identical)

```typescript
calculateSimilarity(content1: string, content2: string): number
```

**Parameters:**

- `content1`: `string`
- `content2`: `string`

**Returns:** `number`

#### `isSimilarContent()`

Check if two contents are similar enough to be considered duplicates
Default threshold is 0.85 (85% similar)

```typescript
isSimilarContent(content1: string, content2: string, threshold?: number): boolean
```

**Parameters:**

- `content1`: `string`
- `content2`: `string`
- `threshold`: `number` (optional) = `0.85`

**Returns:** `boolean`

#### `getContentFingerprint()`

Get normalized content hash for database indexing/comparison
This is a simple hash for quick lookups before full similarity check

```typescript
getContentFingerprint(content: string): string
```

**Parameters:**

- `content`: `string`

**Returns:** `string`

#### `findDuplicates()`

Find duplicates in an array of prompts
Returns groups of similar prompts

```typescript
findDuplicates(prompts: T[], threshold?: number): T[][]
```

**Parameters:**

- `prompts`: `T[]`
- `threshold`: `number` (optional) = `0.85`

**Returns:** `T[][]`

#### `deduplicate()`

Deduplicate an array of prompts, keeping the first occurrence

```typescript
deduplicate(prompts: T[], threshold?: number): T[]
```

**Parameters:**

- `prompts`: `T[]`
- `threshold`: `number` (optional) = `0.85`

**Returns:** `T[]`

### Constants

#### `calculate`

Alias for calculateSimilarity

```typescript
calculate = calculateSimilarity
```

#### `isDuplicate`

Alias for isSimilarContent

```typescript
isDuplicate = isSimilarContent
```

---

## quality/index

Prompt Quality Checker - Local validation for prompt quality

@example
```ts
import { quality } from 'prompts.chat';

const result = quality.check("Act as a developer...");
console.log(result.score); // 0.85
console.log(result.issues); // []
```

### Interfaces

#### `QualityIssue`

Prompt Quality Checker - Local validation for prompt quality

| Property | Type | Description |
|----------|------|-------------|
| `type` | `'error' | 'warning' | 'suggestion'` | - |
| `code` | `string` | - |
| `message` | `string` | - |
| `position` | `{ start: number; end: number }` | - |

#### `QualityResult`

| Property | Type | Description |
|----------|------|-------------|
| `valid` | `boolean` | - |
| `score` | `number` | - |
| `issues` | `QualityIssue[]` | - |
| `stats` | `unknown` | - |

### Functions

#### `check()`

Check prompt quality locally (no API needed)

```typescript
check(prompt: string): QualityResult
```

**Parameters:**

- `prompt`: `string`

**Returns:** `QualityResult`

#### `validate()`

Validate a prompt and throw if invalid

```typescript
validate(prompt: string): void
```

**Parameters:**

- `prompt`: `string`

#### `isValid()`

Check if a prompt is valid

```typescript
isValid(prompt: string): boolean
```

**Parameters:**

- `prompt`: `string`

**Returns:** `boolean`

#### `getSuggestions()`

Get suggestions for improving a prompt

```typescript
getSuggestions(prompt: string): string[]
```

**Parameters:**

- `prompt`: `string`

**Returns:** `string[]`

---

## parser/index

Prompt Parser - Parse and load prompt files in various formats

Supports:
- .prompt.yml / .prompt.yaml (YAML format)
- .prompt.json (JSON format)
- .prompt.md (Markdown with frontmatter)
- .txt (Plain text)

@example
```ts
import { parser } from 'prompts.chat';

const prompt = parser.parse(`
name: Code Review
messages:
  - role: system
    content: You are a code reviewer.
`);
```

### Interfaces

#### `PromptMessage`

Prompt Parser - Parse and load prompt files in various formats

Supports:
- .prompt.yml / .prompt.yaml (YAML format)
- .prompt.json (JSON format)
- .prompt.md (Markdown with frontmatter)
- .txt (Plain text)

| Property | Type | Description |
|----------|------|-------------|
| `role` | `'system' | 'user' | 'assistant'` | - |
| `content` | `string` | - |

#### `ParsedPrompt`

| Property | Type | Description |
|----------|------|-------------|
| `name` | `string` | - |
| `description` | `string` | - |
| `model` | `string` | - |
| `modelParameters` | `unknown` | - |
| `messages` | `PromptMessage[]` | - |
| `variables` | `unknown` | - |
| `metadata` | `Record<string, unknown>` | - |

### Functions

#### `parse()`

Parse prompt content in various formats

```typescript
parse(content: string, format?: 'yaml' | 'json' | 'markdown' | 'text'): ParsedPrompt
```

**Parameters:**

- `content`: `string`
- `format`: `'yaml' | 'json' | 'markdown' | 'text'` (optional)

**Returns:** `ParsedPrompt`

#### `toYaml()`

Serialize a ParsedPrompt to YAML format

```typescript
toYaml(prompt: ParsedPrompt): string
```

**Parameters:**

- `prompt`: `ParsedPrompt`

**Returns:** `string`

#### `toJson()`

Serialize a ParsedPrompt to JSON format

```typescript
toJson(prompt: ParsedPrompt, pretty?: boolean): string
```

**Parameters:**

- `prompt`: `ParsedPrompt`
- `pretty`: `boolean` (optional) = `true`

**Returns:** `string`

#### `getSystemPrompt()`

Get the system message content from a parsed prompt

```typescript
getSystemPrompt(prompt: ParsedPrompt): string
```

**Parameters:**

- `prompt`: `ParsedPrompt`

**Returns:** `string`

#### `interpolate()`

Interpolate variables in a prompt

```typescript
interpolate(prompt: ParsedPrompt, values: Record<string, string>): ParsedPrompt
```

**Parameters:**

- `prompt`: `ParsedPrompt`
- `values`: `Record<string, string>`

**Returns:** `ParsedPrompt`

---

## builder/index

Prompt Builder - A fluent DSL for creating structured prompts

@example
```ts
import { builder } from 'prompts.chat';

const prompt = builder()
  .role("Senior TypeScript Developer")
  .context("You are helping review code")
  .task("Analyze the following code for bugs")
  .constraints(["Be concise", "Focus on critical issues"])
  .output("JSON with { bugs: [], suggestions: [] }")
  .variable("code", { required: true })
  .build();
```

### Interfaces

#### `PromptVariable`

Prompt Builder - A fluent DSL for creating structured prompts

| Property | Type | Description |
|----------|------|-------------|
| `name` | `string` | - |
| `description` | `string` | - |
| `required` | `boolean` | - |
| `defaultValue` | `string` | - |

#### `BuiltPrompt`

| Property | Type | Description |
|----------|------|-------------|
| `content` | `string` | - |
| `variables` | `PromptVariable[]` | - |
| `metadata` | `unknown` | - |

### Classes

#### `PromptBuilder`

**Methods:**

| Method | Description |
|--------|-------------|
| `role(role: string): this` | Set the role/persona for the AI |
| `persona(persona: string): this` | Alias for role() |
| `context(context: string): this` | Set the context/background information |
| `background(background: string): this` | Alias for context() |
| `task(task: string): this` | Set the main task/instruction |
| `instruction(instruction: string): this` | Alias for task() |
| `constraints(constraints: string[]): this` | Add constraints/rules the AI should follow |
| `constraint(constraint: string): this` | Add a single constraint |
| `rules(rules: string[]): this` | Alias for constraints() |
| `output(format: string): this` | Set the expected output format |
| `format(format: string): this` | Alias for output() |
| `example(input: string, output: string): this` | Add an example input/output pair |
| `examples(examples: Array<{ input: string; output: string }>): this` | Add multiple examples |
| `variable(name: string, options?: { description?: string; required?: boolean; defaultValue?: string }): this` | Define a variable placeholder |
| `section(title: string, content: string): this` | Add a custom section |
| `raw(content: string): this` | Set raw content (bypasses structured building) |
| `build(): BuiltPrompt` | Build the final prompt |
| `toString(): string` | Build and return only the content string |

##### `role()`

Set the role/persona for the AI

```typescript
role(role: string): this
```

**Parameters:**

- `role`: `string`

**Returns:** `this`

##### `persona()`

Alias for role()

```typescript
persona(persona: string): this
```

**Parameters:**

- `persona`: `string`

**Returns:** `this`

##### `context()`

Set the context/background information

```typescript
context(context: string): this
```

**Parameters:**

- `context`: `string`

**Returns:** `this`

##### `background()`

Alias for context()

```typescript
background(background: string): this
```

**Parameters:**

- `background`: `string`

**Returns:** `this`

##### `task()`

Set the main task/instruction

```typescript
task(task: string): this
```

**Parameters:**

- `task`: `string`

**Returns:** `this`

##### `instruction()`

Alias for task()

```typescript
instruction(instruction: string): this
```

**Parameters:**

- `instruction`: `string`

**Returns:** `this`

##### `constraints()`

Add constraints/rules the AI should follow

```typescript
constraints(constraints: string[]): this
```

**Parameters:**

- `constraints`: `string[]`

**Returns:** `this`

##### `constraint()`

Add a single constraint

```typescript
constraint(constraint: string): this
```

**Parameters:**

- `constraint`: `string`

**Returns:** `this`

##### `rules()`

Alias for constraints()

```typescript
rules(rules: string[]): this
```

**Parameters:**

- `rules`: `string[]`

**Returns:** `this`

##### `output()`

Set the expected output format

```typescript
output(format: string): this
```

**Parameters:**

- `format`: `string`

**Returns:** `this`

##### `format()`

Alias for output()

```typescript
format(format: string): this
```

**Parameters:**

- `format`: `string`

**Returns:** `this`

##### `example()`

Add an example input/output pair

```typescript
example(input: string, output: string): this
```

**Parameters:**

- `input`: `string`
- `output`: `string`

**Returns:** `this`

##### `examples()`

Add multiple examples

```typescript
examples(examples: Array<{ input: string; output: string }>): this
```

**Parameters:**

- `examples`: `Array<{ input: string; output: string }>`

**Returns:** `this`

##### `variable()`

Define a variable placeholder

```typescript
variable(name: string, options?: { description?: string; required?: boolean

---

Source: [Claudary](https://claudary.paisolsolutions.com/skills/api) · https://claudary.paisolsolutions.com
