ast-visitor-pattern

ast-visitor-pattern is a skill for Claude Code, Codex from prisma/orm. It costs 65 tokens per session (800 once invoked), scanned A, original, Apache-2.0.

A programming pattern for handling a group of related data variants through fixed classes and visitors, which are objects that process each variant.

In plain words
What is it for?
Use it for command sets, intermediate representations, or factory results that are handled in multiple parts of a TypeScript codebase.
Why use it?
It makes every place that handles the variants visible to the compiler when a new variant is added.

Skill for Claude CodeCodex ✓ vendor

Written for no agent in particular: nothing here depends on one.

Good fit Use it for command sets, intermediate representations, or factory results that are handled in multiple parts of a TypeScript codebase.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/prisma/orm/ast-visitor-pattern
About the project

Prisma ORM is a Node.js and TypeScript database toolkit that lets applications work with databases through a programming interface instead of writing every query directly in SQL. Developers use it with databases including PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB, and CockroachDB. The catalogue add-ons provide agent rules, skills, hooks, agents, and other workflows for using Prisma.

prisma/orm · 47,821 stars · on GitHub · prisma.io

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.

Any agent
npx skills add prisma/orm --skill ast-visitor-pattern
Clone the repo
git clone --depth 1 https://github.com/prisma/orm

Made for: Claude Code, Codex.

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 ast-visitor-pattern

README.md
[![agentmods](https://agentmods.dev/badge/skills/prisma/orm/ast-visitor-pattern/github.svg)](https://agentmods.dev/skills/prisma/orm/ast-visitor-pattern)
Your own site
<a href="https://agentmods.dev/skills/prisma/orm/ast-visitor-pattern"><img src="https://agentmods.dev/badge/skills/prisma/orm/ast-visitor-pattern/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 ast-visitor-pattern

Your own site · 80×15
<a href="https://agentmods.dev/skills/prisma/orm/ast-visitor-pattern"><img src="https://agentmods.dev/badge/skills/prisma/orm/ast-visitor-pattern.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 800 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. Third-party audits
  • Snyk pass 7 Sept 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00065 $0.00800
Opus 5.5 $0.00026 $0.00320
Sonnet 5.5 $0.00013 $0.00160
Haiku 4.5 $0.00006 $0.00080

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

Security

Grade A, and why

ast-visitor-pattern 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 3mo 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.

skills-contrib/ast-visitor-pattern/SKILL.md · 99 lines

How it starts

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

AST Class/Visitor Pattern

When a discriminated union has 3+ variants and 2+ dispatch sites (renderers, serializers, classifiers, etc.), replace plain union + switch with frozen subclasses and a visitor interface. This makes adding a new variant a compiler error at every consumer, instead of a silent omission.

Structure

Four pieces, usually in one file — the Mongo DDL set below spreads them over three:

// 1. Abstract base (not exported — consumers use the union type)
abstract class FooNode {
  abstract readonly kind: string;
  abstract accept<R>(visitor: FooVisitor<R>): R;
  protected freeze(): void { Object.freeze(this); }
}

// 2. Visitor interface
export interface FooVisitor<R> {
  bar(node: BarNode): R;
  baz(node: BazNode): R;
}

// 3. Concrete subclasses — readonly fields, freeze() in constructor
export class BarNode extends FooNode {
  readonly kind = 'bar' as const;
  readonly value: string;
  constructor(value: string) {
    super();
    this.value = value;
    this.freeze();
  }
  accept<R>(visitor: FooVisitor<R>): R { return visitor.bar(this); }
}

export class BazNode extends FooNode {
  readonly kind = 'baz' as const;
  readonly count: number;
  constructor(count: number) {
    super();
    this.count = count;
    this.freeze();
  }
  accept<R>(visitor: FooVisitor<R>): R { return visitor.baz(this); }
}

// 4. Union type
export type Foo = BarNode | BazNode;

Consuming

Define a visitor object (or class) per concern:

const renderVisitor: FooVisitor<string> = {
  bar(node) { return node.value; },
  baz(node) { return String(node.count); },
};

function render(node: Foo): string {
  return node.accept(renderVisitor);
}

Always construct instances, never frozen object literals

This holds everywhere a node is built — tests and production construction surfaces (contract-free factories, builders). A factory must return new BarNode(...), never Object.freeze({ kind: 'bar', value: 'x' }). A frozen plain object has no prototype, so instanceof fails, accept() is missing, and a downstream shallow-copy ({ ...node }) silently strips the type back to an anonymous bag; constructor-time invariants are skipped too.

Read the full file on GitHub · 99 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. 3mo ago First seen · 99 lines · 65 tokens per session scan A a2b33606a695

Subscribe to this mod's changes

ast-visitor-pattern is a skill published in the GitHub repository prisma/orm (47,821 stars, last pushed today), licensed Apache-2.0. It adds 65 tokens to every session and 800 once invoked, about $0.0003 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-09-03.

Related

ast-visitor-pattern compared with skills from other repositories

ast-visitor-pattern next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
ast-visitor-patternprisma/ormSkill48ktodayApache-2.0A65Claude Code, Codex
prisma-ormericrisco/rsc-harnessSkill7072d agoMITA101Claude Code, Codex
adding-personhog-rpcPostHog/posthogSkill41ktodaynoneA88Claude Code, Codex
using-prismaFortiumPartners/ensembleSkill132d agoMITA43Claude Code
typescript-expertpersonamanagmentlayer/pclSkill471mo agoApache-2.0A40Claude Code
api-firstbishopZ/2026-BoilerplateSkill264mo agoMITA32Claude Code, Codex
drizzle-orm-expertfindscripter/everything-skillsSkill14todaynoneA96Claude Code