Template Schema
Templates are defined as JSON or YAML objects conforming to the following schema. This page documents every field with examples.
Full Schema
template-schema.json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": ["name", "version", "industry", "steps", "inputSchema"],
"properties": {
"name": {
"type": "string",
"description": "Human-readable template name",
"maxLength": 100
},
"description": {
"type": "string",
"description": "Detailed description of what the template does",
"maxLength": 500
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+$",
"description": "Semantic version (e.g., 1.0.0)"
},
"industry": {
"type": "string",
"enum": ["legal", "finance", "devops", "marketing", "healthcare", "custom"],
"description": "Industry category"
},
"tags": {
"type": "array",
"items": { "type": "string" },
"description": "Searchable tags"
},
"visibility": {
"type": "string",
"enum": ["private", "organization", "public"],
"default": "private"
},
"inputSchema": {
"type": "object",
"description": "JSON Schema defining required inputs",
"$ref": "https://json-schema.org/draft/2020-12/schema"
},
"outputSchema": {
"type": "object",
"description": "JSON Schema defining expected output format",
"$ref": "https://json-schema.org/draft/2020-12/schema"
},
"steps": {
"type": "array",
"items": { "$ref": "#/$defs/step" },
"minItems": 1,
"description": "Ordered list of workflow steps"
},
"defaults": {
"type": "object",
"properties": {
"model": { "type": "string" },
"queue": { "type": "string" },
"timeoutMs": { "type": "number" },
"maxTokens": { "type": "number" },
"temperature": { "type": "number" }
},
"description": "Default settings applied to all steps"
},
"hitl": {
"type": "object",
"properties": {
"requiredFor": {
"type": "array",
"items": { "type": "string" },
"description": "Step IDs that require HITL approval"
},
"confidenceThreshold": {
"type": "number",
"minimum": 0,
"maximum": 1,
"default": 0.85
},
"timeoutMs": {
"type": "number",
"default": 3600000
}
}
},
"metadata": {
"type": "object",
"additionalProperties": true,
"description": "Arbitrary metadata"
}
},
"$defs": {
"step": {
"type": "object",
"required": ["id", "prompt"],
"properties": {
"id": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*$",
"description": "Unique step identifier (lowercase, hyphens)"
},
"prompt": {
"type": "string",
"description": "Prompt template with {{variable}} placeholders"
},
"model": {
"type": "string",
"description": "Model override for this step"
},
"queue": {
"type": "string",
"description": "Queue override for this step"
},
"dependsOn": {
"type": "array",
"items": { "type": "string" },
"description": "Step IDs that must complete before this step"
},
"requiresApproval": {
"type": "boolean",
"default": false,
"description": "Whether this step requires HITL approval"
},
"condition": {
"type": "string",
"description": "Conditional expression to skip this step"
},
"timeoutMs": {
"type": "number",
"description": "Step-level timeout"
},
"retry": {
"type": "object",
"properties": {
"maxAttempts": { "type": "number", "default": 3 },
"backoffMs": { "type": "number", "default": 1000 }
}
},
"maxTokens": { "type": "number" },
"temperature": { "type": "number", "minimum": 0, "maximum": 1 },
"systemPrompt": { "type": "string" }
}
}
}
}YAML Example
contract-review-v1.yaml
name: Contract Review
description: >
Multi-step contract analysis pipeline that extracts clauses,
analyzes risks, checks compliance, and generates an executive report.
version: "1.0.0"
industry: legal
tags:
- contract
- risk-analysis
- compliance
visibility: public
inputSchema:
type: object
required:
- contract
properties:
contract:
type: string
description: Full text of the contract to review
jurisdiction:
type: string
description: Legal jurisdiction (e.g., "New York", "Delaware")
default: "United States"
reviewDepth:
type: string
enum: [quick, standard, comprehensive]
default: standard
defaults:
model: sonnet
queue: default
timeoutMs: 120000
temperature: 0.3
steps:
- id: extract
prompt: |
Extract all key clauses from the following contract.
Return a structured JSON array with fields:
clause_id, title, text, category, page_reference.
Contract:
{{input.contract}}
maxTokens: 4096
- id: analyze-risk
prompt: |
Analyze the following contract clauses for risk factors.
Consider the jurisdiction: {{input.jurisdiction}}.
Review depth: {{input.reviewDepth}}.
For each risk, provide:
- risk_id, clause_reference, severity (LOW/MEDIUM/HIGH/CRITICAL)
- description, potential_impact, mitigation_recommendation
Clauses:
{{extract.output}}
model: opus
dependsOn: [extract]
requiresApproval: true
maxTokens: 8192
- id: check-compliance
prompt: |
Review these contract clauses for regulatory compliance:
- GDPR data handling requirements
- Standard commercial contract terms
- {{input.jurisdiction}} specific regulations
Flag non-compliant clauses with severity and remediation steps.
Clauses:
{{extract.output}}
dependsOn: [extract]
maxTokens: 4096
- id: generate-report
prompt: |
Generate an executive summary report combining:
Risk Analysis:
{{analyze-risk.output}}
Compliance Check:
{{check-compliance.output}}
Include:
1. Overall risk score (1-10) with justification
2. Top 3 risks with mitigation recommendations
3. Compliance status (compliant / partially compliant / non-compliant)
4. Recommended negotiation points
5. Next steps for legal team
dependsOn: [analyze-risk, check-compliance]
maxTokens: 4096
hitl:
requiredFor: [analyze-risk]
confidenceThreshold: 0.85
timeoutMs: 3600000
metadata:
author: Matwal Legal Team
lastReviewed: "2026-02-15"
complianceStandards: [GDPR, UCC, SOX]Template Variables
Templates support {{variable}} placeholders that are resolved at execution time.
| Pattern | Source | Example |
|---|---|---|
{{input.fieldName}} | Deployment input | {{input.contract}} |
{{stepId.output}} | Output of a completed step | {{extract.output}} |
{{env.VARIABLE}} | Environment variable | {{env.API_KEY}} |
{{meta.templateName}} | Template metadata | {{meta.templateName}} |
{{meta.executionId}} | Current execution ID | {{meta.executionId}} |
⚠️
Variables referencing step outputs ({{stepId.output}}) can only be used in steps that declare dependsOn that step. The orchestrator validates the dependency graph at creation time.
Validation
The CLI validates templates before creation:
devteam templates validate --file my-template.yamlCommon validation errors:
| Error | Cause |
|---|---|
CIRCULAR_DEPENDENCY | Step A depends on B which depends on A |
MISSING_DEPENDENCY | dependsOn references a non-existent step ID |
INVALID_INPUT_REF | {{input.x}} references a field not in inputSchema |
UNREACHABLE_STEP | A step cannot be reached from the root of the DAG |
DUPLICATE_STEP_ID | Two steps share the same id |
Next Steps
- Legal Templates -- Browse legal industry templates
- Creating Templates -- Author custom templates