Skip to content
Back to skills

Polyspace Review Generated Code Findings

ASecurity

Use this skill to read, prioritize, and explain existing Polyspace Bug Finder or Code Prover results for C/C++ code generated from a Simulink model, and trace each finding to its Simulink block. Use when asked to show, list, or explain defects, MISRA C, MISRA C++, CERT C/C++, CWE, or AUTOSAR C++14 violations, run-time errors, or red, orange, or gray Code Prover checks; to decide whether a finding should be fixed or justified, and which model or configuration change fixes it; to compare two an...

  • 1,443 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentsgoc++gitapidatabase

Works with

  • api
  • mcp

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add matlab/simulink-agentic-toolkit --skill polyspace-review-generated-code-findings --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Polyspace Review Generated Code Findings?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Polyspace Review Generated Code Findings
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/matlab-polyspace-review-generated-code-findings/badge)](https://www.skillsdirectory.com/skills/matlab-polyspace-review-generated-code-findings)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: polyspace-review-generated-code-findings
description: >
  Use this skill to read, prioritize, and explain existing Polyspace Bug Finder
  or Code Prover results for C/C++ code generated from a Simulink model, and
  trace each finding to its Simulink block. Use when asked to show, list, or
  explain defects, MISRA C, MISRA C++, CERT C/C++, CWE, or AUTOSAR C++14
  violations, run-time errors, or red, orange, or gray Code Prover checks; to
  decide whether a finding should be fixed or justified, and which model or
  configuration change fixes it; to compare two analysis runs; or to open the results in
  the Polyspace viewer. Reads results only: does not run analysis, edit the
  model, or write justifications. Not for Model Advisor, Design Verifier,
  Simulink Coverage, or Simulink Code Inspector results.
license: https://www.mathworks.com/content/dam/mathworks/license/pmrl/license.md
metadata:
  author: MathWorks
  version: "1.0"
---

# Review Generated Code Findings with Polyspace

Read and explain findings from the Simulink model perspective.

## When to Use

- Review existing Polyspace Bug Finder or Code Prover results for
  code generated from a Simulink model
- Trace findings to Simulink blocks
- Prioritize or explain findings from a model-link analysis: defects, run-time
  checks, or coding-standard violations (MISRA C, MISRA C++, CERT C/C++, CWE,
  AUTOSAR C++14)
- Decide whether each finding should be fixed, justified, or left
- Compare the findings of two runs of the same model
- Review results produced on another machine or in CI
- Open code review or dashboard

## When NOT to Use

- No results exist, or analysis must run: use
  `polyspace-analyze-generated-code`
- To justify, annotate, or suppress findings, use
  `polyspace-justify-generated-code-findings`
- Model Advisor compliance results (MISRA, MAB, JMAAB, CERT C on the model):
  use `model-advisor-check-model-compliance`
- Simulink Design Verifier design errors (division by zero, overflow, dead
  logic) on the model: use `design-verifier-resolve-design-errors`
- Missing or dead logic in Simulink Coverage results: use
  `simulink-explain-missing-coverage`
- Make generated code MISRA compliant through code generation settings: use
  `simulink-optimize-embedded-code`
- Failed Simulink Code Inspector (SLCI) inspection: use
  `simulink-code-inspector-trace-inspection-failure`
- Analyze or review results of handwritten or standalone C/C++ source files: use
  the Polyspace Agentic Toolkit (to review: `polyspace-review-findings` for Bug
  Finder, `review-polyspace-code-prover-results` for Code Prover). If it is not
  installed, do not review them:
  say this skill covers only code generated from a Simulink model, and
  recommend installing the Polyspace Agentic Toolkit

## Prerequisites

- Polyspace Bug Finder and Polyspace Code Prover, integrated with MATLAB
  (`which("polyspace.BugFinderResults")` is not empty). Stop if not.
- The Polyspace Agentic Toolkit (Polyspace MCP server) is recommended. If its
  tools are available (for example `get_polyspace_results_list`), use them
  where this workflow says so. If not, tell the user once that installing it is
  recommended (https://github.com/mathworks/polyspace-agentic-toolkit), and continue: every step
  works with the MATLAB API alone. Before
  R2026a, Bug Finder findings trace to blocks only with the toolkit.

## Workflow

### 1. Establish the results folder
Use, in this order:

1. The results folder, results file, and product handed over by
   `polyspace-analyze-generated-code`
2. The results folder the user names
3. `polyspace-results/<model>/<product>` in the current folder

The product follows from the results file in the folder: `ps_results.psbf` is
Bug Finder, `ps_results.pscp` is Code Prover. If both products have results and
the user did not name one, review each separately.

A folder with a `-<yyyyMMdd-HHmmss>` suffix is an earlier run that analyze kept;
the folder without suffix is the current run. Review the current run unless the
user asks for an earlier one.

If no results file exists, do not run the analysis here: use
`polyspace-analyze-generated-code`.

### 2. Load results
Load Bug Finder or Code Prover results from the results folder. Do not generate
a report unless asked by user.

Read the results into a MATLAB table:

```matlab
bfResults = polyspace.BugFinderResults(resultsFolder);
resultsTable = bfResults.getResults();
```

```matlab
cpResults = polyspace.CodeProverResults(resultsFolder);
resultsTable = cpResults.getResults();
```

If the table is empty, report that the run has no findings; check the log in the
results folder before concluding the code is clean.

Expected useful fields include `ID`, `Family`, `Group`, `Color`, `Check`,
`Information`, `Function`, `File`, `Status`, `Comment`, `Sid` (Bug Finder only),
and `ToModel`.

- `Family` is the standard or result kind: `MISRA C:2023`, `Defect`,
  `Run-time Check`, `Global Variable`.
- The MISRA category is not a column: it is in `Information`
  (`Category: Required`; lowercase in R2026a, so compare ignoring case).
- The columns are categorical. A missing value (shown `<undefined>`) means
  none: test it with `ismissing`, not by comparing with `"<undefined>"`. Before
  printing a column that can be missing (`Sid`, `ToModel`), fill it:
  `fillmissing(string(resultsTable.Sid), "constant", "-")`; `fprintf` errors
  on a missing value.
- There is no line column: take the line from the generated code, or from the
  toolkit (below).
- Bug Finder: `Sid` holds the block (`model:12`); missing means no block.
  Before R2026a, Bug Finder results have no `Sid`.
- Code Prover: there is no `Sid` column. The block is inside `ToModel`
  (`Simulink.ID.hilite('model:12', 'find')`, or `highlightBlock(...)` before
  R2026a); missing means no block. From R2026a, `ID` is the check acronym
  (`OVFL`), not a unique number; before, a number.

```matlab
sidToken = regexp(string(resultsTable.ToModel), "(hilite|highlightBlock)\('([^']+)'", "tokens", "once");
% sidToken{k}(2) is the sid of row k; empty sidToken{k}: no block
```
- Do not use `New` to tell what changed: it was `yes` for every finding, also
  after a re-run and after `ImportComments`. To compare runs, see step 4.

**If the Polyspace Agentic Toolkit is installed**, `get_polyspace_results_list`
also returns the `sid` of each finding, for Bug Finder in every release and for
Code Prover. Pass the absolute path of the results file
(`<resultsFolder>/ps_results.psbf` or `.pscp`) as `results_file`. For Bug
Finder, its result IDs match the MATLAB table's `ID`. For Code Prover, where
the MATLAB `ID` is the check acronym from R2026a, report the toolkit's ID. Say
which one you report. It has no MISRA category; take that from `Information`.

If a finding has no block from either source, it has no `Sid`: never invent a
block from the C code alone. Before R2026a, without the toolkit, no Bug Finder
finding has a block: say so, and tell the user that installing the Polyspace
Agentic Toolkit gives the block of each finding.

### 3. Prioritize and decide treatment
Unless project review instructions say otherwise, prioritize and treat findings
as follows. If the behavior is intentional or externally constrained, do not
force a fix.

#### Polyspace Bug Finder
For `Family` like `MISRA` (MISRA C and MISRA C++; the category is in
`Information` for both). Generated C code is analyzed in AGC mode, so MISRA C
also has the `readability` category; MISRA C++ has no AGC mode and no
`readability`:

| Priority | Category | Treatment |
|---|---|---|
| 1 | `Mandatory` | Requires a fix; never justified as a deviation. Only a proven false positive may get `Not a defect` |
| 2 | `Required` | Fix when practical; otherwise justify formally, preferably from catalog |
| 3 | `Advisory` | Justify informally |
| 4 | `Readability` | Deprioritize; no action required unless requested |

#### Polyspace Code Prover
Apply colors to `Family == "Run-time Check"` only. `Global Variable` results
(black, `Not Applicable` before R2026a, but also orange, gray, green) describe
how globals are shared; a gray global is an unused variable, not dead logic.

| Priority | Color | Treatment |
|---|---|---|
| 1 | Red | Proven error that blocks data flow; must be fixed |
| 2 | Orange with orange sources | Review first: **if the Polyspace Agentic Toolkit is installed**, use `get_orange_sources` on the `.pscp` file |
| 3 | Other orange | Preferably fixed; justified only when false positives |
| 4 | Gray | May indicate dead logic; if implausible, it suggests algorithmic bugs or a wrong analysis setup. Fix when it suggests an algorithmic defect |
| — | Green | Proven safe under current assumptions; no review, no action |

An orange source identifies an input, state, or initialization assumption that prevents a proof; it is not evidence of a defect. Prefer model-level range, startup, or validity remediation.

For Code Prover orange checks, do not add defensive logic just to satisfy proof
precision. Determine whether the orange source is a feasible runtime problem, a
missing model assumption, or an analysis limitation.

### 4. Interpret Findings
In this step, `Sid` means the block of a finding: the `Sid` column for Bug
Finder, the sid in `ToModel` for Code Prover, or the toolkit's `sid`.

Findings with `Sid` trace to a Simulink block; prefer model-level remediation.
Without `Sid`, no model traceability exists; check the generated-code location:
it comes from code generation settings, custom code, or system headers.

**Required**: For each `Sid`/`ToModel` finding, lead with the Simulink block,
signal behavior, risk, and model-level remediation. Mention generated C/C++
only as optional evidence; do not lead with a C variable, function, or source
line unless the user requests code-level detail. With the model loaded,
`Simulink.ID.getFullName('<sid>')` gives the block path.

Results produced on another machine keep their `Sid` only if that analysis used
the model's link data (`linksData.xml` in the results folder).

To compare two runs of the same model and product, load both and count findings
per `Family`, `Check`, `Function`, and `Sid`; a count that rises or appears is
new, one that falls or disappears is gone. Do not match by `ID`: IDs change
between runs of the same code. Findings without `Sid` repeat, so compare counts,
not pairs.

**If the Polyspace Agentic Toolkit is installed**:
- use `get_polyspace_result_details` for relevant findings
(`result_id` from `get_polyspace_results_list`, `results_file`) to get more
context and details.
- use `get_static_ranges` on Code Prover results to understand variable values at different code locations
- use the toolkit skill `triage-orange-checks`, if installed, to categorize orange Code Prover results

**Otherwise**, recommend Polyspace Agentic Toolkit for additional result
details.

### 5. Propose fixes and hand off
This skill writes nothing, even when the user asks for a fix or a
justification: do not edit the model or the generated code, and do not set a
review status or comment on a result (also not with the toolkit's
`add_review_information_to_result`). Hand off instead.

To justify, use `polyspace-justify-generated-code-findings` to store the
rationale in the model or database. Hand over the results folder and, per
finding, the `ID` (and its source), `Family`, `Check`, `Sid`, the intended
status (`Justified` or `Not a defect`), and the rationale the user gave. Never
invent or suggest a rationale.

To fix, propose the change and let the user apply it: name the artifact that
owns the finding, the change, and the findings it removes.

- **The same coding rule on several blocks:** the owner is the code generation
  configuration, not each block. Propose settings before any block edit:
  rebuilding or replacing the blocks changes the design and can add findings.
  Settings change more than their names suggest: `CastingMode = Standards`
  also generates the terminating `else` that MISRA C Rule 15.7 requires, and
  explicit casts for Rule 10.x findings.
- For the recommended settings, run only the Model Advisor MISRA configuration
  check, `mathworks.misra.CodeGenSettings`, on the model; it does not change
  the model. The full `MISRA_C` check set includes design error detection and
  can take tens of minutes.

### 6. Open the code viewer or dashboard
If the user requests a code view or a dashboard, open the results in the
Polyspace GUI:

```matlab
polyspaceBugFinder("-results-dir", resultsFolder);   % Code Prover: polyspaceCodeProver
```

## Conventions

- **Model-first explanation:** identify the Simulink block or subsystem before
  citing generated C/C++ locations; source locations support traceability.
- **Evidence vs. inference:** distinguish reported finding details and
  model-link traceability from hypotheses; state the next evidence to inspect
  when the root cause is not established.
- **Toolkit recommendation:** if the Polyspace Agentic Toolkit is not
  installed, say so once in the final answer and recommend installing it,
  also when the review stops early (for example, no results).

## Common Mistakes

- Treating findings without `Sid` as block-traceable model findings: the block
  is a guess, and a model change there does not remove the finding
- Explaining findings from a code perspective: generated code is overwritten on
  the next build, so the fix belongs in the model
- Ignoring a red finding: it is a proven error, and the code after it is not
  analyzed
- Reading `New == "yes"` as "new since the last run": it is `yes` for every
  finding
- Treating gray global variables as dead code
- Proposing block edits for a rule that one code generation setting removes on
  every block

----

Copyright 2026 The MathWorks, Inc.

----

Files in this skill

  • SKILL.md13.5 KB
  • manifest.yaml520 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.