AI assistants
Spec42 gives AI assistants such as Copilot, Cursor and Claude structured SysML v2 / KerML feedback through the CLI. Raw @workspace text alone is not enough for reliable modeling.
When to use what
| Surface | Best for |
|---|---|
| LSP (VS Code extension) | Human editing: live diagnostics, hover, completion, navigation, and typed feature inspection |
| VS Code Language Model Tools (Copilot Agent, VS Code 1.99+) | Four built-in tools via the bundled spec42 CLI — no extra config in VS Code |
CLI spec42 check / doctor / explain-diagnostic / model-export | CI, scripts, other AI hosts (Cursor, non-VS-Code Copilot), LM Tools backend |
The language server does not expose its graph directly to Copilot Chat. Run the CLI after substantive model edits.
VS Code Copilot (language model tools)
With VS Code 1.99+ and the Spec42 extension, Copilot Agent can use four built-in tools (#spec42Check, #spec42Doctor, #spec42ModelExport, #spec42ExplainDiagnostic). The extension runs the bundled spec42 binary (check, doctor, explain-diagnostic, model-export with JSON output).
Requirements:
- Open a workspace folder (or a
.sysml/.kermlfile) so toolwhenclauses match. - Optional: set
spec42.libraryPathslike for the language server.
Other hosts (Cursor, Copilot without VS Code LM Tools, …)
Point the host at the spec42 binary directly, driven by a per-host skill/instructions doc (see .github/copilot-instructions.md for the pattern). There is no MCP server or HTTP API — every surface, including VS Code LM Tools, calls the same CLI JSON output described below.
CLI commands (agent workflow)
See the CLI reference for every command and option. Recommended order when debugging a workspace:
spec42 doctor— standard library, config dirs, library paths, Sysand detectionspec42 check— validation report (summary.error_count, per-filediagnostics[].code,advice)spec42 explain-diagnostic --code <code>— stable explanation for a diagnostic code (optional concrete instances via--path+--line)spec42 model-export <path>— validation summary plus a read-only,schema_version-stampedprojectionof the workspace's resolved structure (elements with their relationship families, resolved expression trees and metadata annotations; connectors; a publication envelope). Unbounded by default;--max-nodesbounds the element list, andprojection.truncationalways reports the full count alongside how many were returned.
spec42 check path/to/model.sysml --format json
spec42 explain-diagnostic --code unresolved_type_reference --format json
spec42 model-export path/to/model.sysml --max-nodes 500 --format json
spec42 doctor --format jsonGlobal flags: --library-path, --config, --stdlib-path, --no-stdlib.
For the full field-by-field description of the export, see the model export reference.
spec42 check response
summary:error_count,warning_count,document_countdocuments[]:uri,diagnostics[]withcode,message, LSPrangeadvice: environment hints (e.g. missing standard library)
Use summary.error_count to decide if the model is clean.
Agent workflow
- Edit
.sysml/.kermlin the editor (or let the agent patch files). - Run
spec42 checkon the changed file or project directory; pass--workspace-rootwhen validating a single file inside a multi-file project. - For each distinct
code, usespec42 explain-diagnosticif the fix strategy is unclear. - If many
unresolved_*diagnostics appear, runspec42 doctorbefore rewriting imports or types. - For structure (what specializes what, which elements carry a metadata tag, connector topology), read
model-export --format json'sprojection. It is the resolved publication, not a guess from source text; branch onprojection.schema_version.
Related guides
- Features and support: release-gating editor and CLI workflows
- Validation and diagnostics: the
spec42 checkcommand and its reports - Troubleshooting: server, libraries, indexing
- GitHub Actions: CI validation
- Model export reference: the JSON written by
model-export