一键导入
python-code-reviewer
Review, debug, and verify Python modeling code against the validated method plan and expected artifacts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Review, debug, and verify Python 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 | python-code-reviewer |
| description | Review, debug, and verify Python modeling code against the validated method plan and expected artifacts. |
| license | MIT |
Review Python modeling code after scripts have been generated and routed by code-reviewer.
This skill checks whether .py scripts are runnable, consistent with the validated method plan, 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 Python scripts to python-code-reviewer.implementation.target = python..py files.The following should already exist or be provided:
implementation.target = python.workspace/code/python/.workspace/data/data_clean/, if data is required.workspace/results/.workspace/figures/.If generated scripts are missing, hand back to python-model-code-generator.
If cleaned data is missing, hand back to data-auditor-cleaner.
If implementation.target is not python, hand back to code-reviewer.
Use or request:
workspace/problem/method-selector/method_plan.jsonworkspace/code/python/workspace/data/data_clean/workspace/data/data_report.md, if availabledata-auditor-cleanerminimal-dependenciesportable-artifactsavoid-notebook-only-codesave-csv-json-pngfixed-random-seedConfirm Python review target.
implementation.target = python..py files.workspace/code/python/ or clearly documented otherwise.Map scripts to the method plan.
Check Python script structure.
.py scripts.run_all.py exists only if useful.Check paths and artifacts.
workspace/data/data_clean/.workspace/data/data_raw/ is not modified.workspace/results/.workspace/figures/..csv, .json, and .png.Check data-field consistency.
pandas.read_csv, read_excel, numpy.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/Q3/q3_main.py:42` | `≤` | `total_allocated[i]` | `capacity[i]` | allocated ≤ capacity (resource upper bound) |
| `code/Q3/q3_main.py:58` | `≥` | `allocated[i]` | `demand_min[i]` | allocated ≥ minimum demand (demand floor) |
| `code/Q3/q3_main.py:72` | `==` | `sum(allocated)` | `available` | total consumed = total available (conservation) |
- Do NOT change inequality direction — the reviewer cannot know the modeler's intent. But the reviewer MUST:
- Flag constraints whose direction looks counterintuitive (e.g., `allocated ≤ demand_min` is surprising — should it be `≥`?).
- Ask the user to scan the "Expected physical meaning" column and confirm.
- This is a **safety net for the user**, not a correctness guarantee. Document this table in `code/Qx/reviews/qx_python_review.md` under a `## Constraint Direction Review` section.
7. Check prediction and machine learning risks when applicable.
Check randomness and reproducibility.
Check dependency and portability risks.
Make minimal fixes if needed.
Produce a review report — MANDATORY substantive file on disk.
status: not_run and report which checks could not be performed (missing data, missing method plan, etc.). Do NOT pad the list with generic statements.Produce reviewed Python code artifacts and a mandatory review file:
.py scripts under code/Qx/ (matching CLAUDE.md workspace convention).code/Qx/reviews/qx_python_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/python_review_summary.md is deprecated. New runs must write to code/Qx/reviews/qx_python_review.md.)
The mandatory code/Qx/reviews/qx_python_review.md file MUST follow this template:
# Qx Python Code Review
> **Status**: passed / passed_with_warnings / failed
> **Reviewer**: python-code-reviewer
> **Date**: [timestamp]
> **Scripts reviewed**: [list of .py paths]
## Pass Items (≥ 5 REQUIRED — concrete, file:line cited)
1. ✅ `code/Q1/q1_main.py:14` reads cleaned data from `workspace/data_clean/clean_data.csv` (matches data audit field mapping).
2. ✅ `code/Q1/q1_main.py:42` uses `K=30` matching `methods/Q1/q1_final_method_explanation.md`.
3. ✅ `code/Q1/q1_main.py:67` writes ranking to `results/Q1/experiments/round1/tables/ranking.csv` — output saved, not printed.
4. ✅ `code/Q1/q1_baseline.py` implements the designated baseline (equal-weight scoring) per method plan.
5. ✅ All scripts set `SEED = 2026` for reproducibility (`q1_main.py:8`, `q1_baseline.py:6`).
6. ✅ No raw data file under `workspace/data_raw/` is opened in write mode.
7. ✅ ...
## Failed / Repaired Items
| # | File:line | Issue | Action taken | Status |
|---|-----------|-------|--------------|--------|
| 1 | code/Q1/q1_main.py:23 | absolute path `/Users/zhnnky/...` | replaced with `DATA_DIR / 'clean_data.csv'` | fixed |
| 2 | code/Q2/q2_main.py:88 | scaler fit on full dataset before train-test split (leakage) | NOT fixed — requires method change | blocked → method-selector |
## Remaining Risks
- [risk 1 with file:line and mitigation suggestion]
## Run Instructions
python code/Q1/q1_baseline.py python code/Q1/q1_main.py
## 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` (if scripts ran and produced outputs)
- OR `robustness-checker` (if results already reported)
JSON summary is acceptable for handoff but the markdown file at code/Qx/reviews/qx_python_review.md is still required.
Check at least the following.
.py filerun_all.py exists only if usefulNaN or infrandom_state is set where supportedworkspace/results/workspace/figures/.json summaries are saved when usefulcode/Qx/reviews/qx_python_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 instead of faking the list.Before handing off, verify:
implementation.target = python..py files.results/Qx/experiments/roundN/ (per CLAUDE.md workspace convention).results/Qx/experiments/roundN/figures/.code/Qx/reviews/qx_python_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:
.py script is available to review.implementation.target is not python.workspace/data/data_raw/.This skill must stop instead of guessing when:
When stopping, output:
If reviewed Python code is usable, hand off to:
robustness-checker
The handoff should include:
.py script pathsIf blocked by missing or wrong generated scripts, hand back to:
python-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 = pythonworkspace/code/python/Q1/q1_main.py uses an absolute local pathOutput:
{
"python_code_review_summary": {
"implementation_target": "python",
"status": "passed_with_warnings",
"reviewed_scripts": [
"workspace/code/python/Q1/q1_main.py"
],
"fixed_issues": [
{
"type": "path_error",
"change": "Replaced absolute local input path with DATA_DIR / 'clean_data.csv'."
},
{
"type": "missing_result_artifact",
"change": "Added DataFrame.to_csv call to save ranking results under workspace/results/."
}
],
"remaining_risks": [
"Column names should be rechecked if the data audit report changes."
],
"expected_outputs": [
"workspace/results/q1_main_results.csv"
],
"recommended_next_skill": "robustness-checker"
}
}
Input state:
implementation.target = matlabOutput:
{
"blocked_items": [
"python-code-reviewer was invoked, but implementation.target is matlab."
],
"recommended_next_skill": "code-reviewer",
"recommended_next_action": "Route the scripts through code-reviewer again and use the MATLAB review branch."
}
Input state:
implementation.target = pythonOutput:
{
"blocked_items": [
"Feature scaling is fitted on the full dataset before train-test split, causing leakage."
],
"affected_script": "workspace/code/python/Q2/q2_main.py",
"recommended_next_skill": "python-code-reviewer",
"recommended_next_action": "Move scaler fitting after the train-test split and fit only on the training set."
}
Input state:
implementation.target = pythonOutput:
{
"blocked_items": [
"The script depends on an unjustified heavy package that is not required by the approved method plan."
],
"affected_script": "workspace/code/python/Q3/q3_main.py",
"recommended_next_skill": "python-code-reviewer",
"recommended_next_action": "Replace the dependency with a simpler numpy / scipy / scikit-learn implementation or update the method plan with a justification."
}