psl-ast-layers

Navigate and manipulate the three-layer PSL syntax tree from @prisma-next/psl-parser.

47.5k|2.5k|Updated Jun 20, 2019
One-click install
npx skills add https://github.com/prisma/prisma --skill psl-ast-layers
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: psl-ast-layers
Source: https://github.com/prisma/prisma/tree/main/skills-contrib/psl-ast-layers
Command: npx skills add https://github.com/prisma/prisma --skill psl-ast-layers

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill resolves the complexity of navigating the Prisma Schema Language (PSL) syntax tree, preventing common errors like manual string parsing or incorrect tree layer usage.

Core Features & Use Cases

  • Layered Navigation: Provides clear guidance on when to use Green trees, Red trees, or Typed AST classes.
  • Best Practices: Enforces efficient, lossless, and type-safe access to PSL structural data.
  • Use Case: When building a custom PSL formatter or language server feature, use this skill to correctly traverse nodes and tokens without re-stringifying the AST.

Quick Start

Use the psl-ast-layers skill to identify the correct AST layer and navigation helper for accessing field attributes in a model declaration.

Frequently Asked Questions about psl-ast-layers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I navigate the Prisma Schema Language syntax tree without losing type safety?

To navigate the Prisma Schema Language syntax tree without losing type safety, use the designated navigation helpers and AST getters provided for the Green, Red, and Typed AST layers instead of manual traversal.

What is the difference between Green nodes and Red nodes in a PSL parser?

Green nodes and Red nodes in a PSL parser represent distinct structural layers: Green nodes provide an immutable, lossless structural tree, while Red nodes offer a navigable, cached view for traversing tokens and parent relationships.

How do I build a custom Prisma Schema formatter using the AST?

To build a custom Prisma Schema formatter using the AST, traverse the Typed AST classes and utilize the mandated navigation helpers to access structural data directly without re-stringifying the syntax tree nodes.

When should I use Typed AST classes versus Red nodes for PSL syntax tree manipulation?

Use Typed AST classes when you need strict, strongly-typed access to specific PSL declarations, and use Red nodes when you require generic, lossless traversal across the syntax tree structure.

Why does manual string parsing fail when manipulating the Prisma Schema Language syntax tree?

Manual string parsing fails because the Prisma Schema Language syntax tree is a complex, three-layer architecture that requires dedicated AST getters to maintain structural integrity and prevent data loss.

Can I use the psl-ast-layers architectural guidance to develop a PSL language server?

Yes, the psl-ast-layers architectural guidance is specifically designed to facilitate the development of PSL language servers by defining strict usage patterns for navigating Green and Red nodes.