Recipe catalog / diff-hazards
Flag hazards in a code diff
diff-hazards is a Jev recipe from the jev-recipes TypeScript package. Which hazards does diff introduce: leaked secrets, destructive commands, debug leftovers, weakened tests, or dependency changes? Use it when a coding agent or pre-commit hook needs a fast screen of a diff for the mistakes that reviewers most often catch late.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I use diff-hazards 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 { diffHazards } from 'jev-recipes/diff-hazards';
const result = await diffHazards({
"diff": "--- a/src/payments.ts\n+++ b/src/payments.ts\n@@ -1,6 +1,9 @@\n import { Stripe } from 'stripe';\n-const stripe = new Stripe(process.env.STRIPE_KEY);\n+const stripe = new Stripe('sk_prod_51Hq9zLKj3mD8vXyZ2pQ7rT4wN6bF0cE1gA5hJ8kL');\n+console.log('DEBUG charge payload', payload);\n export async function charge(payload) {\n return stripe.charges.create(payload);\n }",
"context": "Pre-commit screen for a payments service.",
"minConfidence": 0.8
});
console.log(result);
What input does diff-hazards take?
| Field | Type | Needed |
|---|---|---|
| diff | 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": {
"diff": {
"type": "string"
},
"context": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"diff"
]
},
"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"
]
},
"detected": {
"type": "array",
"items": {
"type": "string",
"enum": [
"secretLeak",
"destructiveCommand",
"debugLeftover",
"testsWeakened",
"dependencyChange"
]
}
},
"labels": {
"type": "object",
"properties": {
"secretLeak": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"present",
"absent"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"status",
"verdict",
"probability",
"confidence"
],
"additionalProperties": false
},
"destructiveCommand": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"present",
"absent"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"status",
"verdict",
"probability",
"confidence"
],
"additionalProperties": false
},
"debugLeftover": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"present",
"absent"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"status",
"verdict",
"probability",
"confidence"
],
"additionalProperties": false
},
"testsWeakened": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"present",
"absent"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"status",
"verdict",
"probability",
"confidence"
],
"additionalProperties": false
},
"dependencyChange": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"present",
"absent"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"status",
"verdict",
"probability",
"confidence"
],
"additionalProperties": false
}
},
"required": [
"secretLeak",
"destructiveCommand",
"debugLeftover",
"testsWeakened",
"dependencyChange"
],
"additionalProperties": false
}
},
"required": [
"model",
"usage",
"status",
"detected",
"labels"
],
"additionalProperties": false
}
}What does a diff-hazards result look like?
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo diff-hazards.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"detected": [
"secretLeak",
"debugLeftover"
],
"labels": {
"secretLeak": {
"status": "ready",
"verdict": "present",
"probability": 0.97,
"confidence": 0.97
},
"destructiveCommand": {
"status": "ready",
"verdict": "absent",
"probability": 0.03,
"confidence": 0.97
},
"debugLeftover": {
"status": "ready",
"verdict": "present",
"probability": 0.93,
"confidence": 0.93
},
"testsWeakened": {
"status": "ready",
"verdict": "absent",
"probability": 0.04,
"confidence": 0.96
},
"dependencyChange": {
"status": "ready",
"verdict": "absent",
"probability": 0.05,
"confidence": 0.95
}
}
}
Input
See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas. context is optional and is omitted from the request when absent.
Result
labels holds one check per label: secretLeak, destructiveCommand, debugLeftover, testsWeakened, dependencyChange. Each check has a verdict of present or absent, the yes probability, confidence for the chosen side, and its own status. detected lists the present labels in declaration order.
The overall status is review when any single label falls below minConfidence. Labels that are individually ready remain usable in that case.
Reuse and calls
Uses the shared labels helper, which places one yes/no question per label in a single Jev request. This folder owns the questions and their outcome descriptions. A live invocation makes one logical Jev request.
Limits
Split very large diffs by file and call the recipe per file; accuracy falls as unrelated hunks accumulate in one call. Deterministic checks such as secret-pattern scanners and lockfile diffs are cheaper and more reliable for what they cover; use this recipe for the semantic cases they miss.
Example input
demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo diff-hazards shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe diff-hazards to inspect the input and result schemas.
How accurate is diff-hazards?
jev-1.13.0 / 2026-10-04 / 43 development cases
Scoring revision 2.
35 ready decisions, with 97% accuracy among those decisions.
95% case-level interval: 85% to 99%. Related synthetic cases are correlated.
This measures the recorded dataset, not general readiness. Label sources: unspecified: Not recorded by the dataset author.
Use the evaluation guide to measure this decision on your own labeled cases.
What are the limits of diff-hazards?
- Reads only the supplied diff text. It does not run the code, resolve imports, or see files outside the diff.
- A pattern that looks like a secret, such as an example key in documentation, may be flagged; treat detections as a prompt for review, not proof.
Which recipes are related to diff-hazards?
- change-risk: Use change-risk to grade the overall shipping risk of a described change rather than flag specific hazards in the diff text.
- commit-message-fit: Use commit-message-fit to check whether the commit message describes the change.
- breaking-change-signal: Use breaking-change-signal to check whether a change breaks callers.