formulahendry

Code Runner

開發程式設計v0.1.0
作者:formulahendry更新於 2026-05-18code-runner@clawhub_formulahendry/code-runner
指令碼工具#Javascript#Typescript

據 AlphaMoat 統計,截至 2026-10,Code Runner 累計下載 6,241 次、獲 3 個星標,按累計下載量在本次參與排名的 5,109 個 AI 技能中排名第 2,163 位,在「開發程式設計」分類(560 個)中排名第 232 位。

列表預設按累計下載量排序,也可按星標排序;詳情頁排名按累計下載量計算。

累計下載
6241
星標
3
全站下載量排名
#2,163
全站前 43% · 「開發程式設計」前 42%
平台累計下載星標評論
ClawHub ↗3547--
SkillHub ↗62413—

各平台的計數口徑不同,統計時間不一致。

這個技能是做什麼的

支援 30 餘種程式語言(JavaScript、Python、TypeScript、Java、C、C++、Go、Rust、Ruby、PHP 等)的程式碼片段執行。適用於使用者需要...

月度資料趨勢

累計下載6241
867375366392026-03 · 累計下載 12652026-05 · 累計下載 24942026-06 · 累計下載 27442026-07 · 累計下載 31562026-08 · 累計下載 37542026-09 · 累計下載 46382026-10 · 累計下載 624126-0326-0926-10
星標3
0232026-03 · 星標 -2026-05 · 星標 22026-06 · 星標 22026-07 · 星標 32026-08 · 星標 32026-09 · 星標 32026-10 · 星標 326-0326-0926-10

2026-09 起統計方法調整:同名技能按作者分別統計,並覆蓋全部技能。圖中虛線為調整前的月份,與之後的資料不直接比較,也不計算跨越調整的增長。 該技能有同名的其他版本,調整前的資料歸屬當前下載量最大的這一個。

月份累計下載環比星標
2026-106241—3
2026-094638—3
2026-083754+18.9%3
2026-073156+15.0%3
2026-062744+10.0%2
2026-052494—2
2026-031265—-

SKILL.md 原文

以下是作者釋出的原始檔案,按純文字顯示,本站未做修改或稽核;其中的連結不可點選,命令請核實後再執行。抓取於 2026-10-23。

5.5 KB · ClawHub v0.1.0
---
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.
---

# 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
展開全部(共 190 行)
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!`

「開發程式設計」分類下的熱門技能

資料月份:2026-10 · 下載/星標數聚合自公開技能註冊庫(ClawHub、SkillHub),按月更新。口徑說明見資料方法。