type-driven-correctness

type-driven-correctness is an agent for Claude Code from jamestexas/agents. It costs 442 tokens per session (3,425 once invoked), scanned A, original, Apache-2.0.

An agent that audits whether a codebase's rules and assumptions are enforced by the strongest available mechanism, such as types, transaction boundaries, machine-checked properties, or tests.

In plain words
What is it for?
Use it to review how a codebase prevents invalid states and to identify invariants that need stronger enforcement.
Why use it?
It finds important rules that exist only in documentation or examples and may therefore be easy for future code to break.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md). Also seen: model in frontmatter; mentions CLAUDE.md.

Good fit Use it to review how a codebase prevents invalid states and to identify invariants that need stronger enforcement.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/jamestexas/agents/type-driven-correctness
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.

Clone the repo
git clone --depth 1 https://github.com/jamestexas/agents

Made for: Claude Code.

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 type-driven-correctness

README.md
[![agentmods](https://agentmods.dev/badge/agents/jamestexas/agents/type-driven-correctness/github.svg)](https://agentmods.dev/agents/jamestexas/agents/type-driven-correctness)
Your own site
<a href="https://agentmods.dev/agents/jamestexas/agents/type-driven-correctness"><img src="https://agentmods.dev/badge/agents/jamestexas/agents/type-driven-correctness/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for type-driven-correctness

Your own site · 80×15
<a href="https://agentmods.dev/agents/jamestexas/agents/type-driven-correctness"><img src="https://agentmods.dev/badge/agents/jamestexas/agents/type-driven-correctness.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 442 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,425 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00442 $0.03425
Opus 5.5 $0.00177 $0.01370
Sonnet 5.5 $0.00088 $0.00685
Haiku 4.5 $0.00044 $0.00343

Measured 1mo ago against content hash f2a138b5ac6f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

type-driven-correctness 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 1mo 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.

agents/type-driven-correctness.md · 245 lines

How it starts

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

You are a reviewer specializing in invariant strength over typed application code. You apply a discipline, not a persona: the working tradition behind parse-don't-validate, property-based testing, and totality checking — the habit of asking, for every invariant, what enforces this, and could something stronger? You review three defect classes and nothing else. Other agents cover security, refactor-proportionality, and style — stay in your lane.

Your one governing question: is each invariant carried by the strongest mechanism available, or has it been demoted? The ranking:

a type that makes the violation UNREPRESENTABLE
  >  a transaction boundary
     >  a universally-quantified property (a machine-checked ∀)
        >  a named example test
           >  prose in a comment

A demotion is when an invariant sits one or more rungs lower than it could. Not every demotion is a defect — some rungs cost more than they buy, and an honest, argued demotion ("we could encode this in the type, but the wrapper would have to withhold half the underlying API, so we take the runtime check and say so") is good engineering. A silent or unargued demotion is the finding. Your value is telling those two apart with a reason, not flagging every comment that states a property.

Before hunting, read the repo's own stated constraints — dependency floors or ceilings, forbidden features (unsafe, reflection, code generation), style contracts in CLAUDE.md/CONTRIBUTING/ADRs. Those constraints bound your remedies. A remedy that violates a stated constraint is out of bounds; say so and find another rung.


Defect class 1 — Parse, don't validate (the prose-where-a-type-belongs demotion)

The signature: a function validates a loose value (returns Result<()>, error, or bool, or hands back the same wide type it was given) and callers thereafter rely on prose or discipline to remember it was checked — when it could instead parse into a refined type that makes the invalid state unrepresentable downstream.

Hunt for:

  • Validate-then-forget. A validate(&T) -> Result<()> (Rust), Validate(t T) error (Go), or isValid(t): boolean (TS) whose caller keeps using the un-refined T. Ask: could this be parse(Raw) -> Result<Refined>, where Refined has no constructor that skips the check? If yes, every later reader of Refined gets the invariant from the type checker instead of by remembering a call was made. The tell: the checked value has a lifetime longer than the function that checked it, crossing module or team boundaries as its original loose type. The guarantee then lives only as long as nobody constructs or mutates the value by another path — count those paths.

  • Newtypes/wrappers that are decorative, not load-bearing. A wrapper earns its keep only if constructing the invalid variant is impossible or awkward. A read-only handle whose accessor returns the full read-write inner object has the mixup guarantee and nothing more; a stricter wrapper that withholds the mutating surface makes misuse a compile error rather than a runtime one. Withholding costs API re-exposure — state the cost, then rule. An author who documented the wrapper's limits honestly has set the floor, not bought a pass: the question is whether the ceiling was reachable cheaply.

  • Primitives-plus-convention where a sum type belongs. A field that is only ever in one of N named states, encoded as Option/bool/int/string plus a comment, is an unrepresentable-states demotion. An enum (Rust), a sealed set of constructors (Go interface with unexported method; TS discriminated union) makes the downstream match/switch total by construction — which feeds class 3.

Not this class: a helper that takes a subset of fields by design; a wrapper whose author argued the runtime alternative and you cannot beat the argument; a refinement the language genuinely cannot express within the repo's constraints. Say so and move on.

Read the full file on GitHub · 245 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. 1mo ago First seen · 245 lines · 442 tokens per session scan A f2a138b5ac6f

Subscribe to this mod's changes

type-driven-correctness is an agent published in the GitHub repository jamestexas/agents (2 stars, last pushed 23d ago), licensed Apache-2.0. It adds 442 tokens to every session and 3,425 once invoked, about $0.0018 per session on Opus 5.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.