A powerful CLI tool for developers who love automation. sir.sh (CLI command: sir) is a local-first workflow/task runner built on Laravel Zero, designed to help you define, share, and execute complex development workflows.
- Layered Configuration: Supports
.sir/folders at project and global levels with automatic layer resolution - Pack System: Install workflow packs from Git repositories without Composer
- Workflow Engine: Define workflows in YAML with support for variables, templating, and step dependencies
- Built-in Tasks: Common operations like git clone, file operations, test running, and more
- Method System: Extensible method definitions from packs (shell or exec-based)
- AI Agent Interface: MCP-style tool surface for AI assistants to discover and execute workflows safely
- Clean Output: Step headers, progress indicators, timing, and success/fail markers
While the v1 implementation is fully functional for its intended use cases, there are some known limitations to be aware of:
-
Template Parsing: The
default()function in templates doesn't handle commas or nested parentheses in default values. For v1, use simple string literals as defaults. -
Input Gathering: The RunWorkflowCommand assumes workflow inputs are passed as options or the first positional argument. Multiple positional inputs aren't fully supported - use options for complex workflows.
-
Nested Properties: Template expressions like
{{obj.property}}aren't supported. Access nested values by setting them as top-level variables in workflow steps.
These limitations are documented and can be addressed in future versions without breaking existing workflows.
- PHP 8.2 or higher
- Git
- Composer
# Clone the repository
git clone https://github.com/sir-sh/sir-cli.git
cd sir-cli
# Install dependencies
composer install
# Make the application executable
chmod +x application
# Optional: Create a symlink for global access
sudo ln -s $(pwd)/application /usr/local/bin/sir
# Or add to your PATH
export PATH="$PATH:$(pwd)"# Create global .sir directory
mkdir -p ~/.sir/workflows
mkdir -p ~/.sir/packs
# Copy example workflow and config
cp examples/workflows/review.yml ~/.sir/workflows/
cp examples/config.yml ~/.sir/sir listCreate .sir/workflows/hello.yml in your home directory:
description: "A simple hello world workflow"
inputs:
name:
type: string
required: true
description: "Your name"
steps:
- shell: "echo 'Hello, {{name}}!'"sir run hello
# When prompted, enter your name# Run a workflow
sir run <workflow>
# Run with dry-run (preview without executing)
sir run <workflow> --dry-run
# Run non-interactively
sir run <workflow> --non-interactive --yes# List all workflows
sir workflows:list
# Show workflow details
sir workflows:show <workflow>
# Show execution plan
sir plan <workflow>
# Show loaded .sir layers
sir where# Install a pack from GitHub
sir recipes:install github:owner/repo
sir recipes:install github:owner/repo@branch
# Install with shorthand
sir recipes:install owner/repo
# Install from git URL
sir recipes:install git:https://github.com/owner/repo.git#main
# Install to project instead of global
sir recipes:install owner/repo --project
# List installed packs
sir recipes:list
sir recipes:list --project
# Remove a pack
sir recipes:remove <pack-id>
sir recipes:remove <pack-id> --project# List available tools
sir agent tools
# Show execution plan for a workflow
sir agent plan <workflow>
# Execute with confirmation
sir agent run <workflow>Sir resolves .sir/ folders by walking up from the current directory:
- Current directory:
./.sir - Parent directories:
../.sir,../../.sir, etc. - Walks all the way to root
/ - Global:
~/.sir
Precedence: Nearest layer overrides parent, parent overrides global.
# Check which layers are loaded
sir whereWorkflows are YAML files in .sir/workflows/ directories:
description: "Workflow description"
inputs:
myInput:
type: string
required: true
default: "default value"
description: "Input description"
steps:
# Call a built-in task
- task: workspace.temp
with:
prefix: "my-workspace"
saveAs: workspace
# Call a pack method
- method: git.clone
with:
repo: "https://github.com/user/repo.git"
folder: "{{workspace.workspace}}/repo"
saveAs: cloneResult
# Run a shell command
- shell: "echo 'Working dir: {{cloneResult.path}}'"
# Use saved variables
- task: files.write
with:
path: "{{workspace.workspace}}/output.txt"
content: "Cloned to {{cloneResult.path}}"Workflows support template expressions:
{{variable}}- Simple variable substitution{{shellQuote(variable)}}- Shell-quoted variable (for security){{default(variable, 'fallback')}}- Variable with fallback
Sir includes several built-in tasks:
workspace.temp- Create temporary workspace directories
files.write- Write content to a filefiles.writeMd- Write markdown with optional title
git.clone- Clone a repository
tests.auto- Automatically detect and run tests (npm or composer)
coderabbit.review- Request CodeRabbit review (requires CLI)
Packs are reusable collections of methods that can be installed from Git repositories.
pack-name/
├── sir-pack.json # Pack metadata
├── methods/
│ ├── method1.json # Method definition
│ └── method2.json
└── scripts/ # Optional scripts for exec methods
└── script.py
Example methods/clone.json:
{
"method": "clone",
"description": "Clone a git repository",
"args": {
"repo": {
"type": "string",
"required": true
},
"folder": {
"type": "path",
"required": false
}
},
"effects": {
"network": true,
"writes": ["{{folder}}"]
},
"impl": {
"type": "shell",
"command": "git clone {{shellQuote(repo)}} {{shellQuote(folder)}}"
}
}# The example pack is in examples/packs/sir-git
# To use it, install it as a pack:
cd examples/packs
git init
git add .
git commit -m "Example pack"
# Then install from local path (in real usage, you'd push to GitHub)
# For now, manually copy to ~/.sir/packs/
cp -r sir-git ~/.sir/packs/The included review workflow demonstrates a complete workflow:
sir run review myproject --target=feature/new-feature --base=mainThis workflow:
- Creates a temporary workspace
- Clones the project repository
- Runs tests automatically
- Requests CodeRabbit review
- Saves results to markdown files
./vendor/bin/pestCheck code style:
./vendor/bin/pint --testFix code style:
./vendor/bin/pintBuild a standalone executable:
php application app:buildSir.sh is organized into several key components:
- LayerResolver: Discovers
.sirdirectories - ConfigLoader: Loads and merges configurations
- PackManager: Manages pack installation from Git
- MethodRegistry/Executor: Handles pack method execution
- WorkflowLoader/Runner: Loads and executes workflows
- TaskRegistry: Registry for built-in tasks
- Context: Manages variables across workflow execution
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
Built with Laravel Zero - The Laravel micro-framework for console applications.