mps-aspect-constraints
Skill1.7k starsChanged 2 months agoApache-2.0View on GitHub
Use when defining or editing MPS language constraints — property validators / setters / getters, referent search scopes (imperative or inherited via `ScopeProvider.getScope`), `referentSetHandler` side effects, default-scope blocks, `canBeChild` / `canBeParent` / `canBeAncestor` / `canBeRoot` placement rules, `defaultConcreteConcept` for abstract concepts, `set <read-only>` and `{name}` aliasing, and scope helpers (`SimpleRoleScope`, `ListScope`, `CompositeScope`, `HidingByNameScope`). Reach for this skill whenever the task involves authoring or modifying `<lang>/languageModels/constraints.mps`.
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-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-model-manipulationSkill
- 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
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 59
Ensure the language has a constraints model.
- Very specific: line 60
Add jetbrains.mps.lang.constraints to the model's used languages.
- Very specific: line 63
Add NodePropertyConstraint / NodeReferentConstraint / canBe* children as needed.
- Very specific: line 64
Write bodies in BaseLanguage + smodel — follow the mps-model-manipulation skill for smodel / collections / closures syntax.
≈ “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
MPS Constraints Aspect
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.
The constraints aspect controls runtime rules about nodes: what values properties may hold, how a property is stored when set, what nodes a reference may point to, and where a node of a concept is allowed to appear in the AST. It lives in the language's constraints model (<lang>/languageModels/constraints.mps) and uses the language jetbrains.mps.lang.constraints.
Constraints are enforced at edit time and also consulted by the typesystem/editor. They are not the place for structural cardinalities (that belongs in structure) or for types (that belongs in typesystem).
Critical Directives
- One
ConceptConstraintsroot per concept. Set itsconceptreference; everything else is child blocks. - Pick the right body for the job:
- Validator (
propertyValidator) — pure acceptance check; returnsboolean; never mutates state. - Setter (
propertySetter) — normalises and must explicitly assignnode.<prop> = propertyValue(a body that forgets this silently drops the value). - Getter (
propertyGetter) — only when the displayed value differs from the stored value (derived URL, aliased name). set <read-only>means no setter at all — direct assignment to the property is rejected by MPS. An empty-body setter is almost always a bug.
- Validator (
canBeChild/canBeParent/canBeAncestorare inherited by sub-concepts; per-property and per-reference constraints are not — duplicate theConceptConstraintsroot or hoist the rule up.- Pick the right scope shape:
- Inherited via
InheritedNodeScopeFactory+ScopeProvider.getScope(behavior) — preferred whenever the scope naturally belongs to an ancestor (block, declaration, program, module). Composes cleanly along the containment chain withparent scope. - Imperative
ConstraintFunction_ReferentSearchScope_Scope— only when the scope is tiny, highly local, and has no natural ancestor owner.
- Inherited via
referentSetHandlerperforms side effects (auto-rename referrer, copy fields,keeps original reference). Never overload the scope to do this.defaultConcreteConceptonConceptConstraintschooses which concrete subconcept replaces an abstract pick — it is a single reference, not a child block.- Surface forms (
come from,parent scope,kind.isSubConceptOf(...),link/C : role/,concept/C/) are not BaseLanguage. Each is a dedicatedjetbrains.mps.lang.scopes/jetbrains.mps.lang.smodelconcept — construct those concepts, not strings (seereferences/scope-fqn-reference.md). Concept_IsSubConceptOfOperationmatches a concept and its sub-concepts;Concept_IsExactlyOperationexcludes sub-concepts. UseisExactlyfor guards that must not fire on specialisations.- Edit constraint models through MPS MCP (
mps_mcp_insert_root_node_from_json,mps_mcp_update_node,mps_mcp_parse_java_and_insert). Do not hand-edit.mpsfiles. Validate withmps_mcp_check_root_node_problemsand rebuild the language; if the new constraint is invisible at runtime, runmps_mcp_reload_all.
Section index — one row, one read
Each row names the file(s) for one job. Read them — two files in one parallel batch — and nothing else in references/.
| Job | Read |
| have not chosen scope style yet | references/referent-constraints/choosing-scope-style.md |
| scope computed at the reference site (shape + verbatim example) | references/referent-constraints/imperative-scope.md, references/referent-constraints/imperative-scope-calculator-example.md |
reference-site scope over a computed sequence (ListScope + anonymous getName) | references/referent-constraints/computed-sequences-listscope.md, references/referent-constraints/computed-sequences-blueprint.md |
reference-site scope assembled with CompositeScope.addScope | references/referent-constraints/composite-scope-addscope.md |
reference-site scope over imported models' roots (rootsIncludingImported) | references/referent-constraints/cross-model-filtered-scope.md |
scope that offers structure declarations (LinkDeclaration referents) | references/referent-constraints/meta-level-scope.md |
| scope belongs to an ancestor / getScope | references/referent-constraints/inherited-scope.md |
| setting a ref must rename/copy/keep original | references/referent-constraints/referent-set-handler.md |
| every ref to this concept shares one scope | references/referent-constraints/default-scope.md |
| validator / setter / getter shape | references/property-constraints/nodepropertyconstraint-shape.md |
| validator / getter / setter wrapper FQNs | references/property-constraints/key-concept-fqns.md |
| validator JSON blueprint | references/property-constraints/validator-example-compound-cardinality.md |
| derived-getter JSON blueprint | references/property-constraints/derived-getter-example.md |
| sibling-uniqueness validator | references/property-constraints/sibling-uniqueness-validator.md |
| {name} alias / set read-only | references/property-constraints/getter-delegation-read-only.md |
Common-Path Workflow
- Ensure the language has a
constraintsmodel; create it withmps_mcp_create_model(moduleName: "<lang>",modelName: "<lang>.constraints"— aspect IDconstraints, case-sensitive, no@suffix; see aspect-model-stereotypes.md) if absent. - Add
jetbrains.mps.lang.constraintsto the model's used languages. For scope bodies also addjetbrains.mps.lang.smodel,jetbrains.mps.lang.scopes,jetbrains.mps.lang.behavior,jetbrains.mps.baseLanguage; import modelsjetbrains.mps.scopeandjetbrains.mps.lang.core.behavior.- Module-level dependency for scope classes: the language module must have a
Defaultdependency on solutionjetbrains.mps.kernel(which ships modeljetbrains.mps.scope).mps_mcp_model_dependencyadds it automatically when importingjetbrains.mps.scope;mps_mcp_create_module type=languagedoes not. Seereferences/scope-fqn-reference/required-languages-imports-dependencies.md.
- Module-level dependency for scope classes: the language module must have a
- For each concept to constrain, create one
ConceptConstraintsroot (mps_mcp_create_root_node); setconceptref. Minimal blueprint and validated FQN/c-ref inreferences/concept-roots.md. - Add
NodePropertyConstraint/NodeReferentConstraint/canBe*children as needed. For inherited scopes, also add agetScopemethod to the owning ancestor'sConceptBehavior(seemps-aspect-behavior). - Write bodies in BaseLanguage + smodel — follow the
mps-model-manipulationskill for smodel / collections / closures syntax. Prefermps_mcp_parse_java_and_insertfor the BaseLanguage skeleton, then drop in scope / constraint-specific concepts via MCP. - Validate with
mps_mcp_check_root_node_problemsand rebuild the language.
Related Skills
mps-aspect-behavior—ScopeProvider.getScopelives in the behavior aspect; this is the partner of everyInheritedNodeScopeFactoryconstraint. Behavior is also where most validator/getter delegation lands.mps-aspect-structure-concepts— structural cardinalities belong instructure, not here. AddINamedConcept/IResolveInfo/ScopeProviderinterfaces on the concept declaration before writing the matching constraint or scope.mps-aspect-editor-menus-and-keymaps— completion menus consume the scope built here; substitute / transformation menus are the place for actions that go beyond picking an existing target.mps-aspect-actions— when a constructor-style initialization is needed, useNodeFactory(actions aspect), not a constraint.mps-aspect-intentions— when a suggested fix belongs on a node, write an intention; constraints only accept or reject.mps-model-manipulation— full BaseLanguage / smodel / collections / closures reference for constraint and scope bodies; for a scope orcanBe*body open onlyreferences/dot-expression-basics.mdin themps-model-manipulationskill root after loading that companion skill from the same origin. Indispensable forancestor<concept = X, +>,selectMany,siblings.ofConcept<X>.all(...), anonymous-class scopes, and the smodel operation FQNs.mps-aspect-typesystem— type checks belong in typesystem; constraints are about value/scope/placement.mps-aspect-textgenandmps-aspect-constraints-co-located utility classes — seereferences/concept-roots.mdfor the BaseLanguageClassConceptco-location pattern (used byXmlNameUtil).
Reference Index
Start here — most common case: creating the ConceptConstraints root or setting defaultConcreteConcept → read only references/concept-roots.md. A property validator / setter / getter, a referent search scope, or a referentSetHandler → read the file(s) in the matching Section index row above.
- Open
references/concept-roots.mdwhen creating theConceptConstraintsroot, settingdefaultConcreteConceptto a concrete subconcept of an abstract concept, looking up the validated concept c-ref, or co-locating a BaseLanguage helperClassConceptnext to constraint roots. - Open the Section index row for
references/property-constraints.mdwhen writingNodePropertyConstraintbodies — validator vs. setter vs. getter shape, wrapper FQNs, the validator / derived-getter JSON blueprints, the{name}aliasing pattern withset <read-only>, or sibling-uniqueness validators. - Open the Section index row for
references/referent-constraints.mdwhen writingNodeReferentConstraint— choosing scope style, imperativeConstraintFunction_ReferentSearchScope_Scope, ancestor-suppliedInheritedNodeScopeFactory,referentSetHandler, or concept-levelDefault Scope. - Open
references/scope-helpers.mdwhen picking amongEmptyScope,ListScope,SimpleRoleScope,CompositeScope,FilteringScope,DelegatingScope,ModelsScope,ModelPlusImportedScope,Scopes.forConcepts,HidingByNameScope, orListScope.forResolvableElements; or when caching withfor model [...],visible roots [C],visible nodes [C]. Includes the verbatim StateChartStateful_Behavior.getScope(ListScope+ anonymousgetName+HidingByNameScopeoverparent scope) idiom. - Open
references/scope-fqn-reference.mdwhen constructing scope bodies via MCP — the full surface-syntax-to-FQN table (parent scope,come from,isSubConceptOfvsisExactly,RefConcept_ReferencevsConceptIdRefExpression,LinkIdRefExpression,Node_GetAncestorOperation+OperationParm_Concept,Node_GetDescendantsOperation,Node_GetModelOperation,Model_RootsIncludingImportedOperation,Node_GetParentOperation,Node_IsInstanceOfOperation), required used-languages and model imports, the validatedScopeProvider.getScopeoverriddenMethod ref, and JSON blueprints for thegetScopeskeleton,parent scopereturn, and the guarded local-scopeif-branch. - Open
references/canbe-rules.mdwhen authoringConstraintFunction_CanBeAChild/CanBeAParent/CanBeAnAncestor/CanBeARoot— each block's parameter set (notecanBeAnAncestorhas only 3 parameters; noparentNodeorlink), theparentNode.parent.isInstanceOf(...)grandparent-traversal pattern (KajaRoutineDefinitionandRequire), thenode.isInRole(link/C : role/)pattern, themodelparameter forcanBeRoot, and the minimalConstraintFunction_CanBeAChildblueprint. - Open
references/common-failures.mdwhen a setter runs but stores nothing, a completion popup is empty, the editor reports "cannot be child", a constraint does not apply to a sub-concept, or constraint edits seem invisible at runtime.
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.

