An Agent Skill that enables AI agents to run code snippets in 35+ programming languages. Works with GitHub Copilot, Claude Code, and other skills-compatible agents.
- 🚀 35+ Languages: JavaScript, Python, TypeScript, Java, C/C++, Go, Rust, Ruby, PHP, and many more
- ⚡ Interpreted & Compiled: Supports both interpreted languages and compiled languages (C, C++, Java, Rust)
- ⏱️ Timeout Handling: Configurable timeout to prevent infinite loops (default: 30 seconds)
- 🔧 Cross-Platform: Works on Windows, macOS, and Linux
- 📦 Zero Dependencies: Pure Node.js implementation, no npm install required
| Category | Languages |
|---|---|
| Web/Scripting | JavaScript, TypeScript, PHP, CoffeeScript |
| General Purpose | Python, Ruby, Perl, Lua, Julia |
| Systems | C, C++, Go, Rust, Nim, Crystal |
| JVM | Java, Kotlin, Scala, Groovy, Clojure |
| Functional | Haskell, F#, OCaml, Elixir, Racket, Scheme, Lisp |
| Shell | Bash, PowerShell, Batch/CMD |
| .NET | C# Script, F# Script, VBScript |
| Other | R, Swift, Dart, AppleScript, AutoHotkey |
Copy the .github/skills/code-runner directory to your project:
your-project/
└── .github/
└── skills/
└── code-runner/
├── SKILL.md
├── scripts/
│ └── run-code.cjs
└── references/
└── LANGUAGES.md
git clone https://github.com/user/agent-skill-code-runner.git
cd agent-skill-code-runnerOnce installed, the skill is automatically discovered by compatible AI agents. Simply ask:
- "Run this Python code: print('Hello, World!')"
- "Execute the JavaScript: console.log(5 + 3)"
- "Test this Go function..."
The agent will use the skill's instructions and runner script to execute the code.
You can also run the script directly:
Recommended (stdin - avoids escaping issues):
echo "<code>" | node .github/skills/code-runner/scripts/run-code.cjs <language>Alternative (CLI argument - for simple code only):
node .github/skills/code-runner/scripts/run-code.cjs <language> "<code>"Examples:
# JavaScript (stdin)
echo "console.log('Hello, World!')" | node scripts/run-code.cjs javascript
# Python (stdin)
echo "print('Hello, World!')" | node scripts/run-code.cjs python
# Go (stdin - handles quotes perfectly)
echo 'package main; import "fmt"; func main() { fmt.Println("Hello!") }' | node scripts/run-code.cjs go
# Multi-line Java (PowerShell inline here-string)
@"
public class Test {
public static void main(String[] args) {
System.out.println("Hello from Java!");
}
}
"@ | node scripts/run-code.cjs java
# Simple code via CLI argument
node scripts/run-code.cjs javascript "console.log(5 + 3)"
# With custom timeout (in milliseconds)
echo "import time; time.sleep(5); print('Done')" | node scripts/run-code.cjs python --timeout 10000The script requires the appropriate interpreter or compiler for each language to be installed and available in your PATH:
| Language | Required |
|---|---|
| JavaScript | Node.js |
| TypeScript | ts-node (npm i -g ts-node typescript) |
| Python | Python |
| Java | JDK |
| C/C++ | GCC/G++ or Clang |
| Go | Go |
| Rust | Rust |
| Ruby | Ruby |
See references/LANGUAGES.md for the complete list.
- Skill Discovery: AI agents read the
SKILL.mdfile to understand what the skill does - Activation: When a user asks to run code, the agent activates the skill
- Execution: The agent uses
scripts/run-code.cjsto:- Create a temporary file with the code
- Execute it with the appropriate interpreter/compiler
- Return stdout/stderr to the user
- Cleanup: Temporary files are automatically deleted
- Review code before execution
- Be cautious with file system access, network requests, and system commands
- Confirm execution with users when appropriate
For untrusted code, consider running in a sandboxed environment (Docker, VM, etc.).
Problem: Code with quotes or special characters fails with "illegal escape character" or similar errors.
Solution: Use stdin instead of CLI arguments:
# ✓ Good (stdin)
echo "System.out.println(\"Hello\");" | node run-code.cjs java
# ✗ Bad (CLI argument - escaping nightmare)
node run-code.cjs java "System.out.println(\"Hello\");"For AI Agents: Always use stdin when calling the script to avoid shell escaping issues across different platforms.
Problem: Command not found error
Solution: Install the required interpreter/compiler and ensure it's in your PATH:
# Check if installed
python --version
java -version
node --version.github/skills/code-runner/
├── SKILL.md # Skill definition and instructions
├── scripts/
│ └── run-code.cjs # Code execution script (CommonJS)
└── references/
└── LANGUAGES.md # Detailed language reference
This skill follows the Agent Skills open standard:
- name:
code-runner - description: Run code snippets in 30+ programming languages
- location:
.github/skills/code-runner/
Compatible with:
- GitHub Copilot (VS Code, CLI, Coding Agent)
- Claude Code
- Cursor
- Other skills-compatible agents
Contributions are welcome! Please feel free to submit a Pull Request.
- Add the language config to
languageConfiginscripts/run-code.cjs - Update the language table in
SKILL.md - Add detailed info in
references/LANGUAGES.md
MIT License - see LICENSE for details.
- vscode-code-runner - VS Code extension for running code
- mcp-server-code-runner - MCP Server for code execution
- Agent Skills - Open standard for AI agent capabilities