Run code snippets in 30+ programming languages including JavaScript, Python, TypeScript, Java, C, C++, Go, Rust, Ruby, PHP, and more. Use when the user wants...
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install code-runner或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install code-runner⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/code-runner/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: code-runner description: Run code snippets in 30+ programming languages including JavaScript, Python, TypeScript, Java, C, C++, Go, Rust, Ruby, PHP, and more. Use when the user wants to execute code, test algorithms, verify output, run scripts, or check code behavior. Supports both interpreted and compiled languages. ---
This skill enables you to run code snippets in multiple programming languages directly from the command line.
Use this skill when:
The following languages are supported (requires the interpreter/compiler to be installed):
| Language | Command | File Extension |
|----------|---------|----------------|
| JavaScript | node | .js |
| TypeScript | ts-node | .ts |
| Python | python | .py |
| Java | java (compile & run) | .java |
| C | gcc (compile & run) | .c |
| C++ | g++ (compile & run) | .cpp |
| Go | go run | .go |
| Rust | rustc (compile & run) | .rs |
| Ruby | ruby | .rb |
| PHP | php | .php |
| Perl | perl | .pl |
| Lua | lua | .lua |
| R | Rscript | .r |
| Swift | swift | .swift |
| Kotlin | kotlin | .kts |
| Scala | scala | .scala |
| Groovy | groovy | .groovy |
| Dart | dart | .dart |
| Julia | julia | .jl |
| Haskell | runhaskell | .hs |
| Clojure | clojure | .clj |
| F# | dotnet fsi | .fsx |
| C# | dotnet script | .csx |
| PowerShell | pwsh | .ps1 |
| Bash | bash | .sh |
| Batch | cmd /c | .bat |
| CoffeeScript | coffee | .coffee |
| Crystal | crystal | .cr |
| Elixir | elixir | .exs |
| Nim | nim compile --run | .nim |
| OCaml | ocaml | .ml |
| Racket | racket | .rkt |
| Scheme | scheme | .scm |
| Lisp | sbcl --script | .lisp |
See references/LANGUAGES.md for detailed language configuration.
Determine the programming language from:
⚠️ Important for AI Agents: Use stdin to avoid escaping issues with quotes, backslashes, and special characters.
Recommended Method (stdin):
echo "<code>" | node scripts/run-code.cjs <languageId>
Alternative Method (CLI argument - for simple code only):
node scripts/run-code.cjs <languageId> "<code>"
Example - JavaScript:
echo "console.log('Hello, World!')" | node scripts/run-code.cjs javascript
Example - Python:
echo "print('Hello, World!')" | node scripts/run-code.cjs python
Example - Java (multi-line):
echo "public class Test {
public static void main(String[] args) {
System.out.println(\"Hello from Java!\");
}
}" | node scripts/run-code.cjs java
Example - Multi-line code from variable:
# In bash
CODE='import math
print("Pi:", math.pi)
print("Result:", math.factorial(5))'
echo "$CODE" | node scripts/run-code.cjs python
# In PowerShell (inline here-string)
@"
import math
print("Pi:", math.pi)
print("Result:", math.factorial(5))
"@ | node scripts/run-code.cjs python
cmd /c for batch scripts
pwsh or powershell
\
#!/usr/bin/env shebang for portable scripts
Common issues and solutions:
- Suggest installing the required runtime - Provide installation instructions
- Show the error message - Point to the line number if available
- Display the stack trace - Explain the error type
- Warn about infinite loops - Suggest optimizations
⚠️ Important: Running arbitrary code can be dangerous. Always:
- Accesses the file system - Makes network requests - Executes system commands - Modifies environment variables
echo "console.log(Array.from({length: 10}, (_, i) => i * i))" | node scripts/run-code.cjs javascript
Output: [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
echo "import math; print(math.factorial(10))" | node scripts/run-code.cjs python
Output: 3628800
echo 'package main; import "fmt"; func main() { fmt.Println("Hello from Go!") }' | node scripts/run-code.cjs go
Output: Hello from Go!
安装 Code Runner 后,可以对 AI 说这些话来触发它
Help me get started with Code Runner
Explains what Code Runner does, walks through the setup, and runs a quick demo based on your current project
Use Code Runner to run code snippets in 30+ programming languages including JavaScript...
Invokes Code Runner with the right parameters and returns the result directly in the conversation
What can I do with Code Runner in my developer & devops workflow?
Lists the top use cases for Code Runner, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/code-runner/ 目录(个人级,所有项目可用),或 .claude/skills/code-runner/(项目级)。重启 AI 客户端后,用 /code-runner 主动调用,或让 AI 根据上下文自动发现并使用。
Code Runner 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Code Runner 可免费安装使用。请查阅仓库了解许可证信息。
Run code snippets in 30+ programming languages including JavaScript, Python, TypeScript, Java, C, C++, Go, Rust, Ruby, PHP, and more. Use when the user wants...
Code Runner 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using Code Runner
Identifies repetitive steps in your workflow and sets up Code Runner to handle them automatically