Agent skill

Convex Return Validators

by waynesutton in waynesutton/markdown-site

Guide for when to use and when not to use return validators in Convex functions.

MITAuto-check passedDevelopment

Install Convex Return Validators

skills CLI
$ npx skills add waynesutton/markdown-site --skill convex-return-validators -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install waynesutton/markdown-site convex-return-validators --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/waynesutton/markdown-site.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.cursor/skills/convex-return-validators .claude/skills/convex-return-validators && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
convex-return-validators
GitHub stars
628
Token cost
~2.4k tokens
SKILL.md length
1,006 words
Files
3 (incl. references)
Skills in repo
17
Repo updated
First seen
Licence
MIT

At a glance

Guide for when to use and when not to use return validators in Convex functions.

  • The user is writing Convex queries
  • SKILL.md covers What is a return validator?, Why the old "always" rule…, Why "always" causes problems and The "exact type" problem —…, plus 5 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Actions and needs guidance on return value validation

What it does

Convex Return Validators is an agent skill from waynesutton/markdown-site. Guide for when to use and when not to use return validators in Convex functions. Use this skill whenever the user is writing Convex queries, mutations, or actions and needs guidance on return value validation. Also trigger when the user asks about Convex type safety, runtime validation, AI-generated Convex code, Convex AI rules, Convex security best practices, or when they're debugging return type issues in Convex functions. Trigger this skill when users mention "validators", "returns", "return type", or "exact…

Its SKILL.md is about 2.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including reference files (for example `references/ai-rules-guidance.md` and `references/quick-reference.md`).

It sits in Development, covering Type safety. The repository describes itself as: An open-source publishing framework built for AI agents and developers to ship websites, docs, or blogs. Write markdown, sync from the terminal. Your content is instantly… The licence is MIT.

When your agent uses it

  • The user is writing Convex queries
  • Actions and needs guidance on return value validation
  • The user asks about Convex type safety
  • Runtime validation

Example prompts

  • “validators”
  • “returns”
  • “return type”
  • “/convex-return-validators”

What it can do on your machine

Read from SKILL.md and the folder at commit 3872c59. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.convex.dev
    • github.com
    • stack.convex.dev

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Convex Return Validators loads about 2.4k tokens when it runs, and up to ~3.8k if it reads all its reference files. Until then it costs about 174 tokens; SKILL.md has 1,006 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~174
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~3.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from waynesutton/markdown-site at commit 3872c59, republished under its MIT licence (© waynesutton). 1,006 words, ~2,423 tokens.

Download SKILL.mdSave it as .claude/skills/convex-return-validators/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
convex-return-validators
description
Guide for when to use and when not to use return validators in Convex functions. Use this skill whenever the user is writing Convex queries, mutations, or actions and needs guidance on return value validation. Also trigger when the user asks about Convex type safety, runtime validation, AI-generated Convex code, Convex AI rules, Convex security best practices, or when they're debugging return type issues in Convex functions. Trigger this skill when users mention "validators", "returns", "return type", or "exact types" in the context of Convex development. Also trigger when writing or reviewing Convex AI rules or prompts that instruct LLMs how to write Convex code.

When to and when not to use return validators in Convex

Convex recently updated its guidance on return validators. The old rule was "always add a returns validator." The new guidance is: prefer simple TypeScript types and inference by default. Use returns: when you actually want Convex to enforce an exact runtime contract.

Return validators aren't bad. The word "always" was doing damage.

What is a return validator?

Convex lets you validate arguments coming into a function using args and return values going out using returns. A return validator declares the return shape, and Convex checks it at runtime.

typescript
import { query } from "./_generated/server";
import { v } from "convex/values";

export const getUserPreview = query({
  args: { userId: v.id("users") },
  returns: v.object({
    name: v.string(),
  }),
  handler: async (ctx, { userId }) => {
    const user = await ctx.db.get(userId);
    if (!user) throw new Error("User not found");
    return { name: user.name };
  },
});

If the returned value doesn't match, you get a runtime error instead of silently returning unexpected data. Object validators don't allow extra properties — returning extra fields will fail validation at runtime.

