Code Runner
/install code-runner
\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
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install code-runner - After installation, invoke the skill by name or use
/code-runner - Provide required inputs per the skill's parameter spec and get structured output
What is 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... It is an AI Agent Skill for Claude Code / OpenClaw, with 1589 downloads so far.
How do I install Code Runner?
Run "/install code-runner" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Code Runner free?
Yes, Code Runner is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Code Runner support?
Code Runner is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Code Runner?
It is built and maintained by formulahendry (@formulahendry); the current version is v0.1.0.