Complete technical specification for Instruction Template Specification v1.0
The Instruction Template Specification (ITS) defines a JSON-based format for creating templates that compile into AI instructions rather than static content. This enables content creators to build reusable templates with placeholders that generate dynamic, AI-powered content.
https://alexanderparker.github.io/instruction-template-specification/schema/v1.0/its-base-schema-v1.json
Property | Type | Description |
---|---|---|
version |
string | Template format version (semantic versioning) |
content |
array | Array of content elements (text, placeholders, conditionals) |
Property | Type | Description |
---|---|---|
extends |
array | Schema references for instruction type definitions (URLs or relative paths) |
metadata |
object | Template metadata (name, author, tags, etc.) |
customInstructionTypes |
object | Template-specific instruction type definitions |
compilerConfig |
object | Configuration for template compilation |
variables |
object | Template-level variables for reuse |
Static text content that appears as-is in the compiled template.
{
"type": "text",
"text": "Your static content here",
"id": "optional-identifier"
}
Placeholder that becomes an AI instruction in the compiled template.
{
"type": "placeholder",
"id": "unique-identifier",
"instructionType": "list",
"config": {
"description": "Content description for the AI",
"displayName": "Human-readable name",
// Additional type-specific configuration
}
}
Content that appears based on conditions. Conditions can include variables, literals, and expressions.
{
"type": "conditional",
"condition": "audienceLevel == 'technical'",
"content": [
// Content if condition is true
],
"else": [
// Content if condition is false (optional)
]
}
Variables are defined in the top-level variables
object and can store strings, numbers, booleans, objects, or arrays.
{
"variables": {
"tone": "professional",
"productType": "gaming headset",
"featureCount": 5,
"includeSpecs": true,
"brandInfo": {
"name": "TechCorp",
"tagline": "Innovation First"
}
}
}
Use ${variableName}
syntax to reference variables throughout your template:
{
"type": "text",
"text": "Welcome to ${brandInfo.name} - ${brandInfo.tagline}"
}
{
"type": "placeholder",
"instructionType": "list",
"config": {
"description": "List ${featureCount} key features of a ${productType}",
"format": "bullet_points",
"itemCount": "${featureCount}"
}
}
Type | Example | Access Method |
---|---|---|
String | "professional" |
${variableName} |
Number | 42 |
${variableName} |
Boolean | true |
${variableName} |
Object | {"name": "value"} |
${object.property} |
Array | ["item1", "item2"] |
${array[0]} |
Conditional elements use JavaScript-like expression syntax to control content inclusion:
==
, !=
>
, <
, >=
, <=
&&
(AND), ||
(OR), !
(NOT)in
(for arrays and strings)// Simple equality
"condition": "tone == 'professional'"
// Numeric comparison
"condition": "featureCount > 3"
// Boolean check
"condition": "includeSpecs == true"
// Compound conditions
"condition": "tone == 'professional' && featureCount > 3"
// Membership test
"condition": "productType in ['headset', 'speakers', 'microphone']"
// Object property access
"condition": "sections.intro == true"
// Negation
"condition": "!includeSpecs"
Reference: Standard Types Schema
Generates titles and headlines with customizable style and length.
{
"instructionType": "title",
"config": {
"description": "Create a catchy product headline",
"style": "headline", // headline, descriptive, catchy, formal, creative
"length": "short" // short, medium, long
}
}
Generates formatted lists with customizable styling and item counts.
{
"instructionType": "list",
"config": {
"description": "list 5 different citrus fruits",
"format": "bullet_points", // bullet_points, numbered, dashes, plain
"itemCount": 5 // optional
}
}
Generates paragraphs with specified tone and length.
{
"instructionType": "paragraph",
"config": {
"description": "Write about sustainable technology",
"tone": "professional", // formal, casual, enthusiastic, professional, friendly
"length": "medium" // short, medium, long
}
}
Generates tables with configurable formatting and dimensions.
{
"instructionType": "table",
"config": {
"description": "Compare technology features",
"format": "markdown", // markdown, plain_text, csv
"columns": 3, // optional
"rows": 4 // optional
}
}
Generates code snippets with syntax highlighting.
{
"instructionType": "code_block",
"config": {
"description": "Create a Python function that sorts a list",
"language": "python" // javascript, python, java, html, css, sql, bash, generic
}
}
Generates conversations between multiple participants.
{
"instructionType": "dialogue",
"config": {
"description": "Conversation about project planning",
"participantCount": 2, // 2-6
"style": "casual" // casual, formal, dramatic, humorous
}
}
Generates relevant quotes with optional attribution.
{
"instructionType": "quote",
"config": {
"description": "Quote about innovation and creativity",
"includeAttribution": true // include attribution if true
}
}
Generates summaries of varying lengths and detail.
{
"instructionType": "summary",
"config": {
"description": "Summarize the key benefits of renewable energy",
"length": "standard" // brief, standard, detailed
}
}
Generates descriptive text for images with different styles.
{
"instructionType": "image_description",
"config": {
"description": "Describe a futuristic city skyline",
"style": "photorealistic" // photorealistic, artistic, technical
}
}
Templates can import instruction type definitions from external schemas using the extends
property. This enables sharing and reusing instruction types across templates.
{
"$schema": "https://alexanderparker.github.io/.../its-base-schema-v1.json",
"version": "1.0.0",
"extends": [
"https://alexanderparker.github.io/.../its-standard-types-v1.json",
"./my-local-types.json",
"https://example.com/custom-types.json"
],
"content": [...]
}
When multiple schemas define the same instruction type, the entire definition from the later schema replaces the earlier one. No partial merging occurs.
Instruction types are resolved in this order (highest to lowest precedence):
customInstructionTypes
defined in the templateextends
arrayextends
array{
"extends": [
"schema-a.json", // Lowest precedence
"schema-b.json", // Overrides schema-a
"schema-c.json" // Overrides schema-b and schema-a
],
"customInstructionTypes": {
"mytype": {...} // Highest precedence, overrides all
}
}
Extended schemas must be compatible with the template's base specification version. The version is determined by the $schema
reference in the template.
Extended schemas must follow this structure and be validated against the Type Extension Schema:
{
"$schema": "https://alexanderparker.github.io/.../its-type-extension-schema-v1.json",
"title": "My Custom Types",
"description": "Description of these types",
"version": "1.0.0",
"instructionTypes": {
"typeName": {
"template": "<>",
"description": "What this instruction type does",
"configSchema": {
"type": "object",
"properties": {
// Configuration property definitions
}
}
}
}
}
You can define custom instruction types for specific use cases within your template:
{
"customInstructionTypes": {
"my_custom_type": {
"template": "<>",
"description": "Description of what this type does",
"configSchema": {
"type": "object",
"properties": {
"customParam": {
"type": "string",
"enum": ["option1", "option2"],
"default": "option1"
}
}
}
}
}
}
Custom instruction types defined in the template have the highest precedence and will override any types with the same name from extended schemas.
Templates compile into AI prompts following this process:
${variable}
references with valuesThe ITS Compiler Python provides a complete reference implementation of the compilation process. See the Compiler Implementation Guide for detailed requirements when building your own compiler.
To prevent parsing conflicts when user descriptions contain quotes, brackets, or other special characters, ITS uses a robust escaping system:
User content wrapper: ([{<USER_CONTENT>}])
Why this pattern:
Handles edge cases like:
"description": "Create code like {\"key\": \"value\"} with \"quotes\" and <<brackets>>"
Safely compiles to:
([{<Create code like {"key": "value"} with "quotes" and <<brackets>>>}])
Input Template:
{
"content": [
{"type": "text", "text": "Here are some fruits:\n"},
{
"type": "placeholder",
"instructionType": "list",
"config": {
"description": "list 5 citrus fruits",
"format": "bullet_points"
}
}
]
}
Compiled Output:
INTRODUCTION
You are an AI designed to convert content templates into actual content. Respond only with the transformed content.
INSTRUCTIONS
1. Replace each placeholder marked with << >> with generated content
2. The user's content request is wrapped in ([{< >}]) to distinguish it from instructions
3. Follow the format requirements specified after each user prompt
4. Maintain the existing structure and formatting of the template
5. Only replace the placeholders - do not modify any other text
6. Generate content that matches the tone and style requested
7. Respond only with the transformed content - do not include any explanations or additional text
TEMPLATE
Here are some fruits:
<<Replace this placeholder with a list using this user prompt: ([{<list 5 citrus fruits>}]). Format requirements: Use bullet_points formatting with each item on a new line.>>