Why the old "always" rule existed

The original motivation was more about TypeScript pain than runtime correctness. Convex projects can hit circular type problems because functions reference generated api or internal objects, and those references become part of the generated types. Types reference types reference types until TypeScript gives up.

The thinking: if the model always declared return validators, it would reduce reliance on inferred return types and break the cycle. In practice, it only helps in specific circumstances.

Why "always" causes problems

In real codebases, and especially in agentic AI workflows, the "always" rule creates predictable failure modes:

Verbosity and copy-paste fragility

LLMs don't reuse validators. They copy-paste shapes inline. You end up with return validators like this on every function:

typescript
export const listByProject = query({
  args: { projectId: v.id("projects") },
  returns: v.array(
    v.object({
      _id: v.id("activityLog"),
      _creationTime: v.number(),
      action: v.string(),
      userId: v.id("users"),
      userName: v.string(),
      projectId: v.id("projects"),
      entityType: v.string(),
      entityId: v.string(),
      metadata: v.optional(v.string()),
    }),
  ),
  handler: async (ctx, args) => {
    // ...
  },
});

It works, but once that shape is copy-pasted across multiple functions, a schema change stops being a "change one place" job. You update a field, chase compile errors, chase runtime validation errors, then update a bunch of validators that are almost-the-same-but-not-quite.

Token inefficiency for AI

Every extra hundred tokens matters when the model is trying to keep the codebase in working memory and plan multi-step changes. Verbosity translates into slower iterations and more "oops, I forgot a field" cycles.

Hallucination risk

Asking a model to reproduce a schema as a validator increases the chance it invents fields, misses fields, or picks the wrong validator type. TypeScript catches a lot of this, but catching things later is still slower than not introducing the problem.

System field duplication

Unless you're using helper utilities, return validators drag you into re-declaring _id and _creationTime over and over. If you want heavy validator usage, look at the validator utilities in convex-helpers.

Convex already provides ergonomic type helpers like Doc<> and WithoutSystemFields, so a lot of the time you can keep code tidier by leaning on normal TypeScript types and inference.

The "exact type" problem — where return validators shine

TypeScript is structurally typed, which means it doesn't have true exact types. A function can claim it returns a User but still accidentally return extra fields.

This becomes more likely once any gets involved, or when consuming untyped external API data:

typescript
// WITHOUT return validator — extra field leaks silently
export const getUser = query({
  args: {},
  handler: async (ctx): Promise<User> => {
    return {
      id: "123",
      name: "Alice",
      email: "alice@example.com", // Extra field — no error!
    } as any;
  },
});

// WITH return validator — Convex catches extra field at runtime
export const getUser = query({
  args: {},
  returns: v.object({
    id: v.string(),
    name: v.string(),
  }),
  handler: async (ctx) => {
    return {
      id: "123",
      name: "Alice",
      email: "alice@example.com", // Runtime error!
    } as any;
  },
});

That guarantee is real and valuable. It's just not needed everywhere, and using it everywhere comes with costs.

When you SHOULD use return validators

Return validators are useful when you need runtime enforcement of an exact contract, not just TypeScript typechecking.

Components codegen

There are cases where inference isn't available and the validator becomes the contract.

Static codegen workflows

With static codegen, functions don't have return type inference and will default to v.any() if they don't have a returns validator.

OpenAPI generation

You often want the server to enforce the contract you're generating client types from. Missing validators get treated as any, which makes the resulting spec less useful.

Show full SKILL.md (411 more words)Show less
When any or unvalidated external data is involved

If there's a realistic chance you'll accidentally return data you didn't intend to expose, return validators catch that. For external API calls, it's usually better to validate the data at the boundary (inside an action right after the fetch). But belt-and-braces is fair too.

When you should NOT use return validators

Standard queries and mutations with good TypeScript types

If your handler's return type is already well-typed via inference or explicit TypeScript annotations, the return validator adds verbosity without meaningful safety.

AI-generated code in agentic workflows

