No slash command · from langium-ai
Recipes, best practices, and troubleshooting for Langium 4.x DSL development: grammars, scoping, validation, LSP features, code generators, and multi-language projects.
Ships in langium-ai. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Recipes, best practices, and fixes for building languages with Langium. This file routes you to the right reference. Read only the references your task needs.
Written for Langium 4.x, verified against 4.4.0.
Check the version first: node_modules/langium/package.json (or the langium dependency in package.json). If the project uses Langium 3.x or earlier, this skill does not apply. Say so, and recommend upgrading to 4.x before using these recipes. Differences between 4.x minor versions are listed in references/troubleshooting.md.
A typical project (scaffolded with yo langium) contains:
| What | Where to look |
|---|---|
| Grammar | src/**/*.langium (path set in langium-config.json) |
| Generator config | langium-config.json if it exists, otherwise the "langium" key in package.json. If both exist, the CLI ignores the package.json key (unless --file points elsewhere) |
| Generated code | src/**/generated/ (ast.ts, grammar.ts, module.ts). Never edit by hand |
| DI module | src/**/<language>-module.ts with create<Language>Services |
| Validators | src/**/<language>-validator.ts |
| Language server entry | src/**/main.ts calling startLanguageServer |
| CLI entry and generator | src/cli/main.ts, src/cli/generator.ts |
| Tests | test/**/*.test.ts (vitest) |
Regenerate after every grammar or config change: npm run langium:generate (runs langium generate), or npm run langium:watch while editing.
| If you need to... | Read |
|---|---|
| Diagnose any misbehavior (parse errors, unresolved references, silent validators, missing editor features, slowness) | references/troubleshooting.md |
Write or change grammar rules, expressions (infix), cross-references, types, terminals | references/grammar.md |
| Fix keyword/terminal conflicts, keywords as identifiers, indentation-sensitive or case-insensitive lexing, value conversion | references/grammar.md |
Scaffold a project, configure langium-config.json, run the CLI, wire DI modules, override a service, bundle | references/project-setup.md |
Pick the right import (langium, langium/lsp, langium/node, ...) or file system | references/project-setup.md |
Add qualified names, imports between files, member access (a.b.c), a builtin library, custom scoping | references/scoping.md |
| Fix "Could not resolve reference" | references/scoping.md (after references/troubleshooting.md) |
| Add validation checks, uniqueness checks, document hooks, slow or custom categories, diagnostic codes | references/validation.md |
| Add a formatter, semantic tokens, code actions, hover, completion tweaks, inlay hints, signature help, code lens | references/lsp-features.md |
| Generate code or text from the AST, write a CLI generator, add tracing | references/code-generation.md |
| Write tests for parsing, linking, validation, or LSP features | references/testing.md |
| Put several languages in one project, reference across languages | references/multi-language.md |
Understand build phases, DocumentState, DI cycles, generated ast.ts, AST utilities | references/how-langium-works.md |
.langium grammar ──langium generate──▶ generated/ast.ts, grammar.ts, module.ts
│
create<Language>Services: inject(default modules, generated modules, your module)
│
DocumentBuilder runs each document through:
Changed → Parsed → IndexedContent → ComputedScopes → Linked → IndexedReferences → Validated
│
LSP requests (hover, completion, ...) wait for the state they need, then call providers
Every behavior is a service. To change behavior, extend the Default* class and register it in your module. Details: references/how-langium-works.md.
generated/.Default* implementation and override one method instead of reimplementing an interface.ref) inside collectExportedSymbols or collectLocalSymbols. Scopes aren't ready yet, so the result is undefined or bound to the wrong target.infix rule the first operator group binds tightest. Right associativity is written right assoc '^'.lsp section of your module.createDefaultModule / createDefaultSharedModule from langium/lsp. Headless tools may use the Core variants from langium.slow and custom validation categories never run on document updates (updates run only built-in and fast). Trigger them explicitly.langium/test test for every scoping or validation change.| Import from | Use for |
|---|---|
langium | Core types and services, inject, Module, AstUtils, CstUtils, URI, EmptyFileSystem, createDefaultCoreModule |
langium/lsp | createDefaultModule, createDefaultSharedModule, startLanguageServer, LSP provider base classes (AbstractFormatter, AbstractSemanticTokenProvider, DefaultCompletionProvider, ...) |
langium/node | NodeFileSystem for Node.js language servers and CLIs |
langium/test | parseHelper, validationHelper, expectError, expectCompletion, ... |
langium/generate | expandToNode, joinToNode, toString, tracing |
langium/grammar | Services for the Langium grammar language itself (rarely needed) |
Use NodeFileSystem for language servers and CLIs that read files from disk. Use EmptyFileSystem in the browser and in all tests, including vitest tests, which run in Node.js but work on in-memory documents.
Langium publishes its TypeScript sources, so read node_modules/langium/src/<area>/ to see the Default* implementation before overriding it (references/, validation/, lsp/, workspace/, parser/, generate/, test/).
Canonical examples at eclipse-langium/langium/examples:
| Example | Shows |
|---|---|
domainmodel | Qualified names, custom scoping, formatter, rename, builtin library |
arithmetics | infix expressions, code actions, case-insensitive keywords, interpreter |
requirements | Two languages in one project with cross-language references |
statemachine | Minimal language with a code generator |
lai: the langium-ai CLI for descriptors, system prompts, and evaluations of LLM output in Langium projects.references/code-generation.md (opens in a new tab)references/grammar.md (opens in a new tab)references/how-langium-works.md (opens in a new tab)references/lsp-features.md (opens in a new tab)references/multi-language.md (opens in a new tab)references/project-setup.md (opens in a new tab)references/scoping.md (opens in a new tab)references/testing.md (opens in a new tab)references/troubleshooting.md (opens in a new tab)references/validation.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub eclipse-langium/langium-ai --plugin langium-ai7 skills in this plugin
/laiGuide for using the langium-ai (LAI) CLI to generate language descriptors, synthesize system prompts, run evaluations, and iteratively refine AI-powered tooling in Langium projects. Use when working with lai commands, descriptors, or evaluation files./lai-gen-descriptorGenerate or refine a language descriptor for a Langium DSL project. Bootstraps a new descriptor via `lai gen descriptor` if none exists, then guides refinement of paths, services, examples, documentation, and structure./lai-gen-evalsExpand and refine the evaluation suite for a Langium DSL project. Generates comprehensive eval files that cover syntactic correctness, semantic validity, user intent matching, edge cases, and language understanding./lai-gen-language-skillSkill for generating a skill for understanding a specific Langium-based DSL. Used in cooperation with the lai & langium skills for understanding./lai-gen-mcpGenerate a Model Context Protocol (MCP) server that exposes a Langium DSL's parser and validator as an MCP tool, allowing any MCP-compatible client to validate DSL code and receive diagnostics./lai-gen-syspromptGenerate or refine a system prompt for a Langium DSL project. Bootstraps a new system prompt via `lai gen sysprompt` if none exists, then guides targeted refinement based on evaluation results and language changes.Other plugins' skills for the same job