deterministic-calc-skill

# deterministic-calc Skill

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "deterministic-calc-skill" with this command: npx skills add hardtothinkausername/deterministic-calc-skill

deterministic-calc Skill

核心理念: 大模型擅长预测(猜),但不擅长确定性计算。本 Skill 将确定性计算固化为代码执行,避免模型"猜"结果。


🧠 问题背景

❌ 错误用法:让模型直接计算

用户:123456789 × 987654321 = ?
模型:(开始猜)大概是 121932631...(可能错)

✅ 正确用法:模型生成代码 → 执行 → 返回

用户:123456789 × 987654321 = ?
模型:(生成代码)print(123456789 * 987654321)
执行:121932631112635269
返回:正确答案

📦 安装

npx clawhub install deterministic-calc

🛠️ 可用函数

calculate(expression)

执行数学表达式计算。

参数:

  • expression (string): 数学表达式

返回:

{
  "success": true,
  "expression": "123456789 * 987654321",
  "result": 121932631112635269
}

run_python(code)

执行 Python 代码并返回结果。

参数:

  • code (string): Python 代码

返回:

{
  "success": true,
  "stdout": "121932631112635269\n",
  "stderr": "",
  "exit_code": 0
}

run_shell(command)

执行 Shell 命令并返回结果。

参数:

  • command (string): Shell 命令

返回:

{
  "success": true,
  "stdout": "...",
  "stderr": "",
  "exit_code": 0
}

safe_eval(expression)

安全执行数学表达式(无代码注入风险)。

参数:

  • expression (string): 数学表达式

返回:

{
  "success": true,
  "result": 42
}

📝 使用示例

数学计算

from deterministic_calc import calculate

result = calculate("123456789 * 987654321")
print(result["result"])  # 121932631112635269

复杂计算

from deterministic_calc import run_python

code = """
import math
result = sum(i**2 for i in range(1000))
print(result)
"""
result = run_python(code)
print(result["stdout"])  # 332833500

Shell 命令

from deterministic_calc import run_shell

result = run_shell("ls -la /tmp")
print(result["stdout"])

⚠️ 安全说明

  • calculate()safe_eval() 是沙箱安全的
  • run_python()run_shell() 可执行任意代码,需谨慎使用
  • 生产环境建议只暴露 calculate()safe_eval()

📄 License

MIT

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

Claude Chrome

Use Claude Code with Chrome browser extension for web browsing and automation tasks. Alternative to OpenClaw's built-in browser tools.

Registry SourceRecently Updated
Coding

App Builder

Build, edit, and deploy Instant-backed apps using npx instant-cli, create-instant-app (Next.js + Codex), GitHub (gh), and Vercel (vercel). Use when asked to create a new app, modify an existing app, fix bugs, add features, or deploy/update an app. Projects live under ~/apps; always work inside the relevant app folder.

Registry SourceRecently Updated
Coding

Opengraph Io

Extract web data, capture screenshots, scrape content, and generate AI images via OpenGraph.io. Use when working with URLs (unfurling, previews, metadata), capturing webpage screenshots, scraping HTML content, asking questions about webpages, or generating images (diagrams, icons, social cards, QR codes). Triggers: 'get the OG tags', 'screenshot this page', 'scrape this URL', 'generate a diagram', 'create a social card', 'what does this page say about'.

Registry SourceRecently Updated
Coding

Xlsx Pro

Compétence pour manipuler les fichiers Excel (.xlsx, .xlsm, .csv, .tsv). Utiliser quand l'utilisateur veut : ouvrir, lire, éditer ou créer un fichier tableur ; ajouter des colonnes, calculer des formules, formater, créer des graphiques, nettoyer des données ; convertir entre formats tabulaires. Le livrable doit être un fichier tableur. NE PAS utiliser si le livrable est un document Word, HTML, script Python standalone, ou intégration Google Sheets.

Registry SourceRecently Updated
2.1K0Profile unavailable