This is counterintuitive, but the "always" rule was actively harming AI code quality. LLMs produce better Convex code when they can lean on TypeScript inference instead of reproducing schema shapes as validators. Fewer tokens, fewer hallucinations, faster iteration.

Rapid prototyping

When the return shape is still changing, return validators slow you down. Add them once the shape stabilizes and you need the runtime contract.

Internal functions

Functions using internalQuery, internalMutation, or internalAction aren't exposed to clients. TypeScript inference is usually sufficient.

Updated guidance for AI rules and prompts

If you're writing Convex AI rules (for Claude, Cursor, Copilot, or any agentic tool), update the guidance:

Old rule: "Always add a returns validator to queries and mutations."

New rule: "Prefer simple TypeScript types and inference by default. Use returns: when you actually want Convex to enforce an exact runtime contract — such as components codegen, static codegen, OpenAPI generation, or when handling any/unvalidated external data."

When AI does use return validators, encourage it to:

  • Reuse shared validators from a central file instead of copy-pasting shapes inline
  • Use .pick(), .omit(), .extend() on object validators to derive return types
  • Use Doc<"tableName"> and WithoutSystemFields for TypeScript types when validators aren't needed
  • Use validator utilities from convex-helpers to reduce system field duplication

Decision framework

ScenarioUse returns:?Why
Components codegenYesInference not available, validator is the contract
Static codegenYesFunctions default to v.any() without it
OpenAPI generationYesMissing validators become any in the spec
any or unvalidated external dataYesCatches accidental data leakage at runtime
Standard queries with good TS typesNoTypeScript inference is sufficient
AI/LLM-generated code (default)NoReduces verbosity, tokens, and hallucination risk
Internal functionsNoNot client-facing, inference is fine
Rapid prototypingNoAdd later when shape stabilizes

Further reading

© waynesutton, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (references) in .cursor/skills/convex-return-validators of waynesutton/markdown-site.

  • SKILL.md
  • references/ai-rules-guidance.md
  • references/quick-reference.md

Open the folder on GitHubat commit 3872c59

Compare with similar skills

Convex Return Validators next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Convex Return Validators compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Convex Return Validators this skillwaynesutton/markdown-site628—~2.4kAutomated safety check: PassMIT
Typescript Advanced Typesrolling-scopes/rsschool-app10k24 repos~4.2kAutomated safety check: PassMPL-2.0
RTK Rust Design Patternsrtk-ai/rtk83k—~1.9kAutomated safety check: PassApache-2.0
Kedro Babysitkedro-org/kedro11k—~4kAutomated safety check: PassCustom licence
Dignified Python Standardsdocling-project/docling68k—~1.5kAutomated safety check: PassApache-2.0
Wagmi Feature Developmentwevm/wagmi6.8k—~3.8kAutomated safety check: PassMIT

Similar skills

  • Typescript Advanced Types

    rolling-scopes/rsschool-app

    Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications.

    10k GitHub starsUsed in 24 repos~4.2k tokens
    DevelopmentAuto-check passed
  • Describes seven Rust design patterns for the RTK CLI filter modules, with when to use each, RTK examples, and notes on when a pattern is overkill.

    83k GitHub stars~1.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Kedro Babysit

    kedro-org/kedro

    Run Kedro's local lint / format / type-check / tests on changed files (uses the project's pre-commit hooks, ruff, mypy, pytest, lint-imports, detect-secrets, Make targets — in the right venv), or…

    11k GitHub stars~4k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Dignified Python Standards

    docling-project/docling

    Applies opinionated production Python conventions chosen by the project's Python version: modern type syntax, pathlib, explicit checks and interface guidance.

    68k GitHub stars~1.5k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Walks through adding a Wagmi feature across its layers: a Viem-based core action, TanStack Query options, and React and Vue bindings.

    6.8k GitHub stars~3.8k tokensUpdated 6 days ago
    DevelopmentAuto-check passed
  • Rust Path Types

    openinterpreter/openinterpreter

    Rules for choosing Rust types for filesystem paths in new Codex code, covering protocol types, internal use and model tool arguments.

    69k GitHub starsUsed in 2 repos~605 tokens
    DevelopmentAuto-check passed

