Agent skill

Modeling Code and Result Contracts

by yushui2022 in yushui2022/MathModel-Skill

Generates result-evidence contracts, tables and runnable q1 to q3 modeling code scaffolds for a math modeling paper from a model route, a data plan and cleaned data.

MITAuto-check passedResearch & Science

SKILL.md written in Chinese; this summary is our English description.

Install Modeling Code and Result Contracts

skills CLI
$ npx skills add yushui2022/MathModel-Skill --skill model-code-and-result-generator -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install yushui2022/MathModel-Skill model-code-and-result-generator --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/yushui2022/MathModel-Skill.git skills-src && mkdir -p .claude/skills && cp -r skills-src/packages/trae/.trae/skills/model-code-and-result-generator .claude/skills/model-code-and-result-generator && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
model-code-and-result-generator
GitHub stars
452
Token cost
~1.4k tokens
SKILL.md length
233 words
Files
4 (incl. scripts, references)
Skills in repo
10
Repo updated
First seen
Licence
MIT

At a glance

Generates result-evidence contracts, tables and runnable q1 to q3 modeling code scaffolds for a math modeling paper from a model route, a data plan and cleaned data.

  • Generating modeling code scaffolds for each question of a math modeling contest
  • SKILL.md covers 全局流程协作约束(长对话防漂移), 目标, 执行契约 and 脚本, plus 4 more sections
  • Runs Python scripts from its folder; calls python
  • Recording model outputs, metrics and conclusions as structured evidence for the paper

What it does

Written in Chinese, this skill is one stage of a mathematical modeling paper workflow. From model_route.json, the data and visualization plans and the files in paper_output/data_cleaned, scripts/build_result_contracts.py builds a result-evidence layer: model_results.json, metrics.json, conclusions.json, run_manifest.json, a table index with CSV tables, and a README plus run_modeling.py and q1, q2 and q3 model scripts under paper_output/code/modeling.

It is not an automatic modeling system. The generated q*_model.py files are a starting point that the agent must revise against the route, the data fields, the problem constraints and the scoring rules. Before starting, it must run workflow_guard.py and stop on a failure, and it hands off to the paper-workflow-orchestrator, quality-assurance-auditor and paper-formal-writer skills. If cleaned data or real modeling code is missing, it still writes the contract skeleton and marks it needs_real_modeling instead of passing it off as final results.

When your agent uses it

  • Generating modeling code scaffolds for each question of a math modeling contest
  • Recording model outputs, metrics and conclusions as structured evidence for the paper
  • Building paper tables from model results

Example prompts

  • “Generate the result contracts and the q1 to q3 model scripts from model_route.json.”
  • “Build the table index and metrics files for the paper from the cleaned data.”
  • “Update the modeling code after I changed the route for question 2.”

Requirements

  • Python 3
  • A model_route.json and data plan from the earlier workflow stages
  • Cleaned data in paper_output/data_cleaned

What it can do on your machine

Read from SKILL.md and the folder at commit 7712876. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Modeling Code and Result Contracts loads about 1.4k tokens when it runs, and up to ~1.7k if it reads all its reference files. Until then it costs about 58 tokens; SKILL.md has 233 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~58
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from yushui2022/MathModel-Skill at commit 7712876, republished under its MIT licence (© yushui2022). 233 words, ~1,357 tokens.

Download SKILL.mdSave it as .claude/skills/model-code-and-result-generator/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
model-code-and-result-generator
description
根据 model_route.json、数据计划和清洗数据,为数学建模论文生成结果证据契约和 q1/q2/q3 建模代码脚手架。Invoke when 需要把模型输出、评价指标、结构化结论、论文表格和当前赛题专用建模代码沉淀到 paper_output/results/、paper_output/tables/ 和 paper_output/code/modeling/,供 QA 与正文生成读取。

建模代码与结果证据生成器

