mps-model-manipulation
Skill1.7k starsChanged 2 months agoApache-2.0View on GitHub
Use when writing or editing MPS BaseLanguage code that lives inside a model — behavior methods, typesystem rules, checking rules, generator queries, constraints, intentions, scope/canBe callbacks, dataflow builders — and combines the `smodel`, `collections`, and `closures` language extensions. Covers querying nodes (`.descendants<C>`, `.ancestor<C>`, `.children`, `.parent`, `containingRoot`), filtering sequences (`.where`, `.select`, `.translate`, `.ofConcept<C>`), building closures (`{ it => ... }`, `yield`, recursion), creating and mutating nodes (`new node<C>()`, `add new(C)`, `set new(C)`, `replace with new(C)`, `.detach`, `.copy`), property and link access (`SPropertyAccess`, `SLinkAccess`, `SLinkListAccess`), reference operations (`.reference/C : role/`, `.target`), null-safe node equality (`:eq:` / `:ne:`), smodel/Java type casts (`node:C`, `node as C`, `/`, `downcast`), foreach choice, the `command` / `read action` lock wrappers, and JSON blueprints for every shape the Java parser cannot produce.
Trending
Quiet since October.thin dataabout the whole repository
Who's talking about JetBrains/MPS
- mbeddr/mps-gradle-plugin“Null pointer exception on generate”GitHub · May 18, 2020 · 1 reactions
- nebojsa-vuksic/skill-atlas“Scan every repository of an organization or user”GitHub · Oct 1, 2026
- modelix/modelix.editor“Implement MPS shortcuts”GitHub · Feb 21, 2023
The biggest 3 of 3 mentions linking to the repository that our crawl found. Each line is their own headline.
In this repository83 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- actionsSkill
- bugfix-workflowSkill
- code-styleSkill
- commitsSkill
- debuggingSkill
- mps-aspect-accessoriesSkill
- mps-aspect-actionsSkill
- mps-aspect-behaviorSkill
- mps-aspect-constraintsSkill
- mps-aspect-dataflowSkill
- mps-aspect-editor-menus-and-keymapsSkill
- mps-aspect-editorSkill
- mps-aspect-generation-planSkill
- mps-aspect-generatorSkill
- mps-aspect-intentionsSkill
- mps-aspect-migrationsSkill
- mps-aspect-structure-conceptsSkill
- mps-aspect-textgenSkill
- mps-aspect-typesystemSkill
- mps-baselanguageSkill
- mps-build-languageSkill
- mps-consoleSkill
- mps-distribution-buildSkill
- mps-dsl-memorySkill
- mps-ide-pluginSkill
- mps-lang-core-xmlSkill
- mps-language-analysisSkill
- mps-language-aspects-overviewSkill
- mps-language-inheritanceSkill
- mps-language-modularitySkill
- mps-mcp-workflowSkill
- mps-node-editingSkill
- mps-project-managementSkill
- mps-quotationsSkill
- mps-run-configurationsSkill
- mps-testsSkill
- registrySkill
- skill-optimization-studySkill
- ssrSkill
- teamcity-cliSkill
- actionsSkill
- bugfix-workflowSkill
- code-styleSkill
- commitsSkill
- debuggingSkill
- mps-aspect-accessoriesSkill
- mps-aspect-actionsSkill
- mps-aspect-behaviorSkill
- mps-aspect-constraintsSkill
- mps-aspect-dataflowSkill
- mps-aspect-editor-menus-and-keymapsSkill
- mps-aspect-editorSkill
- mps-aspect-generation-planSkill
- mps-aspect-generatorSkill
- mps-aspect-intentionsSkill
- mps-aspect-migrationsSkill
- mps-aspect-structure-conceptsSkill
- mps-aspect-textgenSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 35
Add one more file, and only when the body actually does this:
- Very specific: line 64
Identify the source-of-truth layer: If the change is to existing logic in a rule/method body, inspect the current node (shallow …
- Very specific: line 71
If MPS MCP tools are unavailable, do not hand-edit serialized .mps files unless explicitly requested — inspect only and report.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Writing MPS BaseLanguage with smodel / collections / closures
Loading companion skills
Companion names in this skill are lazy dependencies: load only those relevant to the current task. If this skill came from an MCP server, use the host's skill loader to resolve the companion's unique discovered entry URI on the same host-assigned originating server. If the host has no server-backed skill loader, stop and report that limitation; do not silently fall back to a filesystem copy. If this skill came from a filesystem catalog, load the named sibling from that same catalog at <skills-root>/<skill-name>/SKILL.md, even if remote skill loaders are also available. Do not invent a tool name or server endpoint.
Use this skill when authoring code inside an MPS model where BaseLanguage is mixed with the smodel, collections, and closures extensions: behavior methods, checking/typesystem/dataflow rules, generator query functions, intentions, constraints, scope/canBe callbacks. The mps_mcp_parse_java_and_insert parser understands only plain Java, so most non-trivial code requires hand-built node blueprints — this skill is the catalog.
To enumerate nodes/instances/usages across a scope (a whole project, module, model, or repository) rather than navigating from one root, add the jetbrains.mps.lang.smodel.query language — it supplies #instances / #usages / #nodes / #references / #models / #modules and a with (<scope>) { … } wrapper, the same queries the MPS Console runs. Its results compose with the smodel/collections/closures operations catalogued here. See the mps-console skill.
Minimum reading set
references/ is a lookup catalog, not a syllabus. One file is enough to write the body. The
common failure here is the opposite: five catalogs (~60 KB) read to author one behavior method and one
checking rule.
| Body you are writing | Read only |
| a behavior method | references/dot-expression-basics.md |
| a typesystem inference rule or a checking rule | references/dot-expression-basics.md |
a scope or canBe* callback | references/dot-expression-basics.md |
a generator query ($IF$ condition, $LOOP$ source, $REF$ target) | references/dot-expression-basics.md |
One file serves all four because every smodel/collections operation is a DotExpression. That file
carries its own jump table — open the one section matching the expression you are building, not the
whole file.
Add one more file, and only when the body actually does this:
- reads or writes a property (
node.name, a$PROPERTY$value), or creates / restructures nodes (add new(C),set new(C),replace with new(C),.detach,NF_*) →references/property-and-mutation-ops.md - declares a local, parameter or return type that is an MPS type (
sequence<node<X>>,nlist<C>,search scope) →references/variable-declarations.md - goes through an
SReferenceobject, siblings,containingRoot, orofConcept<C>→references/references-and-queries.md - reads or attaches an attribute / annotation (
.@) →references/attribute-access.md - is plain Java going in through
mps_mcp_parse_java_and_insert→references/java-parser-capabilities.md - runs outside a rule or behavior body (IDE action, tool, plugin hook) and touches a model →
references/concurrent-access.md
Stopping rule. Open a further reference only after an error you cannot explain from the one you
have — and then references/golden-rules-and-pitfalls.md (4.8 KB) before any catalog: its
symptom→cause→fix table settles most first-attempt errors and names the single catalog to open when it
does not. The See … pointers in the Critical Directives below, and the Reference Index at the end of
this file, are symptom indexes for that step — not a reading order.
Critical Directives
- Node equality uses
:eq:and:ne:, never==or.equals(). UseNPEEqualsExpression/NPENotEqualsExpression. Seereferences/node-equality.md. - Every
InferredClosureParameterDeclarationneeds atypechild, even though MPS infers the type. Usejetbrains.mps.baseLanguage.structure.UndefinedTypeas placeholder. Omitting it cascades into misleading "different parameter numbers" / "out of search scope" / "operation is not applicable to null" errors. Seereferences/closures-catalog.md. - The Java parser cannot produce smodel/collection types in method return types, cannot parse
:Conceptcasts,.linkaccesses,.behaviorMethod()calls, orMetaAdapterFactory.getContainmentLinkinline. UseLINKS.xxx/CONCEPTS.xxxconstants and replace types post-parse. Seereferences/java-parser-capabilities.md. - Mutations need
command { … }, reads from non-UI code needread action { … }. There is no separate "write action". Behavior methods and rule bodies already hold the right lock. Seereferences/concurrent-access.md. - Pick the right cardinality:
SLinkAccessfor0..1/1;SLinkListAccessfor0..n/1..n. One pair serves both reference links and containment children (there is noSChildAccess/SChildListAccess). Wrong choice triggers "out of search scope" / "access to link X is not expected here". Seereferences/dot-expression-basics.md. - Feature references take the declaration's
sourceNode:SPropertyAccess.property,SLinkAccess.linkandSLinkListAccess.linktarget thesourceNodeof the matchingproperties[]/children[]/references[]entry frommps_mcp_get_concept_details(defaultdetail: "full";"shape"andmps_dump.py shapeomit it). Never use the concept's ownsourceNode, and neverfeatureId. An inherited feature lives in the model of the concept that declares it:name(fromINamedConcept) is alwaysr:00000000-0000-4000-0000-011c89590288(jetbrains.mps.lang.core.structure)/1169194664001. Seereferences/property-and-mutation-ops.md. foreachhas two concepts: collectionsForEachStatementforsequence/list/set, BaseLanguageForeachStatementfor Java arrays/iterables. Wrong choice → type error. Seereferences/foreach-statements.md.- Used-language imports: NF_* operations require
jetbrains.mps.lang.actionsin the model's used languages; without it,add new initialized(...)etc. fail. Seereferences/property-and-mutation-ops.mdandreferences/openapi-and-dependencies.md. - Never recommend deprecated operations:
.role(use.containingLink),.linkDeclaration(use.link),.roleonSReference(use.link.name),.conceptNode_GetConceptOperation(usenode.conceptvia typesystem).
Common-path workflow
- Identify the source-of-truth layer. If the change is to existing logic in a rule/method body, inspect the current node (shallow
mps_mcp_print_node) before editing. - Prefer
parse_java_and_insertfor plain Java method bodies, expression replacements, and field declarations onLINKS/CONCEPTSinner classes. Seereferences/java-parser-capabilities.md. - For smodel/collections/closures constructs not parseable as Java, build the node blueprint by hand — open the single file the "Minimum reading set" above names for your body shape, and stop there.
- For variable declarations and method return types of MPS collection / smodel types, build the type child explicitly —
parse_java_and_insertproduces a wrongClassifierTypefor these in return-type position. Seereferences/variable-declarations.md. - Validate with
mps_mcp_check_root_node_problems(nodeReference, onlyNodesWithProblems=true). Re-read generatedsource_gen/...javaonly to confirm runtime shape — never to apply fixes. Seereferences/workflows.md. - If imports/dependencies break, add a used language or model dependency via
mps_mcp_model_used_language/mps_mcp_model_dependency/mps_mcp_module_dependency. Seereferences/openapi-and-dependencies.md.
If MPS MCP tools are unavailable, do not hand-edit serialized .mps files unless explicitly requested — inspect only and report.
Related Skills
mps-baselanguage— host BaseLanguage statements, expressions, classes; this skill is the smodel/collections/closures overlay.mps-quotations—<…>quotations and antiquotations for assembling node trees inline; use instead of long blueprint chains where they apply.mps-aspect-behavior— per-concept method authoring; behavior bodies are the most common host for this skill.mps-aspect-generator— generator query bodies,$IF$/$MAP_SRC$.mapperFunction, where this skill provides the smodel idioms.mps-aspect-typesystem— inference and checking rule bodies; uses the same idioms.mps-aspect-constraints—getScope,canBe*, property validators; same idiom set.mps-node-editing— programmatic node creation and editing from outside model code (the MCP-tool side rather than smodel-language side).mps-console— the MPS Console and thejetbrains.mps.lang.smodel.querylanguage (with-statement,#instances/#usages/#nodes/#models/#modules, scopes); use it to run or generate the smodel code in this skill across a project/repository scope, or to insert console commands viamps_mcp_insert_console_command_from_json.
Reference Index
One line per file, keyed by the symptom that should send you there. This is an index to search, not a sequence to read: per the Minimum reading set above, expect to open one entry — and a second only after an error the first cannot explain.
- Open
references/golden-rules-and-pitfalls.mdwhen an error message makes no sense — a cascadingUnknownDotCall, "out of search scope", "different parameter numbers",List<SNode>vssequence<node<X>>. The symptom→cause→fix table; the first file to open after any failure, and frequently the only one. - Open
references/java-parser-capabilities.mdbefore callingmps_mcp_parse_java_and_insert, or when it inserted something silently mis-typed — what the parser handles and the workarounds (LINKS/CONCEPTS constants instead of inlineMetaAdapterFactory, post-parsereplace_node_child, widening a signature to keep smodel casts out of arguments). - Open
references/workflows.mdwhen you know what to write but not in what order to call the tools — the two end-to-end recipes (add a helper method to a checking-rule class; replace one expression inside a rule body) and the rules for readingsource_gen/artifacts. - Open
references/concept-id-table.mdwhen a blueprint needs a hex ID or persistent node ref you do not have —MetaAdapterFactoryIDs for BaseLanguage concepts and links (ThrowStatement,CatchClause,TryCatchStatement,VariableReference, …) and node refs forType,Expression,Classifier,SequenceType,ListType,SNodeType. - Open
references/smodel-concepts-catalog.mdwhen you know the MPS surface notation but not the concept behind it (or the reverse) — every smodel concept (SNodeType,SLinkAccess,Node_GetAncestorOperation,OfConceptOperation,Concept_*Operation,EnumMember_*, …) with its ID. Search it for the one name you need; it is not prose. - Open
references/baselanguage-key-concepts.mdwhen the host BaseLanguage concept is the piece missing from a blueprint — the short list this skill keeps reaching for (DotExpression,ForeachStatement,BlockStatement,NPE*Expression,UndefinedType). - Open
references/concurrent-access.mdwhen the code runs outside a rule or behavior body — an IDE action, tool, plugin hook or migration — and reads or mutates a model:command,read action,execute command in EDT,undo-transparent command. Also read it before wrapping a body that already holds the lock in anothercommand. - Open
references/collections-catalog.mdwhen you need a sequence/list/set/map operation whose name or shape you are unsure of (where,select,translate,any,take,sortBy,reduceLeft,toList, …), asequenceis rejected where alistis required,isEmptyresolves to the wrong language, or a lazy sequence is evaluated twice — plus the type hierarchy (sequence⊃list/set;map), creators, mutators, sorted variants, anditeratorvsmodifying_iterator. - Open
references/closures-catalog.mdwhen a closure does not type-check — "different parameter numbers", a parameter whose type stayed null, recursion (InvokeFunctionOperationvsInvokeExpression),yieldvsreturnexclusivity, SAM conversion, the generated-Java form, or the missing closures runtime jar. Holds theClosureLiteral/InferredClosureParameterDeclaration/FunctionTypeshapes. - Open
references/dot-expression-basics.mdfor any body, as the Minimum reading set says, and whenever aDotExpressionchain must be built or repaired — cardinality (SLinkAccessvsSLinkListAccess, one pair for both references and children); an operand that must be cast to a typednode<X>viaSNodeTypeCastExpression; navigation (.link,.parent,.children,.ancestor<C>,.ancestors<C>,.descendants<C>, include-self+);node:Cvsnode as C;expr/(SemanticDowncastExpression) anddowncast expr(DowncastExpression) for crossing into Java APIs;.isInstanceOf/.isNotNull/.isNull/.behaviorMethod(args);where/any/translate/list.add. Has its own jump table — read one section. - Open
references/property-and-mutation-ops.mdwhen the body reads or writes a property, or changes the tree —SPropertyAccess, assignment,Property_RemoveOperation;SNodeCreator,add new(C),set new(C),replace with new(C)/replace with(other),.copy,.detach, sibling inserts; and theNF_*factory-initialized variants with theirjetbrains.mps.lang.actionsused-language requirement. - Open
references/references-and-queries.mdwhen you are holding anSReferencerather than a node, or navigating sideways —Node_GetReferenceOperation(.reference/C:role/),Node_GetReferencesOperation,Reference_GetTargetOperation;.siblings/.next-sibling/.prev-sibling*,.containingRoot/.containingLink/.model/.index,.isExactly(C),seq.ofConcept<C>,seq.ofAspect<a>, enum-member operations. - Open
references/attribute-access.mdwhen an annotation or attribute is in play — a generator macro, a comment, a requirement trace: the.@operator (AttributeAccess+NodeAttributeQualifier/LinkAttributeQualifier/ChildAttributeQualifier/PropertyAttributeQualifier/AllAttributeQualifier) to read, attach/replace (assignable l-value) or remove one, the list semantics ofmultipleattributes (.@role.add(...)), and chaining into the children/refs/properties it grafts onto a node. Pairs withreferences/attributes-and-annotations.mdin themps-aspect-structure-conceptsskill root after loading that companion skill from the same origin (the structure side). - Open
references/link-and-concept-literals.mdwhen an API wants anSContainmentLink/SReferenceLink/SConceptargument and there is no precedingnode.operand to hang it on — standalonelink/C : role/(LinkIdRefExpression, two required refs) andconcept/C/(ConceptIdRefExpression), and how both differ fromOperationParm_LinkQualifierandRefConcept_Reference. - Open
references/foreach-statements.mdwhen iterating produces a typesystem error, or the loop variable will not resolve — the twoforeachconcepts (collectionsForEachStatement+ForEachVariable/ForEachVariableReferencevs BaseLanguageForeachStatement+LocalVariableDeclaration/VariableReference). - Open
references/node-equality.mdbefore comparing two nodes — theNPEEqualsExpression(:eq:) andNPENotEqualsExpression(:ne:) blueprints, and why==/.equals()is wrong here. - Open
references/variable-declarations.mdwhen a declared type is rejected or came out wrong — type-child choices for locals, parameters and return types (node<C>,nlist<C>,node-ptr<C>,concept<C>,search scope,enummember<E>,sequence/list/set<node<C>>,boolean); creator blueprints (new arraylist<node<C>>,new hashset<node<C>>, …); and the post-parse fix-ups for areturnTypethe Java parser produced asList<SNode>. - Open
references/openapi-and-dependencies.mdwhen you hit "Concept not imported", "cannot resolve", or a class missing at runtime — which layer to fix (module dependency vs model dependency vs used language) and the matching MCP tool, plus theorg.jetbrains.mps.openapi.*interfaces and threading rules for hand-written Java calling into models.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

