Recipe catalog / instruction-clarity
Grade instruction clarity
How unambiguous is instruction for a delegate who has only context, on a five-level rubric?
You need to grade an instruction before sending it to a sub-agent or teammate, so an orchestrator can rewrite it or ask a question instead of letting the delegate guess.
Explore this recipe interactively ยท Source and implementation guide
Use instruction-clarity in TypeScript
Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.
import { instructionClarity } from 'jev-recipes/instruction-clarity';
const result = await instructionClarity({
"instruction": "Clean up the flaky tests in the payments module and make sure CI is green.",
"context": "The payments module has 214 tests across 18 files. Three tests were quarantined last week with a skip marker and a link to issue #882. CI currently fails on main because of an unrelated lint error in the docs build.",
"minConfidence": 0.8
});
console.log(result);
Input contract
| Field | Type | Needed |
|---|---|---|
| instruction | string | Required |
| context | string | Optional |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"instruction": {
"type": "string"
},
"context": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"instruction"
]
},
"result": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"model": {
"type": "string"
},
"usage": {
"type": "object",
"properties": {
"input_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"output_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"input_tokens",
"output_tokens"
],
"additionalProperties": false
},
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"score": {
"type": "number",
"minimum": 0
},
"level": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"probabilities": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"clarity": {
"type": "string",
"enum": [
"unusable",
"ambiguous",
"gappy",
"clear",
"precise"
]
}
},
"required": [
"model",
"usage",
"status",
"score",
"level",
"confidence",
"probabilities",
"clarity"
],
"additionalProperties": false
}
}Saved example result
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo instruction-clarity.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"score": 1.99,
"level": 2,
"confidence": 0.83,
"probabilities": {
"0": 0.01,
"1": 0.08,
"2": 0.83,
"3": 0.07,
"4": 0.01
},
"clarity": "gappy"
}
Evaluation evidence
No verified live accuracy measurement is available. Evaluate representative cases before using this decision in your workflow.
Use the evaluation guide to measure this decision on your own labeled cases.
Limitations
- Grades ambiguity from the delegate's point of view using only instruction and context. It cannot know what the delegate already knows unless context says so.
- Reports how clear the instruction is, not whether the instructed work is sensible, safe, or within the delegate's abilities.
Related recipes
- query-specificity: Use query-specificity to grade how narrowly a search query pins down what is wanted, rather than how clearly an instruction directs work.
- clarify: Use clarify to list the specific questions a delegate would need answered when the instruction grades below clear.