一键导入
scientific-computing
审查科学计算代码的数值稳定性、物理单位一致性和数学正确性
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
审查科学计算代码的数值稳定性、物理单位一致性和数学正确性
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Guidelines and constraints for modifying the FastAPI api.py server, the BayesianOptimizer core logic, the physics-informed KnowledgeEngine prompting, or the VectorMemory embeddings/RAG layers. Use this skill whenever the user asks to modify python backend code under backend/optimization/ or backend/api.py.
Guidelines and constraints for modifying the React, Vite, Tailwind CSS 4.x, and Recharts frontend of BOagent. Use this skill whenever the user asks to modify App.tsx, BenchMode.tsx, OperationalMode.tsx, custom components in src/components/, or the styling theme in index.css.
Rules and protocols for running backend unit/integration tests (pytest) and frontend E2E tests (Playwright) in BOagent. Use this skill whenever the user asks to run test suites, check code coverage, add new test cases, mock API calls, or verify modifications to the codebase.
强制测试驱动开发循环 - 先写测试(RED)→ 实现功能(GREEN)→ 重构(REFACTOR)
Specialized expert for BOagent codebase. Analyzes Bayesian Optimization logic, materials science physical constraints (Band Alignment/Defects), and verifies PVK-LLM alignment. Use when auditing backend optimization logic, benchmark consistency, or frontend-backend API contracts.
Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.
| name | scientific-computing |
| description | 审查科学计算代码的数值稳定性、物理单位一致性和数学正确性 |
| user-invocable | false |
当修改 backend/optimization/ 或 backend/benchmark/ 中的代码时,自动应用此技能审查科学计算的正确性。
必查项:
1e-10)np.log1p(x) 而非 np.log(1 + x)scipy.special.logsumexp 处理 log-sum-expnp.isclose() 而非 ==示例问题:
# ❌ 危险:可能除零
variance = sigma ** 2
ucb = mean + kappa * variance
# ✅ 安全:添加 epsilon
variance = sigma ** 2 + 1e-10
ucb = mean + kappa * np.sqrt(variance)
钙钛矿能带对齐公式:
CBO = χ_PVK - χ_ETL (导带偏移)VBO = (χ_HTL + E_g_HTL) - χ_PVK (价带偏移)LUMO_barrier = LUMO_HTL - LUMO_PVK (电子阻挡)必查项:
高斯过程:
alpha 参数防止矩阵奇异采集函数:
mean + kappa * std,kappa 通常 ∈ [1, 3]示例审查:
# 检查 UCB 实现
def ucb(mean, std, kappa=2.0):
# ✅ 正确:std 已经是标准差
return mean + kappa * std
# ❌ 错误:重复开方
# return mean + kappa * np.sqrt(std)
输入验证:
np.isnan() 检测缺失值np.isinf() 检测无穷大示例:
def validate_data(X, y):
assert not np.any(np.isnan(X)), "输入包含 NaN"
assert not np.any(np.isinf(y)), "目标包含 Inf"
assert X.shape[0] == y.shape[0], "样本数不匹配"
assert np.all((X >= 0) & (X <= 1)), "特征未归一化"
向量化操作:
内存管理:
dtype=np.float32 节省内存对每个问题标注严重程度:
| 级别 | 含义 | 示例 |
|---|---|---|
| CRITICAL | 数学错误或数值不稳定,会导致错误结果 | 除零、矩阵奇异、公式错误 |
| HIGH | 物理不一致或严重性能问题 | 单位错误、参数越界、O(n³) 循环 |
| MEDIUM | 代码质量问题,可能影响可维护性 | 缺少验证、硬编码常数 |
| LOW | 风格建议 | 变量命名、注释完整性 |
当我修改 backend/optimization/optimizer.py 时,自动触发此技能:
# 修改前
def calculate_ucb(self, X):
mean, std = self.gp.predict(X, return_std=True)
return mean + self.kappa * std # ⚠️ 缺少数值稳定性检查
# 审查后建议
def calculate_ucb(self, X):
mean, std = self.gp.predict(X, return_std=True)
# ✅ 添加 epsilon 防止 std=0
std = np.maximum(std, 1e-10)
return mean + self.kappa * std
backend/optimization/optimizer.py - 贝叶斯优化核心backend/optimization/knowledge.py - 物理公式计算backend/benchmark/bo_step.py - 优化步进逻辑backend/benchmark/data_loader.py - 数据加载与验证