run
Lightweight task runner that speaks shell, Python, Node, and more, that communicates natively with your AI Agents.
Define tasks in a Runfile, run them from anywhere. Make them available to AI via the in-built MCP server.
# Runfile
)
)
}
# @shell node
) => ) || );
}
Perfect for project automation, CI scripts, and personal workflows.
Table of Contents
Why run?
It hits a common sweet spot — lightweight, readable, and shell-native for quick CLI automation without the overhead of heavier task systems.
- Zero Config: Shell, Python, Node, or Ruby: right in your Runfile.
- Low Overhead: Instant startup time.
- Shell Native: Use the syntax you already know (
$1,&&, pipes). - Clean Namespace: Organise tasks with
group:tasksyntax. - Global & Local: Project-specific
./Runfileor personal~/.runfile.
Comparison
- vs Make:
runis easier for linear scripts and doesn't require learning Makefile quirks (tabs vs spaces,.PHONY). - vs Just:
runis closer to raw shell scripting. It doesn't have a custom language for variables or logic—it just delegates to your shell. - vs Both:
runis the only task runner with built-in Model Context Protocol support, letting AI agents like Claude discover and execute your tools automatically.
Installation
Recommended
macOS/Linux (Homebrew)
Windows (Scoop)
scoop bucket add nihilok https://github.com/nihilok/scoop-bucket
scoop install runfile
Alternative: Cargo
Works on all platforms:
Tab Completions
Auto-detect your shell and install completions:
Supports bash, zsh, fish, and powershell.
Quick Start
Create a Runfile in your project root:
# Simple one-liner
# Use Python for complex logic
# @shell python
)
)
}
Run your tasks:
List available tasks:
The Runfile Syntax
run parses your Runfile to find function definitions. The syntax is designed to be familiar to anyone who has used bash or sh.
Basic Functions
For simple, one-line commands, you don't need braces.
# Usage: run dev
Block Syntax
Use {} for multi-statement functions. This avoids the need for trailing backslashes.
Arguments & Defaults
Arguments are passed directly to the underlying shell. Access them using standard positional variables: $1, $2, $@.
# Usage: run commit "Initial commit"
# Usage: run deploy prod v2
# $1 = prod, $2 = v2 (defaults to 'latest' if missing)
# Pass all arguments through
Attributes & Polyglot Scripts
You can use comment attributes (# @key value) or shebang lines to modify function behaviour and select interpreters.
Platform Guards (@os)
Restrict functions to specific operating systems. This allows you to define platform-specific implementations of the same task.
# @os windows
When you run run clean, only the variant matching your current OS will execute.
Interpreter Selection
There are two ways to specify a custom interpreter:
1. Shebang detection (recommended):
The first line of your function body can be a shebang, just like standalone scripts:
,
=
}
2. Attribute syntax (@shell):
Use comment attributes for explicit control or when you need to override a shebang:
# @shell python3
,
=
}
Precedence: If both are present, @shell takes precedence over the shebang.
Supported interpreters: python, python3, node, ruby, pwsh, bash, sh
Nested Namespaces
Organise related commands using colons. run parses name:subname as a single identifier.
Execute them with spaces:
Function Composition
Functions can call other functions defined in the same Runfile, enabling task composition and code reuse without duplication.
# Base tasks
# Deploy depends on successful build
When you run run ci, all compatible functions are automatically injected into the execution scope, so you can call them directly without spawning new processes.
Key features:
- Functions can call sibling functions defined in the same file
- Exit codes are properly propagated (use
|| exit 1to stop on failure) - Works across different shells when interpreters are compatible
- Top-level variables are also available to all functions
AI Agent Integration (MCP)
run includes built-in support for the Model Context Protocol (MCP), allowing AI agents like Claude to discover and execute your Runfile functions as tools.
Exposing Functions to AI Agents
Use @desc and @arg attributes to provide metadata for AI agents:
# @desc Search the codebase for specific patterns
# @arg 1:pattern string The regex pattern to search for
# @shell python
for
if )
)
)
for)
if )
)
}
# @desc Deploy the application to a specific environment
# @arg 1:environment string Target environment (staging|prod)
MCP Server Mode
Start run as an MCP server to enable AI agent integration:
Configure in your AI client (e.g., Claude Desktop):
Note: The --runfile argument is required to specify which Runfile the AI agent should use. This allows you to expose specific Runfiles to different AI contexts.
Now AI agents can:
- Discover available tools via
run --inspect - Execute functions with typed parameters
- Receive structured outputs
Inspect Tool Schema
View the generated JSON schema for all MCP-enabled functions:
This outputs the tool definitions that AI agents will see, useful for debugging and validation.
Configuration
Shell Selection
By default, run uses:
- Windows: PowerShell (
pwshif available, elsepowershell) - Unix:
sh
You can override this default by setting the RUN_SHELL environment variable.
# Force Zsh for this command
RUN_SHELL=zsh
# Make it permanent for your session
Note: The commands in your Runfile must be compatible with the configured shell, unless an explicit interpreter (e.g., # @shell python) is defined for that function.
Global Runfile
Create a ~/.runfile in your home directory to define global commands available anywhere.
# ~/.runfile
# Usage: run update
# Usage: run clone <repo>
If a local ./Runfile exists, run looks there first. If the command isn't found locally, it falls back to ~/.runfile.
License
MIT