全局流程协作约束(长对话防漂移)

  • 本 skill 不得作为孤立入口。用户要求完整论文、生成 Word、继续流程或不确定阶段时,先回到 paper-workflow-orchestrator 判断当前 S0-S8 阶段。
  • 启动或继续本 skill 的正式任务前,必须运行:
    bash
    python .trae/skills/paper-workflow-orchestrator/scripts/workflow_guard.py --skill model-code-and-result-generator
  • 如果输出 [WORKFLOW FAIL] 或报告 status != "PASS",停止本 skill,按 paper_output/qa/workflow_guard_report.json 的失败项回补前置阶段,不得凭记忆继续。
  • 本 skill 只写入自己契约范围内的 paper_output/ 产物;完成后必须回到 paper-workflow-orchestrator 判断下一步,并用 context-memory-keeper 记录已完成产物、阻塞项和下一步。
  • 长对话中如果上下文变长、阶段不确定或用户分开调用 skill,先运行:
    bash
    python .trae/skills/paper-workflow-orchestrator/scripts/workflow_guard.py --status
    再读取 paper_output/qa/workflow_guard_report.json、paper_output/preflight_report.json、paper_output/input_manifest.json、paper_output/results/run_manifest.json 和本 skill 的上游 JSON 契约,按报告里的 recommended_skill 与 next_action 继续。
  • 继续流程前,必须把 paper_output/context/workflow_memory.json 视为长期断点记录;若其中的 current_step、next_step、recommended_skill 与 workflow_guard.py --status 不一致,以 guard 报告为准。
  • 每次完成本 skill 的产物后,先回到 paper-workflow-orchestrator 或运行 workflow_guard.py --status,再更新 workflow memory:
    bash
    python .trae/skills/context-memory-keeper/scripts/update_workflow_memory.py
    更新后读取 paper_output/context/workflow_memory.json / .md,确认下一步和推荐 skill 已记录。

目标

本 skill 不是万能自动建模系统。它的作用是给 Agent 一个稳定的“结果证据层”和可运行的赛题专用建模代码起点,避免正文只根据模型路线空写,也避免 Agent 面对数据时无头乱转。

真实赛题中,Agent 必须根据 model_route.json、数据字段、题目约束和评分要求二次修改生成的 q*_model.py。生成代码固定放在 paper_output/code/modeling/,不要写回 skill 包的 scripts/。

