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.
npx agentmods add skills/prisma/prisma-next/psl-ast-layersnpx skills add prisma/prisma-next --skill psl-ast-layersgit clone --depth 1 https://github.com/prisma/prisma-nextWrote 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.
[](https://agentmods.dev/skills/prisma/prisma-next/psl-ast-layers)<a href="https://agentmods.dev/skills/prisma/prisma-next/psl-ast-layers"><img src="https://agentmods.dev/badge/skills/prisma/prisma-next/psl-ast-layers.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00080 | $0.02177 |
| Opus 5 | $0.00040 | $0.01089 |
| Sonnet 5 | $0.00016 | $0.00435 |
| Haiku 4.5 | $0.00008 | $0.00218 |
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 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.
This is a copy
91% identical to psl-ast-layers — 4 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.
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 @prisma-next/psl-parser/syntax (and re-exported from the package root). parse(source) returns { document: DocumentAst, diagnostics, sourceFile } — you start in the typed layer.
Choosing a layer
-
You know what the node is (you hold a
ModelDeclarationAst, aFieldAttributeAst, …) and want its parts → call the typed getters. Never dig through children yourself. -
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 boundariesnonTriviaSibling(element, 'next' | 'prev'),skipTriviaToken(token, direction),isTrivia(token)(fromsyntax/navigation.ts) — trivia-aware movement; never write your own whitespace/comment-skipping loop
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.
- 2d ago First seen · 153 lines · 80 tokens per session scan A dbad5643fa5f
psl-ast-layers is a skill published in the GitHub repository prisma/prisma-next (419 stars, last pushed 11d ago), licensed Apache-2.0. It adds 80 tokens to every session and 2,177 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. It is 91% identical to psl-ast-layers, differing in 4 lines, and is treated as a copy.
Other skills, from other repositories
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 @internal/psl-parser.
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.
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.
bumping-biome
Bumps biome package versions (e.g. @biomejs/biome) using pnpm, aligns biome.jsonc files with the new version/s across the repository and runs biome-related checks. Use when required to update biome to a newer version - explicitly or implicitly (e.g. after running pnpm up, pnpm update, pnpm upgrade without specific…
create-pr
Creates a GitHub PR with a Linear-ticket-prefixed title and a decision-led, narrative description for prisma-next. Use when the user wants to create a pull request, open a PR, or submit changes for review.
draft-release-notes
Author the committed release-notes file for a Prisma 8 release (stable or 8.0.0-rc.N) by enumerating the merged PRs since the previous release v tag (stable or -rc.N), resolving opaque TML-NNNN: titles via Linear context (never copied verbatim), triaging public-worthiness, and writing categorized notes — breaking…