360 Secure SkillHub
360 安全技能中心

Bc Calc

该 Skill 把用户给出的算术表达式(支持加减乘除、取模、scale、sqrt、pi 以及默认启用的数学库函数)通过命令行参数或标准输入传给 Unix bc 计算器求值,返回计算结果,表达式非法时返回 bc 的错误信息。依赖 Node(>=12)与 bc 命令行工具。

danstaal
danstaal
热度 35.19
最近更新 2026-05-11 17:41:04
分类:效率依赖:代码执行应用场景:数据处理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add bc-calc
Metadata
name
bc-calc
description
This skill evaluates arithmetic expressions using the Unix `bc` calculator. It accepts full `bc` syntax (addition, subtraction, multiplication, division, modulus, scale, sqrt, and constants like `pi`). Use it when the user asks to "calculate", "compute", "do math", or simply poses a question such as "what is 1+1". The skill provides precise, arbitrary‑precision calculation.
version
1.0.0

bc-calc

Use the Unix bc calculator to evaluate arbitrary arithmetic expressions. The skill accepts the expression as a command‑line argument or via standard input.

When This Skill Applies

This skill activates when the user's request involves:

  • Basic or advanced arithmetic calculations (addition, subtraction, multiplication, division, modulus)
  • Full bc expressions (including scale, sqrt, pi, etc.)
  • Any math expression evaluation request

How It Works

  1. Parse the mathematical expression from the request or stdin.
  2. Pass the expression to bc and capture the output.
  3. Return the result, or the bc error message if the expression is invalid.

Usage Examples

# As a CLI command with a single expression
bc-calc "12+34*5"

# With piped input and scale
printf "scale=2; 1/3" | bc-calc

Installation

The skill can be installed with the ClawHub CLI:

openclaw install bc-calc

Or simply place the bc-calc directory under ~/.openclaw/workspace/skills.

Dependencies

  • node (>=12)
  • bc command‑line tool (usually pre‑installed on Linux/macOS)

Optional Flags

# Show help
bc-calc --help

The help flag displays usage instructions.

NOTE: The math‑library flag -l is now enabled by default, giving access to trigonometric and other advanced functions.

Available functions:

  • s(x) : sine, in radians.
  • c(x) : cosine, in radians.
  • a(x) : arctangent, in radians.
  • l(x) : natural logarithm.
  • e(x) : e^x.
  • j(n,x) : Bessel function of integer order n for x.