rok - Run One, Know All
Execute multi-step tasks from JSON - the ultimate automation tool for developers and AI agents.
What is rok?
rok is a CLI tool that executes multi-step tasks defined in JSON format. It's designed for:
- Developer workflows - Automate repetitive tasks
- AI agents - Self-contained task execution
- CI/CD pipelines - Complex build and deployment scripts
- Self-evolution - Use rok to improve rok
Installation
# From crates.io
# From source
# Local development
Quick Start
Basic Usage
# Run from file
# Run from stdin
|
# Run from inline JSON
Example: File Operations
Core Concepts
Steps
rok provides 20+ built-in step types:
| Category | Steps |
|---|---|
| File Operations | read, write, mv, cp, rm, mkdir, patch |
| Search | grep, scan, extract |
| Code Analysis | summarize, lint, diff |
| Templates | template |
| Version Control | git, snapshot, restore |
| Network | http |
| Control Flow | if, each, parallel |
References
Pass data between steps using refs:
Conditionals
Advanced Features
Templates
Create reusable templates:
Templates support:
- Custom props with validation
- Inheritance (
extendsfield) - Derived transforms (pluralize, camelcase, etc.)
Task Files
Save and reuse tasks:
# Save current payload as a named task
# Run saved task
# List all tasks
Environment Variables
Use {{env.VAR_NAME}} in any string field:
Timeouts & Retries
Step Enhancements
All steps support:
id- Referenceable identifier- Custom fields per step type (max_bytes, create_dirs, case_sensitive, context_lines, encoding)
CLI Commands
rok - AI Agent Task Runner
Commands:
templates List available templates
init-template Create a new template
validate-template Validate a template schema
run Run a saved task
save Save current payload as task
list List saved tasks
edit Edit a saved task
watch Watch files and re-run
history Show execution history
replay Replay a previous run
Options:
-f, --file FILE Path to JSON file
-j, --json JSON Inline JSON payload
-o, --output Output format: json, pretty, silent
-v, --verbose Enable verbose output
-q, --quiet Suppress output
--dry-run Preview without executing
Configuration
Configuration File (.rokrc)
rok supports configuration files to set default options. Create a .rokrc, rok.toml, or .rok/config.toml file in your project root:
# .rokrc example
[]
= "pretty"
= true
= true
= 60000
[]
= "development"
= "http://localhost:3000"
[]
= "cargo build --release"
= "cargo test --all"
Configuration file locations (checked in order):
.rokrc- TOML format in project rootrok.toml- TOML format in project root.rok/config.toml- TOML format in .rok directory
Task Options
Options can also be specified in the task JSON:
Note: Task options take precedence over configuration file defaults.
Self-Evolution
rok is self-hosting - use it to improve itself:
# Generate a new step module
See usage.md for more self-evolution patterns.
Development
# Build
# Test
# Run all tests with output
# Run integration tests
# Run benchmarks
# Lint
# Format
# Generate documentation
Project Structure
rok/
├── src/
│ ├── main.rs # CLI entry point
│ ├── cli.rs # Argument parsing
│ ├── config.rs # Configuration
│ ├── error.rs # Error types
│ ├── output.rs # Output formatting
│ ├── refs.rs # Reference resolution (with tests)
│ ├── runner.rs # Execution engine
│ ├── schema.rs # JSON schema (with tests)
│ └── steps/ # Step implementations
├── tests/
│ └── integration_test.rs # Integration tests
├── benches/
│ └── runner_bench.rs # Benchmarks
├── docs/
│ ├── ARCHITECTURE.md # Architecture documentation
│ ├── api.md # API reference
│ └── ...
├── examples/ # Example task files
└── scripts/ # Utility scripts
For more information, see:
- CONTRIBUTING.md - Contribution guidelines
- CHANGELOG.md - Version history
- IMPROVEMENT_PLAN.md - Roadmap and improvements
- docs/ARCHITECTURE.md - Technical architecture
License
MIT License - see LICENSE for details.