Skip to content

Guide · Agent skill

How to use the PSL AST Layers Guide agent skill (psl-ast-layers)

Updated · written with AI from the project's own documentation and checked against our catalogue data

The psl-ast-layers skill is a set of written instructions that tells an AI agent how to read Prisma Schema Language (PSL) syntax trees correctly inside the prisma/orm repository. It is aimed at developers and contributors working on the @internal/psl-parser package, interpreters, formatters or language server features. After this guide you will know what the skill changes about the agent's behaviour, how to install it, how to phrase requests so it triggers, and what to check before relying on its output.

PSL AST Layers Guideprisma/orm · Apache-2.0

Quick start

  1. 1Download the ZIP. Get the psl-ast-layers ZIP from this skill's page on the directory.
  2. 2Unzip the skill. Extract SKILL.md into ~/.claude/skills/ for personal use or into .claude/skills/ inside your project.
  3. 3Or upload in the Claude apps. Go to Settings → Capabilities → Skills and upload the skill there if you use the Claude apps.
  4. 4Open the prisma/orm repository. Make sure you are working in the prisma/orm repository that contains the psl-parser package.
  5. 5Ask for PSL work in plain terms. Describe a task such as a psl-parser helper, formatter change or language server feature.
  6. 6Review the agent's tree access. Check that it uses typed getters and red-tree helpers rather than string slicing or green nodes.

What the skill makes the agent do

The PSL parser produces a three-layer syntax tree: a green tree for immutable storage, a red tree for navigation with offsets and parents, and typed AST classes for known nodes. The skill tells the agent which layer to use for each task. By default it should use typed AST classes such as ModelDeclarationAst and FieldDeclarationAst, call their getters, and move to the red tree only when it needs to navigate outward or sideways.

The skill also steers the agent away from common anti-patterns. These include converting the tree back to text to extract facts, reading green nodes directly, and materializing lazy iterators into arrays.

  • Prefer typed getters such as name(), fields() and lbrace() over digging through children.
  • Use red-tree helpers such as findAncestor(), tokenAtOffset() and nonTriviaSibling() for movement.
  • Never read green nodes from consumer code.
  • Avoid printing the tree to a string and matching text to get structural facts.

Install the skill from the ZIP or the Claude apps

Download the ZIP from the skill's page on this directory and unzip it. The skill ships as a single file, SKILL.md. For a personal install, unzip it into ~/.claude/skills/. For a project-specific install, unzip it into the .claude/skills/ folder of the project.

If you use the Claude apps instead, upload the skill under Settings → Capabilities → Skills.

  • Personal install: ~/.claude/skills/
  • Project install: .claude/skills/ inside your project
  • Claude apps: Settings → Capabilities → Skills

Check the requirements before you start

The skill is specific to the prisma/orm repository. You need access to its psl-parser package (@internal/psl-parser). The skill does not run scripts and does not use the network. Its only file is SKILL.md.

  • Access to the prisma/orm repository and its psl-parser package
  • No scripts are run by the skill
  • No network access is used by the skill

Trigger the skill with natural requests

Agent skills are usually selected from the task you describe, so you do not need a special command. Mention PSL work in plain terms. The skill's description covers PSL interpreters such as contract-psl, helpers inside the psl-parser package, the language server, formatters, and any code that consumes parse() output from @internal/psl-parser.

  • "Add a helper in psl-parser that finds the model enclosing this field."
  • "Write a language server hover that finds the attribute under the cursor."
  • "Review this formatter change for PSL code that uses string matching on the tree."
  • "Add a getter to the typed AST class for the field's attribute list."

Example: how the agent should write tree access

Given a node you already hold, the skill expects the agent to call a typed getter. When the agent must find an enclosing declaration, it should use findAncestor with a static cast. When it must resolve a cursor position, it should anchor on tokenAtOffset and pick leftBiased() or rightBiased() on purpose.

  • Known node: call the typed getter, for example model.lbrace().
  • Enclosing model: node.syntax.findAncestor(ModelDeclarationAst.cast).
  • Cursor to attribute: token.parent.findAncestor(FieldAttributeAst.cast) after tokenAtOffset.
const model = node.syntax.findAncestor(ModelDeclarationAst.cast);

Safety notes and tips

The skill is guidance only. It does not run code or contact a network, but the agent it guides can still edit files in your repository, so review its changes as you would any contribution. The guidance is tied to the internal @internal/psl-parser API, so names may not match other codebases.

For best results, ask the agent to add missing getters to the AST class with tests rather than working around them at the call site, since the skill recommends that pattern.

  • Review diffs before committing, as with any agent output.
  • Expect the skill to be unhelpful outside Prisma's PSL parser.
  • If the agent writes string slicing or green-node access, point it back to the skill's anti-pattern section.

What people use it for

  • Writing a psl-parser helper that finds the model or composite type enclosing a node.
  • Building a language server feature that resolves the attribute under the cursor.
  • Reviewing a formatter or interpreter change for string matching on tree output.
  • Adding a missing typed getter to an AST class with tests.

Frequently asked questions

How do I install the psl-ast-layers agent skill?

Download the ZIP from the skill's page and unzip it. Put it in ~/.claude/skills/ for personal use or in a project's .claude/skills/ folder, or upload it in the Claude apps under Settings → Capabilities → Skills.

What do I need to use the psl-ast-layers skill?

You need access to the prisma/orm repository's psl-parser package (@internal/psl-parser). The skill does not run scripts and does not use the network.

Is the psl-ast-layers skill free?

The source material provided for this guide does not state pricing or licence terms beyond the listed licence, Apache-2.0. Check the repository's licence file for the terms that apply.

Can I use this skill with a different parser?

No. The guidance is specific to the internal @internal/psl-parser API, and its class and helper names would not exist in a project that uses a different parser or syntax tree library.

What is the difference between the green tree and the red tree?

The green tree is immutable, position-independent storage that consumer code should not touch. The red tree adds offsets and parents and provides navigation helpers such as findAncestor() and tokenAtOffset().

Why does the skill say not to convert the tree back to text?

Extracting facts by stringifying the tree or slicing source by offsets throws away parsing work and can break on comments, whitespace and escapes. Typed getters return the structure directly.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

This skill suits developers and contributors who build PSL interpreters, formatters or language server features inside the Prisma repository, and maintainers reviewing that code for typed, lossless access. It is not useful if you work on other codebases or use a different syntax tree library, because its names would not apply there.

Download the skill