checks_implementation_guide

An implementation guide for adding validation checks to the GoZod library, a Go library for checking whether data matches expected rules. It describes factory functions, JSON Schema metadata, shared validation logic, and error handling.

In plain words
What is it for?
Use it when implementing or reviewing GoZod checks, connecting checks to JSON Schema, reusing the validation package, and designing their errors.
Why use it?
It reduces inconsistent check implementations and duplicated validation code. It also helps new checks fit the library’s existing architecture and schema output.

Cursor rule for Codex

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 rules/kaptinlin/gozod/checks_implementation_guide
Clone the repo
git clone --depth 1 https://github.com/kaptinlin/gozod

Made for: Codex.

Per session 2,843 This file is loaded in full into every session.
When invoked 2,843 The same file — it is already loaded in full.
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.02843 $0.02843
Opus 5 $0.01422 $0.01422
Sonnet 5 $0.00569 $0.00569
Haiku 4.5 $0.00284 $0.00284

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

Security

Grade A, and why

checks_implementation_guide 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 2d 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/rules/checks_implementation_guide.mdc · 396 lines

How it starts

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

GoZod Checks Implementation Guide

📋 Overview

This document provides implementation guidelines for GoZod validation checks based on the current architecture. All checks follow a unified factory function pattern that directly creates core.ZodCheckInternals instances with optional JSON Schema support.

🎯 Core Design Principles

1. Factory Function Pattern

  • All check functions return core.ZodCheck interface
  • Direct creation of core.ZodCheckInternals instances
  • No wrapper types or unnecessary abstractions

2. JSON Schema Integration

  • OnAttach callbacks for metadata generation
  • Automatic constraint merging for compatible properties
  • Type-appropriate attribute mapping

3. Validation Reuse

  • Leverage pkg/validate package for actual validation logic
  • Avoid duplicating validation implementations
  • Focus on error handling and schema generation

🏗️ Current Architecture

Core Types (from core package)

// ZodCheck interface - implemented by ZodCheckInternals
type ZodCheck interface {
    GetZod() *ZodCheckInternals
}

// ZodCheckInternals - the main check implementation
type ZodCheckInternals struct {
    Def      *ZodCheckDef                     // Check definition
    Check    func(payload *ParsePayload)      // Validation function  
    OnAttach []func(any)                     // JSON Schema callbacks
    When     func(payload *ParsePayload) bool // Conditional execution
}

// ZodCheckDef - check metadata
type ZodCheckDef struct {
    Check  string                // Check type identifier
    Params map[string]any        // Check parameters
    Error  *ZodErrorMap         // Custom error mapping
}

Helper Functions (from internal/checks/checks.go)

// normalizeParams - standardize string parameters to error maps
func normalizeParams(def *ZodCheckDef, params []string)

// setBagProperty - set JSON Schema property
func setBagProperty(schema any, key string, value any)

// mergeConstraint - merge constraints with conflict resolution
func mergeConstraint(schema any, key string, value any, merge func(old, new any) any)

// mergeMinimumConstraint/mergeMaximumConstraint - boundary constraint merging
func mergeMinimumConstraint(schema any, value any, inclusive bool)
func mergeMaximumConstraint(schema any, value any, inclusive bool)

Read the full file on GitHub · 396 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. 2d ago First seen · 396 lines · 2,843 tokens per session scan A 08231e883283

Subscribe to this mod's changes

checks_implementation_guide is a cursor rule published in the GitHub repository kaptinlin/gozod (24 stars, last pushed 1mo ago), licensed MIT. It adds 2,843 tokens to every session, about $0.0142 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-30.