/install code-runner-local
\r \r
Code Runner Skill\r
\r This skill enables you to run code snippets in multiple programming languages directly from the command line.\r \r
When to Use This Skill\r
\r Use this skill when:\r
- The user wants to run or execute a code snippet\r
- Testing algorithm implementations or logic\r
- Verifying expected output of code\r
- Running quick scripts or one-liners\r
- Checking syntax or runtime behavior\r
- Demonstrating code functionality\r \r
Supported Languages\r
\r
The following languages are supported (requires the interpreter/compiler to be installed):\r
\r
| Language | Command | File Extension |\r
|----------|---------|----------------|\r
| JavaScript | node | .js |\r
| TypeScript | ts-node | .ts |\r
| Python | python | .py |\r
| Java | java (compile & run) | .java |\r
| C | gcc (compile & run) | .c |\r
| C++ | g++ (compile & run) | .cpp |\r
| Go | go run | .go |\r
| Rust | rustc (compile & run) | .rs |\r
| Ruby | ruby | .rb |\r
| PHP | php | .php |\r
| Perl | perl | .pl |\r
| Lua | lua | .lua |\r
| R | Rscript | .r |\r
| Swift | swift | .swift |\r
| Kotlin | kotlin | .kts |\r
| Scala | scala | .scala |\r
| Groovy | groovy | .groovy |\r
| Dart | dart | .dart |\r
| Julia | julia | .jl |\r
| Haskell | runhaskell | .hs |\r
| Clojure | clojure | .clj |\r
| F# | dotnet fsi | .fsx |\r
| C# | dotnet script | .csx |\r
| PowerShell | pwsh | .ps1 |\r
| Bash | bash | .sh |\r
| Batch | cmd /c | .bat |\r
| CoffeeScript | coffee | .coffee |\r
| Crystal | crystal | .cr |\r
| Elixir | elixir | .exs |\r
| Nim | nim compile --run | .nim |\r
| OCaml | ocaml | .ml |\r
| Racket | racket | .rkt |\r
| Scheme | scheme | .scm |\r
| Lisp | sbcl --script | .lisp |\r
\r
See references/LANGUAGES.md for detailed language configuration.\r
\r
How to Run Code\r
\r
Step 1: Identify the Language\r
\r Determine the programming language from:\r
- User's explicit request (e.g., "run this Python code")\r
- File extension if provided\r
- Code syntax patterns\r \r
Step 2: Execute Using the Runner Script\r
\r ⚠️ Important for AI Agents: Use stdin to avoid escaping issues with quotes, backslashes, and special characters.\r \r Recommended Method (stdin):\r
echo "\x3Ccode>" | node scripts/run-code.cjs \x3ClanguageId>\r
```\r
\r
**Alternative Method (CLI argument - for simple code only):**\r
```bash\r
node scripts/run-code.cjs \x3ClanguageId> "\x3Ccode>"\r
```\r
\r
**Example - JavaScript:**\r
```bash\r
echo "console.log('Hello, World!')" | node scripts/run-code.cjs javascript\r
```\r
\r
**Example - Python:**\r
```bash\r
echo "print('Hello, World!')" | node scripts/run-code.cjs python\r
```\r
\r
**Example - Java (multi-line):**\r
```bash\r
echo "public class Test {\r
public static void main(String[] args) {\r
System.out.println(\"Hello from Java!\");\r
}\r
}" | node scripts/run-code.cjs java\r
```\r
\r
**Example - Multi-line code from variable:**\r
```bash\r
# In bash\r
CODE='import math\r
print("Pi:", math.pi)\r
print("Result:", math.factorial(5))'\r
echo "$CODE" | node scripts/run-code.cjs python\r
\r
# In PowerShell (inline here-string)\r
@"\r
import math\r
print("Pi:", math.pi)\r
print("Result:", math.factorial(5))\r
"@ | node scripts/run-code.cjs python\r
```\r
\r
### Step 3: Return Results\r
\r
- Show the output (stdout) to the user\r
- If there are errors (stderr), explain what went wrong\r
- Suggest fixes for common errors\r
\r
## Platform Notes\r
\r
### Windows\r
- Use `cmd /c` for batch scripts\r
- PowerShell scripts require `pwsh` or `powershell`\r
- Path separators use backslash `\`\r
\r
### macOS / Linux\r
- Bash scripts work natively\r
- Swift available on macOS\r
- Use `#!/usr/bin/env` shebang for portable scripts\r
\r
## Error Handling\r
\r
Common issues and solutions:\r
\r
1. **Command not found**: The language interpreter is not installed or not in PATH\r
- Suggest installing the required runtime\r
- Provide installation instructions\r
\r
2. **Syntax errors**: Code has syntax issues\r
- Show the error message\r
- Point to the line number if available\r
\r
3. **Runtime errors**: Code runs but fails during execution\r
- Display the stack trace\r
- Explain the error type\r
\r
4. **Timeout**: Code takes too long (default: 30 seconds)\r
- Warn about infinite loops\r
- Suggest optimizations\r
\r
## Security Considerations\r
\r
⚠️ **Important**: Running arbitrary code can be dangerous. Always:\r
\r
1. Review the code before execution\r
2. Be cautious with code that:\r
- Accesses the file system\r
- Makes network requests\r
- Executes system commands\r
- Modifies environment variables\r
3. Consider running in a sandboxed environment for untrusted code\r
\r
## Examples\r
\r
### Example 1: Run a JavaScript calculation\r
```bash\r
echo "console.log(Array.from({length: 10}, (_, i) => i * i))" | node scripts/run-code.cjs javascript\r
```\r
Output: `[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]`\r
\r
### Example 2: Run Python with imports\r
```bash\r
echo "import math; print(math.factorial(10))" | node scripts/run-code.cjs python\r
```\r
Output: `3628800`\r
\r
### Example 3: Test a Go function\r
```bash\r
echo 'package main; import "fmt"; func main() { fmt.Println("Hello from Go!") }' | node scripts/run-code.cjs go\r
```\r
Output: `Hello from Go!`\r
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install code-runner-local - 安装完成后,直接呼叫该 Skill 的名称或使用
/code-runner-local触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Code Runner Local 是什么?
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... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 318 次。
如何安装 Code Runner Local?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install code-runner-local」即可一键安装,无需额外配置。
Code Runner Local 是免费的吗?
是的,Code Runner Local 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Code Runner Local 支持哪些平台?
Code Runner Local 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Code Runner Local?
由 panchenbo(@panchenbo)开发并维护,当前版本 v1.0.0。