psl-ast-layers

psl-ast-layers is a skill for Claude Code, Codex from prisma/orm. It costs 78 tokens per session (2,163 once invoked), scanned A, original, Apache-2.0.

A guide to the three kinds of syntax tree produced by the PSL parser: storage, navigation, and typed program structure. A syntax tree is a structured representation of source code.

In plain words
What is it for?
It helps build PSL interpreters, language-server features, formatters, and parser helpers that read the result of `parse()`.
Why use it?
It helps developers choose the right tree layer for each task, avoiding unnecessary low-level access while preserving source text and useful type information.

Skill for Claude CodeCodex

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,601 stars · on GitHub

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 skills/prisma/orm/psl-ast-layers
Any agent
npx skills add prisma/orm --skill psl-ast-layers
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 psl-ast-layers

README.md
[![agentmods](https://agentmods.dev/badge/skills/prisma/orm/psl-ast-layers.svg)](https://agentmods.dev/skills/prisma/orm/psl-ast-layers)
Your own site
<a href="https://agentmods.dev/skills/prisma/orm/psl-ast-layers"><img src="https://agentmods.dev/badge/skills/prisma/orm/psl-ast-layers.svg" alt="Measured on agentmods" height="20"></a>
Per session 78 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,163 The whole file, excluding the scripts and references it only reads on demand.
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.00078 $0.02163
Opus 5 $0.00039 $0.01081
Sonnet 5 $0.00016 $0.00433
Haiku 4.5 $0.00008 $0.00216

Measured yesterday against content hash 883290244d66, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

psl-ast-layers 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 yesterday.

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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

skills-contrib/psl-ast-layers/SKILL.md · 153 lines

How it starts

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

PSL AST Layers

The PSL parser (packages/1-framework/2-authoring/psl-parser) produces a three-layer syntax tree. Each layer has exactly one job — pick the right one and the code stays lossless, typed, and cheap.

Layer Types Job Use in consumer code?
Green tree GreenNode, GreenToken (syntax/green.ts) Immutable, position-independent storage. Foundation only. Never
Red tree SyntaxNode, SyntaxToken (syntax/red.ts, syntax/navigation.ts) Navigation with offsets and parents: findAncestor(), tokenAtOffset(), nextToken/prevToken, nonTriviaSibling() Navigation outside the current node
Typed AST ModelDeclarationAst, FieldDeclarationAst, … (syntax/ast/) Structural information about a known node via getters (name(), fields(), lbrace(), value()) Default choice

Everything is exported from @internal/psl-parser/syntax. parse(source) returns { document: DocumentAst, diagnostics, sourceFile } — you start in the typed layer.

Choosing a layer

  1. You know what the node is (you hold a ModelDeclarationAst, a FieldAttributeAst, …) and want its parts → call the typed getters. Never dig through children yourself.

  2. You need to move outward or sideways (find the enclosing model, the previous declaration, the token after the cursor) → use the red tree's navigation helpers, then immediately re-enter the typed layer with a static cast:

    // enclosing model (tests the node itself first, then walks ancestors)
    const model = node.syntax.findAncestor(ModelDeclarationAst.cast);
    
    // enclosing model OR composite type — combine casts with any(…)
    const owner = node.syntax.findAncestor(
      any(ModelDeclarationAst.cast, CompositeTypeDeclarationAst.cast),
    );
    

    Sideways and token-level movement all have dedicated helpers — do not hand-roll the walks:

    • nextSiblingOrToken / prevSiblingOrToken — adjacent element within the same parent (works from both nodes and tokens)
    • token.nextToken / token.prevToken — document order, crossing node boundaries
    • nonTriviaSibling(element, 'next' | 'prev'), skipTriviaToken(token, direction), isTrivia(token) (from syntax/navigation.ts) — trivia-aware movement; never write your own whitespace/comment-skipping loop

Read the full file on GitHub · 153 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. yesterday First seen · 153 lines · 78 tokens per session scan A 883290244d66

Subscribe to this mod's changes

psl-ast-layers is a skill published in the GitHub repository prisma/orm (47,601 stars, last pushed 2d ago), licensed Apache-2.0. It adds 78 tokens to every session and 2,163 once invoked, about $0.0004 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-09-03.

Related

Other skills, from other repositories

prisma-next-extension-upgrade

Upgrade Prisma Next in your extension. Bumps every @prisma-next/ dependency to the requested target (or npm latest), runs the per-transition upgrade instructions for the extension SPI (middleware lifecycle, codec / migration-tools / framework-components churn, seed-migration on-disk shape), verifies the pins are…

prisma/prisma-next · 136 tokens

ast-visitor-pattern

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.

prisma/prisma-next · 65 tokens

record-upgrade-instructions

Record upgrade instructions alongside a Prisma Next breaking-change PR, so downstream consumers (users of @prisma-next/ and authors of Prisma Next extensions) can apply the matching code translation automatically via the published upgrade skills. Use when you have refactored framework code and the test suite went red…

prisma/prisma-next · 122 tokens

psl-ast-layers

How to use the PSL syntax tree layers (green tree, red tree, strongly-typed AST classes) correctly. Use for any PSL-related work: PSL interpreters (contract-psl), helpers inside the psl-parser package, the language server, formatters, or anything else that consumes parse() output from @prisma-next/psl-parser.

prisma/prisma-next · 80 tokens

no-bare-casts

Writing as in TypeScript or TSX production code, modifying a file that contains a bare as cast, silencing a type error with a cast, encountering as unknown as, or reviewing a cast site.

prisma/prisma-next · 52 tokens

compiler-orchestrator

Orchestrate the Rust compiler port end-to-end. Discovers the current frontier, fixes failing passes, ports new passes, reviews, and commits in a loop.

react/react · 38 tokens