More from waynesutton/markdown-site

All 17 skills in this repo
  • Convex Self Hosting

    waynesutton/markdown-site

    Integrate Convex static self hosting into existing apps using the latest upstream instructions from get-convex/self-hosting every time.

    628 GitHub stars~1.4k tokensUpdated 4 mo ago
    Auto-check passed
  • Robel Auth

    waynesutton/markdown-site

    Integrate and maintain Robelest Convex Auth in apps by always checking upstream before implementation.

    628 GitHub stars~4.4k tokensUpdated 4 mo ago
    Auto-check passed
  • Migration Helper

    waynesutton/markdown-site

    Plan and execute Convex schema migrations safely, including adding fields, creating tables, and data transformations.

    628 GitHub starsUsed in 1 repo~958 tokens
    Auto-check passed
  • Convex Doctor

    waynesutton/markdown-site

    Run convex-doctor static analysis, interpret findings, and fix issues across security, performance, correctness, schema, and architecture categories.

    628 GitHub stars~1.9k tokensUpdated 4 mo ago
    Auto-check passed
  • Convex Quickstart

    waynesutton/markdown-site

    Initialize a new Convex project from scratch or add Convex to an existing app.

    628 GitHub stars~1.2k tokensUpdated 4 mo ago
    Auto-check: notes
  • Convex Setup Auth

    waynesutton/markdown-site

    Set up Convex authentication with proper user management, identity mapping, and access control patterns.

    628 GitHub stars~1.4k tokensUpdated 4 mo ago
    Auto-check passed

Categories

Questions about Convex Return Validators

What does Convex Return Validators do?

Guide for when to use and when not to use return validators in Convex functions. Convex Return Validators is an agent skill from waynesutton/markdown-site. Guide for when to use and when not to use return validators in Convex functions.

When should I use Convex Return Validators?

Convex Return Validators fits situations like: the user is writing Convex queries; actions and needs guidance on return value validation; the user asks about Convex type safety; runtime validation.

How do I install Convex Return Validators in Claude Code?

Run `npx skills add waynesutton/markdown-site --skill convex-return-validators -a claude-code`. Or copy the skill folder (.cursor/skills/convex-return-validators in waynesutton/markdown-site) into .claude/skills/convex-return-validators in your project. Claude Code loads it when a task matches its description.

How do I install Convex Return Validators in Codex?

Run `npx skills add waynesutton/markdown-site --skill convex-return-validators -a codex`. Or copy the skill folder (.cursor/skills/convex-return-validators in waynesutton/markdown-site) into .agents/skills/convex-return-validators in your project. Codex loads it when a task matches its description.

Can I use Convex Return Validators in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add waynesutton/markdown-site --skill convex-return-validators -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/convex-return-validators, .gemini/skills/convex-return-validators, .github/skills/convex-return-validators and .opencode/skills/convex-return-validators in your project.

What does Convex Return Validators need to run?

SKILL.md names no scripts, command-line tools or credentials: Convex Return Validators is instructions for the agent only.

Does Convex Return Validators access the network?

SKILL.md names 3 domains. As links in the text: docs.convex.dev, github.com and stack.convex.dev. This is read from the text; nothing was executed.

Is Convex Return Validators safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Convex Return Validators use?

Convex Return Validators is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Convex Return Validators use?

About 2.4k tokens (SKILL.md is roughly 9.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.3k tokens, read only when the agent opens those files.

What are the alternatives to Convex Return Validators?

Skills that share tags, products or a category with Convex Return Validators: Typescript Advanced Types (rolling-scopes/rsschool-app, 10k stars), RTK Rust Design Patterns (rtk-ai/rtk, 83k stars), Kedro Babysit (kedro-org/kedro, 11k stars) and Dignified Python Standards (docling-project/docling, 68k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Convex Return Validators?

waynesutton (a GitHub user) maintains it in waynesutton/markdown-site, which has 628 GitHub stars. The repository holds 17 skills in this directory. The repository was last updated on May 20, 2026.

Source: waynesutton/markdown-site on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.