一键导入
matlab-code-reviewer
Review, debug, and verify MATLAB or Beita Tianyuan compatible modeling code against the validated method plan and expected artifacts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Review, debug, and verify MATLAB or Beita Tianyuan compatible modeling code against the validated method plan and expected artifacts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
At a judgment point, emit the 2-3 questions only the human modeler can answer — framed as trade-offs, not answers — and refuse to answer them. The inverse of "AI answers, human confirms": here the AI asks, the human answers, then the AI assists with the consequences.
Manage the full mathematical modeling contest workflow and decide which skill should be used next.
Verify every skill that claims "completed" produced a substantive audit/review artifact on disk with ≥ 5 explicit pass items. Runs as part of the independent audit layer that does not trust any single skill's self-declaration of done.
Plan figures and tables that support the modeling logic, results, and paper narrative.
Generate publication-quality mathematical modeling figures with matplotlib, covering evaluation charts, prediction plots, optimization diagrams, mechanism schematics, heatmaps, and multi-panel layouts. Use when creating or revising figures for contest papers.
Extract, organize, and document unified model assumptions from the problem parse and candidate method pools, distinguishing necessary from simplifying assumptions.
| name | matlab-code-reviewer |
| description | Review, debug, and verify MATLAB or Beita Tianyuan compatible modeling code against the validated method plan and expected artifacts. |
| license | MIT |
Review MATLAB / 北太天元 compatible modeling code after scripts have been generated and routed by code-reviewer.
This skill checks whether .m scripts are runnable, consistent with the validated method plan, compatible with MATLAB / 北太天元 constraints, and able to produce traceable result and figure artifacts.
This skill may make minimal code fixes when needed, but it must not change the modeling route or silently alter assumptions.
This skill does not select models, clean raw data, invent results, write paper sections, or approve final submission.
Use this skill:
code-reviewer routes MATLAB scripts to matlab-code-reviewer.implementation.target = matlab..m files.The following should already exist or be provided:
implementation.target = matlab.workspace/code/matlab/.workspace/data/data_clean/, if data is required.workspace/results/.workspace/figures/.If generated scripts are missing, hand back to matlab-model-code-generator.
If cleaned data is missing, hand back to data-auditor-cleaner.
If implementation.target is not matlab, hand back to code-reviewer.
Use or request:
workspace/problem/method-selector/method_plan.jsonworkspace/code/matlab/workspace/data/data_clean/workspace/data/data_report.md, if availabledata-auditor-cleanerbeita-tianyuan-compatibleavoid-heavy-toolboxesprefer-basic-matrix-and-table-operationsavoid-live-scriptsavoid-app-designersave-portable-artifactsConfirm MATLAB review target.
implementation.target = matlab..m files.workspace/code/matlab/ or clearly documented otherwise.Map scripts to the method plan.
Check MATLAB script structure.
.m scripts..m files.Check paths and artifacts.
workspace/data/data_clean/.workspace/data/data_raw/ is not modified.workspace/results/.workspace/figures/..csv, .mat, and .png.Check data-field consistency.
readtable, readmatrix, load, or equivalent input operations use expected files.Check numerical correctness risks.
NaN, Inf, or invalid numeric operations.6.5. Constraint-direction sanity check (P2 — list for human review, do NOT auto-correct).
Inequality direction errors (writing allocated ≥ capacity when it should be ≤) are semantic, not syntactic — the agent cannot verify physical correctness. But it can surface every constraint for the user to scan.
For every constraint in the code:
- Extract the line number, the inequality direction (`<=` / `>=` / `==`), the left-hand side variable name, and the right-hand side expression.
- Format as a compact table in the review file:
| File:line | Direction | LHS | RHS | Expected physical meaning |
|---|---|---|---|---|
| `code/matlab/Q3/q3_main.m:42` | `<=` | `total_allocated(i)` | `capacity(i)` | allocated ≤ capacity (resource upper bound) |
| `code/matlab/Q3/q3_main.m:58` | `>=` | `allocated(i)` | `demand_min(i)` | allocated ≥ minimum demand (demand floor) |
- Do NOT change inequality direction. The reviewer MUST:
- Flag constraints whose direction looks counterintuitive.
- Ask the user to scan the "Expected physical meaning" column and confirm.
- Document this table in `code/matlab/Qx/reviews/qx_matlab_review.md` under a `## Constraint Direction Review` section.
7. Check randomness and reproducibility.
rng(seed) is set.Check MATLAB / 北太天元 compatibility.
Make minimal fixes if needed.
Produce a review report — MANDATORY substantive file on disk.
status: not_run. Do NOT pad with generic statements.Produce reviewed MATLAB code artifacts and a mandatory review file:
.m scripts under code/matlab/Qx/ (matching CLAUDE.md workspace convention).code/matlab/Qx/reviews/qx_matlab_review.md — REQUIRED. This is the artifact completeness-auditor will check for existence and pass-item count. Create the reviews/ directory if missing.(Legacy path workspace/code/code-review/matlab_review_summary.md is deprecated. New runs must write to code/matlab/Qx/reviews/qx_matlab_review.md.)
The mandatory code/matlab/Qx/reviews/qx_matlab_review.md file MUST follow this template:
# Qx MATLAB Code Review
> **Status**: passed / passed_with_warnings / failed
> **Reviewer**: matlab-code-reviewer
> **Date**: [timestamp]
> **Scripts reviewed**: [list of .m paths]
> **Compatibility target**: MATLAB / 北太天元
## Pass Items (≥ 5 REQUIRED — concrete, file:line cited)
1. ✅ `code/matlab/Q1/q1_main.m:8` reads cleaned data via `readtable(fullfile('workspace','data_clean','clean_data.csv'))`.
2. ✅ `code/matlab/Q1/q1_main.m:24` weight vector `w (1×6)` matches indicator count from data audit.
3. ✅ `code/matlab/Q1/q1_main.m:53` calls `writetable` to save ranking → output saved, not just displayed.
4. ✅ `rng(2026)` is set at line 6 → reproducibility ensured.
5. ✅ No App Designer / Live Script / Simulink dependencies → 北太天元 compatible.
6. ✅ ...
## Failed / Repaired Items
| # | File:line | Issue | Action taken | Status |
|---|-----------|-------|--------------|--------|
| 1 | code/matlab/Q1/q1_main.m:17 | absolute path | replaced with relative path | fixed |
| 2 | code/matlab/Q3/q3_main.m:42 | uses `fmincon` (Optimization Toolbox) | NOT fixed — requires method change | blocked → method-selector |
## Remaining Risks
- [risk 1 with file:line]
## Run Instructions
Run code/matlab/Q1/q1_baseline.m Run code/matlab/Q1/q1_main.m
## Expected Outputs
- `results/Q1/experiments/round1/tables/ranking.csv`
- `results/Q1/experiments/round1/figures/q1_ranking.png`
- `results/Q1/experiments/round1/run_summary.json`
## Recommended Next Skill
- `result-report-generator` or `robustness-checker`
JSON summary is acceptable for handoff but the markdown file at code/matlab/Qx/reviews/qx_matlab_review.md is still required.
Check at least the following.
.m filerun_all.m exists only if usefulreadtable, readmatrix, load, or equivalent input calls use expected pathsNaN or Infrng(seed) is used when randomness existsworkspace/results/workspace/figures/.mat files are saved when useful for later reviewrng(seed) when randomness exists and no seed is set.code/matlab/Qx/reviews/qx_matlab_review.md to disk with ≥ 5 explicit pass items. A verbal "passed" is not a review — completeness-auditor will flag it as MISSING.status: not_run.Before handing off, verify:
implementation.target = matlab..m files.results/Qx/experiments/roundN/ (per CLAUDE.md workspace convention).results/Qx/experiments/roundN/figures/.code/matlab/Qx/reviews/qx_matlab_review.md exists on disk with ≥ 5 explicit pass items (this is what completeness-auditor will check — verbal completion does not count).result-report-generator or robustness-checker if code is usable.Stop and report a blocker if:
.m script is available to review.implementation.target is not matlab.workspace/data/data_raw/.This skill must stop instead of guessing when:
When stopping, output:
If reviewed MATLAB code is usable, hand off to:
robustness-checker
The handoff should include:
.m script pathsIf blocked by missing or wrong generated scripts, hand back to:
matlab-model-code-generator
If blocked by method-plan issues, hand back to:
method-selector
If blocked by data issues, hand back to:
data-auditor-cleaner
If blocked by target or routing conflicts, hand back to:
code-reviewer
Input state:
implementation.target = matlabworkspace/code/matlab/Q1/q1_main.m uses an absolute local pathOutput:
{
"matlab_code_review_summary": {
"implementation_target": "matlab",
"status": "passed_with_warnings",
"reviewed_scripts": [
"workspace/code/matlab/Q1/q1_main.m"
],
"fixed_issues": [
{
"type": "path_error",
"change": "Replaced absolute local input path with a relative path under workspace/data/data_clean/."
},
{
"type": "missing_result_artifact",
"change": "Added writetable call to save ranking results under workspace/results/."
}
],
"remaining_risks": [
"北太天元 compatibility should be verified if writetable behavior differs in the contest environment."
],
"expected_outputs": [
"workspace/results/q1_main_results.csv"
],
"recommended_next_skill": "robustness-checker"
}
}
Input state:
implementation.target = pythonOutput:
{
"blocked_items": [
"matlab-code-reviewer was invoked, but implementation.target is python."
],
"recommended_next_skill": "code-reviewer",
"recommended_next_action": "Route the scripts through code-reviewer again and use the Python review branch."
}
Input state:
implementation.target = matlabbeita-tianyuan-compatibleOutput:
{
"blocked_items": [
"The script depends on a toolbox-specific solver that conflicts with the 北太天元 compatibility requirement."
],
"affected_script": "workspace/code/matlab/Q3/q3_main.m",
"recommended_next_skill": "method-selector",
"recommended_next_action": "Revise the method plan to use a basic MATLAB-compatible solver or explicitly approve the dependency."
}
Input state:
n x m1 x k, where k != mOutput:
{
"blocked_items": [
"Weight vector length does not match the number of indicators."
],
"affected_script": "workspace/code/matlab/Q1/q1_main.m",
"recommended_next_skill": "matlab-model-code-generator",
"recommended_next_action": "Regenerate or repair the script using the indicator count from the cleaned data and method plan."
}