执行契约

  • 上游输入:优先读取 paper_output/plan/model_route.json、data_plan.json、visualization_plan.json,并扫描 paper_output/data_cleaned/。
  • 必须输出:paper_output/results/model_results.json、metrics.json、conclusions.json、run_manifest.json、paper_output/tables/table_index.json、paper_output/tables/*.csv。
  • 建模代码输出:paper_output/code/modeling/result_contract_io.py、run_modeling.py、q1_model.py、q2_model.py、q3_model.py 或与 question_id 对应的 q*_model.py。
  • 下游交接:quality-assurance-auditor 直接审计结果、指标、表格、图表和结论;证据门禁 PASS 后由 paper-formal-writer 构建正式写作计划。
  • 失败回退:如果没有清洗数据或真实建模代码,仍生成契约骨架,并用 needs_real_modeling 标记,不伪装成最终比赛结果。

脚本

  • scripts/build_result_contracts.py
    • 何时用:已有模型路线,需要生成结果契约、表格索引和当前赛题的 q1/q2/q3 建模代码脚手架。
    • 做什么:扫描 model_route.json 的每个 question_id,生成结果契约骨架、基础字段画像表、paper_output/code/modeling/README.md,并生成可运行的 q*_model.py。
    • 覆盖规则:生成文件带有 managed marker;如果 Agent 已经手工改写并去掉 marker,本脚本会保留用户文件,不覆盖。
  • scripts/result_contract_templates.py
    • 何时用:需要了解不同任务类型应沉淀哪些指标、表格和结论字段。
    • 做什么:提供预测、优化、评价、分类、聚类、仿真、通用建模的契约模板。

任务类型分发

  • 预测/回归/时间序列 -> forecasting scaffold:生成目标列、特征列、预测值、残差、RMSE、MAE、MAPE。
  • 优化/规划/调度/选址/路径 -> optimization scaffold:生成代理目标函数、方案排序、约束满足率待补项。
  • 评价/排序/权重/TOPSIS/AHP/熵权 -> evaluation scaffold:生成指标归一化、综合得分、排序和权重敏感性待补项。
  • 分类/识别/判别 -> classification scaffold:生成代理分类标签、准确率/F1 待补项。
  • 聚类/分群 -> clustering scaffold:生成代理聚类标签、聚类数、簇内紧凑度。
  • 仿真/机理/动力学/微分 -> simulation scaffold:生成趋势代理、情景结果、拟合误差和敏感性参数。
  • 其他 -> general scaffold:生成数值字段统计摘要和通用结果表。

输出位置

text
paper_output/
|-- code/
|   `-- modeling/
|       |-- run_modeling.py
|       |-- result_contract_io.py
|       |-- q1_model.py
|       |-- q2_model.py
|       |-- q3_model.py
|       `-- README.md
|-- results/
|   |-- model_results.json
|   |-- metrics.json
|   `-- conclusions.json
`-- tables/
    |-- table_index.json
    |-- table_q1_result_skeleton.csv
    |-- table_q1_forecasting_scaffold.csv
    `-- ...

统一规则:

  • 所有路径使用相对路径。
  • 所有 JSON 包含 schema_version、generated_by、generated_at。
  • 每条结果、指标、结论和表格都应带 question_id。
  • 草稿或脚手架结果必须使用 status 或 evidence_status 标记。
  • 正式结果必须带 execution_provenance,至少包含 source_code_path、source_code_sha256、run_command、run_exit_code 和 output_artifacts。
  • 统一入口 run_modeling.py 必须在实际执行后写入 paper_output/results/run_manifest.json,记录总体 status、脚本 hash、question_ids、退出码、工作目录、Python 实现/版本/平台,以及每个输入和输出文件的 path、bytes、sha256、exists。
  • run_manifest.json 不是日志占位符。建模脚本、输入文件或输出产物在运行后发生变化时,必须重新运行模型,不能手改 manifest 或结果 JSON 续签旧证据。
  • model_results.json 中正式条目必须有非空 result_summary;metrics.json 中 status=computed 的指标必须有非空、有限的 value,不得使用 null、NaN 或无穷值。
  • table_index.json 中正式表格必须指向真实存在且非空的文件;只有索引条目、没有 CSV/XLSX 产物不能作为证据。
  • official evidence gate 会重新计算脚本、输入和输出哈希,并拒绝没有真实代码运行来源、运行账本状态失败、文件被修改或运行记录无法关联 question_id 的结果。
  • 正文中引用的表格必须能在 paper_output/tables/table_index.json 找到。

使用方式

推荐由 paper-workflow-orchestrator 在数据清洗与可视化之后调用。也可以手动运行:

bash
python .trae/skills/model-code-and-result-generator/scripts/build_result_contracts.py

生成脚手架后,Agent 应按真实赛题执行:

bash
python paper_output/code/modeling/run_modeling.py

该入口会写入 paper_output/results/run_manifest.json。运行后不要再编辑建模脚本或产物;如需修正,修改后重新运行入口,再重新运行 evidence gate 和 S7 写作准备,使结果与写作契约同步失效并重建。

真实赛题使用原则

  • 不要把占位式指标或代理结果直接当成最终比赛结果。
  • 优先修改 paper_output/code/modeling/q*_model.py,不要修改 skill 包内的 scripts/。
  • 正式建模完成后,必须由建模代码实际运行并把真实输出写回 paper_output/results/ 与 paper_output/tables/;不要手写 model_results.json 冒充运行结果。没有 run_manifest.json 对应运行记录时,不能进入正式 evidence gate。
  • 如果某一问没有真实结果,QA 应保留 warning,正文不得把该问写成已经完成精确计算。

© yushui2022, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (scripts, references) in packages/trae/.trae/skills/model-code-and-result-generator of yushui2022/MathModel-Skill.

  • SKILL.md
  • references/modeling_result_guidelines.md
  • scripts/build_result_contracts.py
  • scripts/result_contract_templates.py

Open the folder on GitHubat commit 7712876

Compare with similar skills

Modeling Code and Result Contracts next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Modeling Code and Result Contracts compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Modeling Code and Result Contracts this skillyushui2022/MathModel-Skill452—~1.4kAutomated safety check: PassMIT
Backward Traceabilitylingzhi227/agent-research-skills384—~802Automated safety check: PassNone
Paper Pipeline Assemblylingzhi227/agent-research-skills384—~971Automated safety check: PassNone
Nature-Style Scientific FiguresYuan1z0825/nature-skills46k—~2.9kAutomated safety check: PassApache-2.0
Meta-model-agent Math Modeling PipelineWuXinbo-bo/Math-model-skills111—~2.3kAutomated safety check: PassMIT
LaminDB Biological Data Managementdavila7/claude-code-templates32k12 repos~3.6kAutomated safety check: PassMIT

Similar skills

  • Backward Traceability

    lingzhi227/agent-research-skills

    Makes each number in a LaTeX paper link back to the code line that produced it, using hypertarget and hyperlink tags and compile-time `\num` formulas.

    384 GitHub stars~802 tokensUpdated 7 mo ago
    Research & ScienceAuto-check passed
  • Paper Pipeline Assembly

    lingzhi227/agent-research-skills

    Orchestrates a research paper from literature review through code, experiments, figures, tables, writing and review, with state passed between phases and checkpoints to resume.

    384 GitHub stars~971 tokensUpdated 7 mo ago
    Research & ScienceAuto-check passed
  • Nature-Style Scientific Figures

    Yuan1z0825/nature-skills

    Creates, revises, audits and exports manuscript-ready scientific figures in Python or R, and routes AI-generated graphical abstracts to a separate workflow.

    46k GitHub stars~2.9k tokensUpdated yesterday
    Research & ScienceAuto-check passed
  • Meta-model-agent Math Modeling Pipeline

    WuXinbo-bo/Math-model-skills

    Runs a staged pipeline for mathematical modeling research and contest papers, from problem analysis and computation to paper writing, review rounds and submission checks.

    111 GitHub stars~2.3k tokensUpdated 18 days ago
    Research & ScienceAuto-check passed
  • LaminDB Biological Data Management

    davila7/claude-code-templates

    Manages biological datasets with LaminDB: versioned artifacts, run lineage, ontology-based annotation, schema validation and links to workflow managers and ML tools.

    32k GitHub starsUsed in 12 repos~3.6k tokens
    Research & ScienceAuto-check passed
  • Mathmodel Skill

    handsomeZR-netizen/mathmodel-skill

    Plugin shim for the mathmodel-skill competition workflow. An agent skill from handsomeZR-netizen/mathmodel-skill.

    292 GitHub stars~197 tokensUpdated 13 days ago
    Research & ScienceAuto-check passed

More from yushui2022/MathModel-Skill

All 10 skills in this repo
  • Builds a scoring-aligned outline for a mathematical modeling paper and a model selection plan with baseline, improvement and validation experiments.

    452 GitHub starsUsed in 1 repo~1.8k tokens
    Auto-check passed
  • Formal Modeling Paper Writer

    yushui2022/MathModel-Skill

    Plans, drafts, audits, formats and verifies a formal mathematical-modeling paper from an evidence chain, delivering audited Markdown and a Word file with native equations.

    452 GitHub stars~1.6k tokensUpdated yesterday
    Auto-check passed
  • Paper Micro-Unit Generator

    yushui2022/MathModel-Skill

    Repairs one failing section of a mathematical modeling paper from the repair queue, or builds a legacy or quickstart scaffold when you ask for one by name.

    452 GitHub stars~1.1k tokensUpdated yesterday
    Auto-check passed
  • Authoritative Data Harvester

    yushui2022/MathModel-Skill

    Finds authoritative public data sources for modeling tasks, prefers official APIs and bulk downloads, and outputs a reproducible fetch and cleaning plan with citations.

    452 GitHub starsUsed in 1 repo~1.1k tokens
    Auto-check passed
  • Context Memory Keeper

    yushui2022/MathModel-Skill

    Maintains a two-layer persistent memory for a math-modeling paper workflow: long-term rules plus a short-term workbench, with finished tasks archived.

    452 GitHub starsUsed in 1 repo~893 tokens
    Auto-check passed
  • Math Modeling Data Cleaning and Charts

    yushui2022/MathModel-Skill

    Cleans raw or scraped competition data and produces exploratory charts and a figure plan as one stage of a mathematical modeling paper workflow.

    452 GitHub starsUsed in 1 repo~1.7k tokens
    Auto-check passed

Works with

Questions about Modeling Code and Result Contracts

What does Modeling Code and Result Contracts do?

Generates result-evidence contracts, tables and runnable q1 to q3 modeling code scaffolds for a math modeling paper from a model route, a data plan and cleaned data. Written in Chinese, this skill is one stage of a mathematical modeling paper workflow.py and q1, q2 and q3 model scripts under paper_output/code/modeling.

When should I use Modeling Code and Result Contracts?

Modeling Code and Result Contracts fits situations like: generating modeling code scaffolds for each question of a math modeling contest; recording model outputs, metrics and conclusions as structured evidence for the paper; building paper tables from model results.

How do I install Modeling Code and Result Contracts in Claude Code?

Run `npx skills add yushui2022/MathModel-Skill --skill model-code-and-result-generator -a claude-code`. Or copy the skill folder (packages/trae/.trae/skills/model-code-and-result-generator in yushui2022/MathModel-Skill) into .claude/skills/model-code-and-result-generator in your project. Claude Code loads it when a task matches its description.

How do I install Modeling Code and Result Contracts in Codex?

Run `npx skills add yushui2022/MathModel-Skill --skill model-code-and-result-generator -a codex`. Or copy the skill folder (packages/trae/.trae/skills/model-code-and-result-generator in yushui2022/MathModel-Skill) into .agents/skills/model-code-and-result-generator in your project. Codex loads it when a task matches its description.

Can I use Modeling Code and Result Contracts in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add yushui2022/MathModel-Skill --skill model-code-and-result-generator -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/model-code-and-result-generator, .gemini/skills/model-code-and-result-generator, .github/skills/model-code-and-result-generator and .opencode/skills/model-code-and-result-generator in your project.

What does Modeling Code and Result Contracts need to run?

Going by SKILL.md and its folder, Modeling Code and Result Contracts needs Python for the scripts in its folder and the command-line tools its instructions call (python). Our summary lists: Python 3; A model_route.json and data plan from the earlier workflow stages; Cleaned data in paper_output/data_cleaned.

Does Modeling Code and Result Contracts access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Modeling Code and Result Contracts safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Modeling Code and Result Contracts use?

Modeling Code and Result Contracts is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Modeling Code and Result Contracts use?

About 1.4k tokens (SKILL.md is roughly 5.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 313 tokens, read only when the agent opens those files.

What are the alternatives to Modeling Code and Result Contracts?

Skills that share tags, products or a category with Modeling Code and Result Contracts: Backward Traceability (lingzhi227/agent-research-skills, 384 stars), Paper Pipeline Assembly (lingzhi227/agent-research-skills, 384 stars), Nature-Style Scientific Figures (Yuan1z0825/nature-skills, 46k stars) and Meta-model-agent Math Modeling Pipeline (WuXinbo-bo/Math-model-skills, 111 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Modeling Code and Result Contracts?

yushui2022 (a GitHub user) maintains it in yushui2022/MathModel-Skill, which has 452 GitHub stars. The repository holds 10 skills in this directory. The repository was last updated on October 7, 2026.

Source: yushui2022/MathModel-Skill on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.