ast-visitor-pattern
Guidelines and TypeScript examples for implementing a frozen-class visitor pattern for discriminated unions (AST/command nodes). Recommends creating abstract base, visitor interface, concrete frozen subclasses, and a union type to enforce compile-time errors when variants are added and to avoid plain frozen object literals.
Use the frozen-class/visitor pattern for discriminated unions that have multiple dispatch sites. Use when creating a new set of variants (commands, IR nodes, factory calls) that will be switched over in 2+ places, or when refactoring an existing union type that has grown multiple switch sites.
- Category: Software development
- Source: prisma/orm at commit 73bcce4
- Stars: 47746
- License: Apache-2.0
- Automated scan and AI review: passed on commit 73bcce4 (2026-11-28). All 1 file read in full by the automated scan and the AI review.
What this skill does on your computer
Instructions only: nothing beyond what your agent normally does.
We checked version 73bcce4 on 2026-11-28. Later changes to the repository haven't been checked; the install command gets the checked version.
Works with
- Claude Code: copy the folder to ~/.claude/skills/ast-visitor-pattern/ (or .claude/skills/<skill>/ in a project)
- OpenAI Codex: copy the folder to ~/.codex/skills/ast-visitor-pattern/
- GitHub Copilot: copy the folder to .github/skills/ast-visitor-pattern/ in your repository
- Cursor: copy the folder to the skills folder in your Cursor settings
- Gemini CLI: copy the folder to the skills folder in your Gemini CLI settings
- Amp: copy the folder to the skills folder in your Amp settings
Install the checked version: npx degit prisma/orm/skills-contrib/ast-visitor-pattern#73bcce4d45dcdf82e9f915a407fb32fea78856a3 ast-visitor-pattern. AI Agents Store never runs skills, and checks can miss things: review the files before you install. How we review skills