Execute code snippets in multiple languages with sandboxed environments. Supports JavaScript, TypeScript, Python, and shell scripts with timeout protection and output capture.
Execute code snippets safely with output capture and timeout protection.
node /path/to/skills/code-runner/scripts/run.js --lang js "console.log('Hello')"
node /path/to/skills/code-runner/scripts/run.js --file script.py --lang python
node /path/to/skills/code-runner/scripts/repl.js --lang js
Execute code snippets in various languages.
Usage:
node run.js <code> --lang <language>
node run.js --file <path> --lang <language>
Options:
--lang <lang> - Language: js, ts, python, py, shell, bash (required)--file <path> - Execute code from file instead of argument--timeout <ms> - Execution timeout (default: 30000)--stdin <data> - Provide stdin input--args <args> - Command-line arguments (comma-separated)--env <json> - Environment variables as JSONQuick JavaScript expression evaluation.
Usage:
node eval.js <expression>
Features:
Interactive REPL for testing code.
Usage:
node repl.js --lang <language>
Commands:
.exit - Exit REPL.clear - Clear context.help - Show helpBenchmark code execution time.
Usage:
node benchmark.js <code> --lang <language> [OPTIONS]
Options:
--iterations <n> - Number of runs (default: 100)--warmup <n> - Warmup runs (default: 10)| Language | Aliases | Runtime |
|---|---|---|
| JavaScript | js, javascript, node | Node.js |
| TypeScript | ts, typescript | ts-node / tsx |
| Python | py, python, python3 | python3 |
| Shell | sh, shell, bash | /bin/bash |
node run.js --lang js "
const arr = [1, 2, 3, 4, 5];
const sum = arr.reduce((a, b) => a + b, 0);
console.log('Sum:', sum);
"
node run.js --lang python "
import json
data = {'name': 'test', 'value': 42}
print(json.dumps(data, indent=2))
"
node run.js --lang bash "
for i in 1 2 3; do
echo \"Number: \$i\"
done
"
node run.js --lang python --stdin "Hello World" "
import sys
data = sys.stdin.read()
print(f'Received: {data}')
"
node run.js --lang js --args "arg1,arg2" "
console.log('Args:', process.argv.slice(2));
"
node benchmark.js --lang js --iterations 1000 "
const result = Array(100).fill(0).map((_, i) => i * 2);
"
{
"success": true,
"language": "javascript",
"exitCode": 0,
"stdout": "Hello World\n",
"stderr": "",
"duration": 45,
"timedOut": false
}
{
"language": "javascript",
"iterations": 100,
"warmupRuns": 10,
"results": {
"min": 2.3,
"max": 15.7,
"mean": 4.2,
"median": 3.8,
"stdDev": 2.1,
"p95": 8.5,
"p99": 12.3
},
"unit": "ms"
}
{
"success": false,
"language": "python",
"exitCode": 1,
"stdout": "",
"stderr": "NameError: name 'undefined_var' is not defined",
"duration": 120,
"error": "Process exited with code 1"
}