返回顶部
c

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 to execute code, test algorithms, verify output, run scripts, or check code behavior. Supports both interpreted and compiled languages.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
157
下载量
0
收藏
概述
安装方式
版本历史

code-runner

# Code Runner Skill This skill enables you to run code snippets in multiple programming languages directly from the command line. ## When to Use This Skill Use this skill when: - The user wants to run or execute a code snippet - Testing algorithm implementations or logic - Verifying expected output of code - Running quick scripts or one-liners - Checking syntax or runtime behavior - Demonstrating code functionality ## Supported Languages 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](references/LANGUAGES.md) for detailed language configuration. ## How to Run Code ### Step 1: Identify the Language Determine the programming language from: - User's explicit request (e.g., "run this Python code") - File extension if provided - Code syntax patterns ### Step 2: Execute Using the Runner Script **⚠️ Important for AI Agents**: Use stdin to avoid escaping issues with quotes, backslashes, and special characters. **Recommended Method (stdin):** ```bash echo "<code>" | node scripts/run-code.cjs <languageId> ``` **Alternative Method (CLI argument - for simple code only):** ```bash node scripts/run-code.cjs <languageId> "<code>" ``` **Example - JavaScript:** ```bash echo "console.log('Hello, World!')" | node scripts/run-code.cjs javascript ``` **Example - Python:** ```bash echo "print('Hello, World!')" | node scripts/run-code.cjs python ``` **Example - Java (multi-line):** ```bash 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:** ```bash # 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 ``` ### Step 3: Return Results - Show the output (stdout) to the user - If there are errors (stderr), explain what went wrong - Suggest fixes for common errors ## Platform Notes ### Windows - Use `cmd /c` for batch scripts - PowerShell scripts require `pwsh` or `powershell` - Path separators use backslash `\` ### macOS / Linux - Bash scripts work natively - Swift available on macOS - Use `#!/usr/bin/env` shebang for portable scripts ## Error Handling Common issues and solutions: 1. **Command not found**: The language interpreter is not installed or not in PATH - Suggest installing the required runtime - Provide installation instructions 2. **Syntax errors**: Code has syntax issues - Show the error message - Point to the line number if available 3. **Runtime errors**: Code runs but fails during execution - Display the stack trace - Explain the error type 4. **Timeout**: Code takes too long (default: 30 seconds) - Warn about infinite loops - Suggest optimizations ## Security Considerations ⚠️ **Important**: Running arbitrary code can be dangerous. Always: 1. Review the code before execution 2. Be cautious with code that: - Accesses the file system - Makes network requests - Executes system commands - Modifies environment variables 3. Consider running in a sandboxed environment for untrusted code ## Examples ### Example 1: Run a JavaScript calculation ```bash 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]` ### Example 2: Run Python with imports ```bash echo "import math; print(math.factorial(10))" | node scripts/run-code.cjs python ``` Output: `3628800` ### Example 3: Test a Go function ```bash echo 'package main; import "fmt"; func main() { fmt.Println("Hello from Go!") }' | node scripts/run-code.cjs go ``` Output: `Hello from Go!`

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 code-runner-local-1776123378 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 code-runner-local-1776123378 技能

通过命令行安装

skillhub install code-runner-local-1776123378

下载 Zip 包

⬇ 下载 code-runner v1.0.0

文件大小: 8.46 KB | 发布时间: 2026-4-14 10:09

v1.0.0 最新 2026-4-14 10:09
Initial release of the Code Runner skill.

- Run code snippets in over 30 programming languages, including JavaScript, Python, Java, C/C++, Go, Rust, and more.
- Supports both interpreted and compiled languages via command line.
- Provides guidelines for identifying language, executing code, and handling output/errors.
- Includes detailed instructions and examples for running code in different environments (Windows, macOS, Linux).
- Emphasizes security with recommendations for running untrusted code.
- Offers troubleshooting tips for common issues like missing interpreters or code errors.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部