matlab/resolve-design-errors
Use when asked to run Design Error Detection (quick defect scan), find design errors in a Simulink model, perform root cause analysis on DED findings, fix division-by-zero, overflow, dead logic or out-of-bounds defects detected by SLDV, or diagnose why missing coverage cannot be achieved (dead logic blocking coverage objectives). Do NOT use for requirement verification, test generation, Inf/NaN detection, active logic analysis, or coverage measurement.
npx skills add https://github.com/matlab/simulink-agentic-toolkit --skill resolve-design-errors
.mat file) and wants analysis without re-running DEDRequires: MATLAB R2023b+, Simulink Design Verifier, Simulink Check / Model Slicer.
All script functions live in the skill's scripts/ directory. Use evaluate_matlab_code with project_path set to that folder so MATLAB can find them.
This skill provides two functions that automate SLDV-driven analysis the agent otherwise gets
wrong when hand-rolling it, then hands you the facts to classify and fix findings. The workflow
is four steps:
1. Detect errors → sldv_run_defect_checker (use the function; don't hand-roll DED)
2. Root cause errors → sldv_find_de_root_cause (use the function; don't hand-roll slicing)
3. Classify errors → agent step (dead logic: intentional vs. design_error)
4. Fix errors → agent step (propose, get approval, clone-fix-verify)
Steps 1–2 are the two functions. Steps 3–4 are agent judgment based on their output. Full API
detail (return fields, options, caching, sub-functions) is in references/api-reference.md —
load it when you need exact fields or options.
Call sldv_run_defect_checker(model) instead of writing your own SLDV DED invocation or
parsing objectives by hand — it configures the analysis, runs DED, and auto-loads cached
*_sldvdata.mat results when available.
result = sldv_run_defect_checker("my_model", OutputDir="artifacts/ded")
If result.Status == "pass": STOP. Report "No design errors of the checked types were
detected" and end the workflow. Do NOT call sldv_find_de_root_cause or investigate further.
DED is a quick scan, not an exhaustive proof — tell the user no defects of the checked types
were found, not that the model is error-free.
Proceed to Step 2 only when result.Status == "fail".
Call sldv_find_de_root_cause(model, DedResult=result.DedResult) instead of hand-building
slices — it returns backward slices, counterexamples, locality (blast-radius) measures, and
shared-root cascade annotations for every finding.
rca = sldv_find_de_root_cause("my_model", DedResult=result.DedResult, OutputDir="artifacts/ded")
Then trace each finding to its root cause:
rca.SliceBlocks to find which block produces thedefect-triggering value
model_overview / model_read to understand each block's roleLocality blocks (narrow blast radius, safer) and high-FindingCount blocks(fix resolves more defects); check rca.Cascades — a shared-root fix resolves multiple
findings at once
When the slice is shallow (< 3 blocks) or stops at a Stateflow / MATLAB Function block:
the Model Slicer cannot trace through those constructs. Do NOT stop and report only what the
tool returned — fall back to model_read / model_overview to interpret the finding: read
the defect block and its upstream connections, read the Stateflow chart or MATLAB Function
logic the slice stopped at, and cross-reference counterexample values to see which branch is
active.
Classification happens after root cause analysis — you need to see the root cause (which
block, what value) before deciding whether dead logic is intentional.
Findings arrive pre-enriched. For every dead logic finding, sldv_find_de_root_cause
attaches on the finding struct:
finding.ModelContext — a model_read dump of the block's surrounding scope. You do notneed to call model_read again for this. (If empty — model_read was unavailable — fall back
to model_overview / model_read yourself for that block.)
finding.PatternCatalog — the entire dead-logic pattern library (catalog index + everypattern), concatenated. You do not need to open the YAML files yourself.
finding.Classification — "pending", awaiting your decision.How to classify. For each dead logic finding, using ModelContext and PatternCatalog:
PatternCatalog.complementary Stateflow guards) or is it a BUG (wrong parameter, cascading error)?
Set the classification:
"intentional" — defensive logic, enable-as-input, negation guard pairs → no fix needed;report to the user as expected behavior
"design_error" — wrong parameter, cascading dead logic, short-circuit → fix the root cause"unclassified" — unclear → ask the userOnly apply fixes for "design_error" findings.
The functions provide facts; you identify root causes and decide fixes — there is no hardcoded
defect-to-fix mapping.
When you are ready to propose or apply a fix, load and follow references/fix-strategy.md.
It covers root-cause identification, the clone-fix-verify procedure, fix principles, and the
blast-radius discussion required for every proposal.
Two rules that always apply (see Safety Rules): present findings and wait for explicit approval
before applying anything, and propose a fix for every design_error finding — 2–3 ranked
options each when possible — rather than stopping after only some.
| Mistake | Fix |
|---------|-----|
| Continuing after Status == "pass" | STOP. Zero falsified objectives = no defects. Do not call sldv_find_de_root_cause or investigate further. Report "no defects found" and end. |
| Calling sldv_find_de_root_cause without DedResult or DataFile | Pass one of the two — check result.DedResult from the checker |
| Running on an unsaved model | Save first; DED needs a file on disk |
| Applying fixes without presenting findings to user | Always show root cause analysis results first, get approval before fixing |
| Stopping at a shallow slice | Fall back to model_read / model_overview (Step 2) |
| Running on large models without OutputDir | Set OutputDir to avoid temp-dir clutter |
Take matlab/resolve-design-errors from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.