Skip to content

Commit c766d8c

Browse files
docs: add validated prompt schema examples library
1 parent 0d04d2b commit c766d8c

12 files changed

Lines changed: 341 additions & 0 deletions

examples/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# PromptOpsKit Example Library
2+
3+
This folder contains a small, validation-safe set of prompt examples that demonstrate the main PromptOpsKit features and front matter schema.
4+
5+
## Layout
6+
7+
- `prompts/defaults.md` — folder defaults (provider/model/metadata/system instructions)
8+
- `prompts/shared/` — reusable includes used by composition examples
9+
- `prompts/*.md` — standalone examples with a `# Notes` section
10+
11+
## Validate all examples
12+
13+
```bash
14+
npm run build
15+
node dist/cli/index.js validate examples/prompts
16+
```
17+
18+
## Optional: inspect or render a single example
19+
20+
```bash
21+
node dist/cli/index.js inspect examples/prompts/03-composition-includes.md
22+
node dist/cli/index.js render examples/prompts/05-response-schema-json.md --json
23+
```

examples/prompts/01-basic.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
id: examples/basic
3+
schema_version: 1
4+
description: Minimal prompt with variable interpolation.
5+
context:
6+
inputs:
7+
- name: name
8+
non_empty: true
9+
reject_secrets: true
10+
---
11+
12+
# Prompt template
13+
14+
Hello {{ name }}! Give a one-sentence welcome.
15+
16+
# Notes
17+
18+
This is the smallest useful prompt example:
19+
- Inherits `provider` and `model` from `defaults.md`.
20+
- Declares a single input used in interpolation.
21+
- Uses a single prompt template section.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
id: examples/context-validation
3+
schema_version: 1
4+
context:
5+
history:
6+
max_items: 10
7+
inputs:
8+
- name: user_message
9+
max_size: 2000
10+
non_empty:
11+
return_message: "Please enter your question."
12+
reject_secrets:
13+
return_message: "Please remove credentials before sending your message."
14+
deny_regex:
15+
pattern: '(?:ignore|forget)\s+all\s+instructions'
16+
flags: i
17+
return_message: "Please avoid prompt-injection text."
18+
- name: app_context
19+
max_size: 400
20+
trim: end
21+
allow_regex: '/^[A-Za-z0-9 .,_-]+$/'
22+
---
23+
24+
# System instructions
25+
26+
Use `app_context` only when relevant to the request.
27+
28+
# Prompt template
29+
30+
Context: {{ app_context }}
31+
32+
User message: {{ user_message }}
33+
34+
# Notes
35+
36+
Demonstrates context hardening and guards:
37+
- `non_empty` + `reject_secrets` built-ins.
38+
- Structured `deny_regex` with a return message.
39+
- `max_size` and `trim` for large values.
40+
- `history.max_items` for bounded conversation context.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
id: examples/composition
3+
schema_version: 1
4+
includes:
5+
- ./shared/tone.md
6+
- ./shared/safety.md
7+
context:
8+
inputs:
9+
- name: topic
10+
non_empty: true
11+
reject_secrets: true
12+
---
13+
14+
# System instructions
15+
16+
Prioritize practical examples over abstract theory.
17+
18+
# Prompt template
19+
20+
Teach the basics of {{ topic }} in 5 bullet points.
21+
22+
# Notes
23+
24+
Shows composition with `includes`:
25+
- Included system instructions are prepended.
26+
- Local system instructions can add task-specific guidance.
27+
- Shared files remain reusable across many prompts.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
id: examples/overrides
3+
schema_version: 1
4+
model: gpt-5.4
5+
fallback_models:
6+
- gpt-5.4-mini
7+
reasoning:
8+
effort: medium
9+
sampling:
10+
temperature: 0.4
11+
environments:
12+
dev:
13+
model: gpt-5.4-mini
14+
reasoning:
15+
effort: low
16+
sampling:
17+
temperature: 0.8
18+
cache:
19+
openai:
20+
prompt_cache_key: examples-overrides-dev
21+
retention: in_memory
22+
tiers:
23+
fast:
24+
model: gpt-5.4-mini
25+
sampling:
26+
temperature: 0.2
27+
cache:
28+
openai:
29+
prompt_cache_key: examples-overrides-fast
30+
retention: in_memory
31+
context:
32+
inputs:
33+
- name: user_goal
34+
non_empty: true
35+
reject_secrets: true
36+
---
37+
38+
# Prompt template
39+
40+
Generate a short implementation plan for: {{ user_goal }}.
41+
42+
# Notes
43+
44+
Shows override layering:
45+
- Base config is production-like.
46+
- `environments.dev` lowers cost and reasoning effort.
47+
- `tiers.fast` demonstrates runtime performance tuning.
48+
- Runtime options still apply last (base → env → tier → runtime).
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
id: examples/response-json
3+
schema_version: 1
4+
response:
5+
format: json
6+
schema_name: quick_answer
7+
schema_description: Structured answer with confidence and citations.
8+
schema_strict: true
9+
schema:
10+
type: object
11+
additionalProperties: false
12+
required:
13+
- answer
14+
- confidence
15+
- citations
16+
properties:
17+
answer:
18+
type: string
19+
confidence:
20+
type: number
21+
minimum: 0
22+
maximum: 1
23+
citations:
24+
type: array
25+
items:
26+
type: string
27+
context:
28+
inputs:
29+
- name: question
30+
non_empty: true
31+
reject_secrets: true
32+
---
33+
34+
# Prompt template
35+
36+
Answer this question as structured JSON: {{ question }}
37+
38+
# Notes
39+
40+
Shows portable structured output settings via `response`.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
id: examples/tools-mcp
3+
schema_version: 1
4+
tools:
5+
- web_search
6+
- name: lookup_order
7+
description: Fetch an order by id.
8+
input_schema:
9+
type: object
10+
required:
11+
- order_id
12+
properties:
13+
order_id:
14+
type: string
15+
mcp:
16+
servers:
17+
- docs-index
18+
- name: billing-db
19+
config:
20+
readonly: true
21+
context:
22+
inputs:
23+
- name: order_id
24+
non_empty: true
25+
allow_regex: /^[A-Z0-9-]+$/
26+
---
27+
28+
# Prompt template
29+
30+
Find the order status for {{ order_id }}.
31+
32+
# Notes
33+
34+
Shows both tool declaration styles and MCP server references.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
id: examples/provider-controls
3+
schema_version: 1
4+
provider: anthropic
5+
model: claude-sonnet-4-20250514
6+
cache:
7+
anthropic:
8+
mode: explicit
9+
type: ephemeral
10+
ttl: 5m
11+
cache_system_instructions: true
12+
provider_options:
13+
anthropic:
14+
top_k: 40
15+
raw:
16+
anthropic:
17+
metadata:
18+
trace_id: example-provider-controls
19+
context:
20+
inputs:
21+
- name: support_ticket
22+
non_empty: true
23+
reject_secrets: true
24+
max_size: 6000
25+
---
26+
27+
# System instructions
28+
29+
Summarize support issues without exposing personal data.
30+
31+
# Prompt template
32+
33+
Support ticket:
34+
{{ support_ticket }}
35+
36+
# Notes
37+
38+
Demonstrates advanced provider control:
39+
- Provider-specific caching hints.
40+
- Provider-specific options (`top_k`).
41+
- `raw` passthrough for unmodeled request body fields.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
id: examples/openai-responses
3+
schema_version: 1
4+
provider: openai-responses
5+
model: gpt-5.4-mini
6+
sampling:
7+
temperature: 0.3
8+
response:
9+
format: markdown
10+
context:
11+
inputs:
12+
- name: changelog
13+
non_empty: true
14+
max_size: 6000
15+
---
16+
17+
# System instructions
18+
19+
Write release notes in a clear customer-facing style.
20+
21+
# Prompt template
22+
23+
Turn this changelog into release notes:
24+
{{ changelog }}
25+
26+
# Notes
27+
28+
Demonstrates the `openai-responses` provider with a simple markdown response format.

examples/prompts/defaults.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
provider: openai
3+
model: gpt-5.4-mini
4+
metadata:
5+
owner: examples-team
6+
stable: true
7+
cache:
8+
openai:
9+
prompt_cache_key: examples-v1
10+
retention: in_memory
11+
---
12+
13+
# System instructions
14+
15+
You are a clear, practical assistant. Prefer concise, actionable responses.

0 commit comments

Comments
 (0)