psl-ast-layers

psl-ast-layers is a skill for Claude Code, Codex from prisma/prisma-next. It costs 80 tokens per session (2,177 once invoked), scanned A, a copy of psl-ast-layers, Apache-2.0.

A guide to using the three syntax-tree layers produced by the PSL parser. A syntax tree is a structured representation of source code; the guide explains when to use its storage, navigation, and typed-node layers.

In plain words
What is it for?
Use it when building or changing PSL interpreters, parser helpers, language-server features, formatters, or other code that consumes parser output.
Why use it?
It helps prevent using the wrong representation when working with PSL code, which can make code harder to navigate, less precise, or more expensive to process.

Skill for Claude CodeCodex ✓ vendor

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

Good fit Use it when building or changing PSL interpreters, parser helpers, language-server features, formatters, or other code that consumes parser output.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/prisma/prisma-next/psl-ast-layers
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/prisma-next --skill psl-ast-layers
Clone the repo
git clone --depth 1 https://github.com/prisma/prisma-next

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/prisma-next/psl-ast-layers/github.svg)](https://agentmods.dev/skills/prisma/prisma-next/psl-ast-layers)
Your own site
<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/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 psl-ast-layers

Your own site · 80×15
<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="Reviewed on agentmods" width="80" height="20"></a>
Per session 80 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,177 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.
Origin 91% copy Near-identical to another mod 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.00080 $0.02177
Opus 5.5 $0.00032 $0.00871
Sonnet 5.5 $0.00016 $0.00435
Haiku 4.5 $0.00008 $0.00218

Measured 1mo ago against content hash dbad5643fa5f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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.

Origin

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.

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 @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

  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. 1mo ago First seen · 153 lines · 80 tokens per session scan A dbad5643fa5f

Subscribe to this mod's changes

psl-ast-layers is a skill published in the GitHub repository prisma/prisma-next (414 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 80 tokens to every session and 2,177 once invoked, about $0.0003 per session on Opus 5.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.

Related

Other skills, from other repositories

omh-rust

This is an OMH rust workflow skill, projected for Agent Skills hosts (Claude Code, Codex, Cursor, opencode, OpenClaw, pi).

rlaope/oh-my-hermes · 74 tokens

axiom-concurrency

Use when writing ANY async code, actors, or threads in an Apple-platform app, or seeing ANY concurrency error. Covers Swift 6 concurrency, @MainActor, Sendable, data races, async/await patterns.

CharlesWiltgen/Axiom · 49 tokens

splitting-oversized-modules

Split an oversized Python module (a thousand-plus-line logic.py, models.py, api.py, or its test file) into a package of one module per concern, mechanically and provably without changing behavior. Use on a request to split / break up / decompose a god module or move functions out of one, once a human has agreed to…

PostHog/posthog · 197 tokens

migrate-better-result-3

Migrate a TypeScript codebase from better-result 2.x to 3.0. Use when upgrading better-result across the TaggedError syntax, removed Result serialization helpers, recovery inference, matching, or retry APIs.

dmmulroy/better-result · 52 tokens

precise

Online (incremental) covariance, correlation, and precision estimation in Python — the streaming complement to sklearn.covariance. Use when code needs a covariance/correlation matrix updated per observation, recomputes np.cov/np.corrcoef in a rolling loop, must judge or compare covariance estimates, or proposes a new…

microprediction/precise · 76 tokens

et-test-write

ET test authoring workflow for WOW. Use when writing or modifying ATestHandler tests, choosing test package placement, naming test classes, creating test-only model types, preparing deterministic coroutine-style assertions, handling ObjectWait, constructing test config data, and enforcing EntityRef safety in tests.

FlameskyDexive/Legends-Of-Heroes · 60 tokens