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 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
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: - User's explicit request (e.g., "run this Python code") - File extension if provided - Code syntax patterns
⚠️ 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 scriptspwsh or powershell\#!/usr/bin/env shebang for portable scriptsCommon issues and solutions:
Provide installation instructions
Syntax errors: Code has syntax issues
Point to the line number if available
Runtime errors: Code runs but fails during execution
Explain the error type
Timeout: Code takes too long (default: 30 seconds)
⚠️ Important: Running arbitrary code can be dangerous. Always:
小蔥技能站7w4.net,專業的AI技能分享平臺。
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!
這個 Skill 質量不錯,能執行30多種程式語言的程式碼,適合需要快速驗證程式碼效果的場景。文件寫得清楚詳細,支援通過標準輸入傳遞程式碼不容易出錯,還有超時保護防止程式碼卡死。唯一的小遺憾是某些小眾語言的支援細節文件和實際工具有細微不一致,極端情況下臨時檔案可能清理不完全,整體瑕不掩瑜。