Open source · Prompt & Agent Workflows

Prompt Contract Linter

Check prompts for objective, context, constraints, output and verification fields.

v0.1.0 · Node.js 22+ · MIT

Browse the public repository · View releases

A prompt that has grown past a paragraph is a contract between several parties: whoever writes the template, whoever supplies the variables, whoever consumes the output, and whoever has to prove the output was checked. Nothing enforces that contract, so it rots in specific ways — a variable is renamed in the template but not in the declaration, an output schema survives a switch from JSON to Markdown, a word limit contradicts another word limit, a retrieved passage is pasted in with no label saying it is data rather than instruction, and the verification list quietly empties out.

This walkthrough uses the tool's public README and checked-in example files. Run the command from a repository checkout with Node.js 22+; inspect the source before using it on your own files.

Run the checked-in example

# a contract that satisfies every rule: exits 0
node bin/prompt-contract-linter.mjs --root examples examples/release-notes.json

# the same run, human-readable
node bin/prompt-contract-linter.mjs --root examples --format text \
  examples/release-notes.json

# a contract with missing fields and contradictory output requirements: exits 1
node bin/prompt-contract-linter.mjs --root examples --format text \
  examples/contradictory-output.json

# everything the repository checks before a commit
npm run check

Read the result

npm run check runs node --check over every .mjs file, the test suite, both examples, and npm pack --dry-run.

Where this check stops

Every limit is enforced from the command line, and exceeding one produces a finding naming it and an incomplete run — never a silent truncation and never a pass.

Before adapting the command to your own workflow, review the accepted inputs, exit codes and safety boundaries in the README.

Compiled with AI assistance from checked-in public documentation and example scripts. Run the example and review the repository's current documentation before relying on its result.