contracts-dev

contracts-dev is a command for coding agents from punt-labs/z-spec. It costs 17 tokens per session (7,252 once invoked), scanned A, original, MIT.

A command that generates runtime checks from a Z specification. These checks verify preconditions, postconditions, and invariants while the program runs; an invariant is a rule that should always remain true.

In plain words
What is it for?
Use it to generate assertion functions in Swift, TypeScript, Python, or Kotlin, optionally including invariant-only checks or wrappers that check before and after operations.
Why use it?
It catches specification violations during execution instead of allowing invalid state or behavior to go unnoticed.

Command

Part of the z-spec-dev plugin — 42 commands, 1 hook shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/punt-labs/z-spec/contracts-dev
Clone the repo
git clone --depth 1 https://github.com/punt-labs/z-spec

Or install z-spec-dev, the plugin that ships this one along with the rest of its 42 commands, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for contracts-dev

README.md
[![agentmods](https://agentmods.dev/badge/commands/punt-labs/z-spec/contracts-dev.svg)](https://agentmods.dev/commands/punt-labs/z-spec/contracts-dev)
Your own site
<a href="https://agentmods.dev/commands/punt-labs/z-spec/contracts-dev"><img src="https://agentmods.dev/badge/commands/punt-labs/z-spec/contracts-dev.svg" alt="Measured on agentmods" height="20"></a>
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 7,252 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00017 $0.07252
Opus 5 $0.00009 $0.03626
Sonnet 5 $0.00003 $0.01450
Haiku 4.5 $0.00002 $0.00725

Measured 3d ago against content hash 54782bf05f05, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

contracts-dev scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

  • contracts — 98% identical, 34 lines differ
plugin/commands/contracts-dev.md · 938 lines

How it starts

The opening of the file, as written. The whole thing — 938 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/z-spec-dev:contracts-dev - Generate Runtime Contracts

Generate runtime precondition, postcondition, and invariant assertion functions in the target language from Z schemas. Unlike /z-spec-dev:model2code-dev which generates implementation code, this command generates checks -- assertion functions that verify spec conformance at runtime.

Contracts are the executable bridge between specification and implementation. They encode Z predicates as runtime assertions so that violations are caught immediately rather than silently corrupting state.

Input

Arguments: $ARGUMENTS

Parse arguments:

  • First positional argument: Z specification file (default: search docs/*.tex)
  • Second positional argument or auto-detect: target language (swift, typescript, python, kotlin)
  • --invariants-only: generate only state invariant checks (no operation contracts)
  • --wrap: also generate wrapper functions with before/after assertion sandwiches
  • --strip: emit no-op stubs (empty function bodies) for production builds

Process

0. Prerequisites

The specification should exist and be type-checked. If the spec has not been checked, suggest running /z-spec-dev:check-dev first but do not block -- contracts can still be generated from a syntactically valid spec.

Verify fuzz is available for type-checking:

which fuzz >/dev/null 2>&1 || echo "FUZZ_NOT_FOUND"

If fuzz is found, run a type-check to confirm the spec is valid:

fuzz -t <spec.tex>

If fuzz reports errors, warn the user but continue. Contract generation does not require a passing type-check, but the generated assertions may reference invalid types.

No other external tools are needed.

1. Locate the Specification

If a file path is provided, use it directly.

If no file specified:

  • Look in docs/ for .tex files containing Z specifications
  • If multiple found, ask user to specify

Read the specification file.

2. Detect Target Language

If a language is explicitly provided as the second argument, use it.

Read the full file on GitHub · 938 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 938 lines · 17 tokens per session scan A 54782bf05f05

Subscribe to this mod's changes

contracts-dev is a command published in the GitHub repository punt-labs/z-spec (5 stars, last pushed 4d ago), licensed MIT. It adds 17 tokens to every session and 7,252 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.