ReadMe Runner is a command-line tool that automatically executes instructions embedded in your README files. Define executable code blocks directly in your documentation using simple HTML comments, and let RR run them safely with built-in confirmation prompts and approval tracking.
- 🚀 Execute commands from README files - Embed executable code blocks directly in your documentation
- 🔒 Safety first - Confirmation prompts for each block before execution
- ✅ Approval tracking - Automatically remembers approved blocks using hash-based tracking
- 🔑 Variable support - Use variables and prompts for dynamic command execution
- 🌍 Environment variables - Load variables from
.envfiles for configuration - 📝 Multi-line commands - Support for complex multi-line bash commands
- 🎯 Selective execution - Only executes code within designated RR blocks, ignores everything else
go install github.com/thestuckster/readmerunner@latestgit clone <repository-url>
cd readmerunner
go build -o rrMove the rr binary to a location in your PATH, or use it directly from the project directory.
- Create an RR block in your README file:
<!-- RR[Hello World]
echo "Hello from ReadMe Runner!"
-->- Run the commands:
readmerunner run- Confirm execution when prompted:
--- Block 1 of 1 ---
Block Name: Hello World
Commands to execute:
1. echo "Hello from ReadMe Runner!"
Execute this block? (y/n): y
readmerunner runExecutes all RR blocks found in README.md or readme.md in the current directory.
Specify a custom project directory:
readmerunner run --path /path/to/project
# or
readmerunner run -p /path/to/projectAuto-execute all blocks without prompts (skips hash checking):
readmerunner run --trust
# or
readmerunner run -tNote: When using --trust, blocks are executed immediately without confirmation prompts or hash tracking.
Specify a custom path to a .env file:
readmerunner run --env /path/to/.env
# or
readmerunner run -e /path/to/.envNote: If --env is not provided, RR will automatically look for a .env file in the project directory (specified by --path or current directory).
RR blocks are defined using HTML-style comments in your README file. Only content within <!-- RR ... --> blocks is executed. Everything else is completely ignored.
ReadMe Runner supports loading environment variables from .env files:
- Automatic discovery: If no
--envflag is provided, RR looks for.envin the project directory - Custom path: Use
--envto specify a custom.envfile location - Standard format: Supports standard
.envfile format (KEY=VALUE) - Variable precedence: Block variables override environment variables if names conflict
- Quoted values: Supports both single and double-quoted values in
.envfiles
Environment variables are loaded before block execution and can be used in commands using the #VARIABLE_NAME syntax.
ReadMe Runner uses a .rr file in your project directory to track approved blocks:
- First run: You'll be prompted to approve each block
- Approved blocks: Once approved, blocks are hashed and saved to
.rr - Subsequent runs: Previously approved blocks (with matching content) execute automatically
- Modified blocks: If a block's content changes, its hash changes and you'll be prompted again
This ensures you're always aware of what's being executed while avoiding repetitive confirmations for trusted blocks.
<!-- RR
echo "This is a basic unnamed RR block"
--><!-- RR[Setup Environment]
export NODE_ENV=production
npm install
--><!-- RR[Deploy]
environment = "staging"
echo "Deploying to #environment environment"
deploy.sh --env #environment
--><!-- RR[Login]
username = #prompt("Enter your username:")
password = #prompt("Enter your password:")
login.sh -u #username -p #password
--><!-- RR[Build and Deploy]
echo "Building application..." && \
npm run build && \
echo "Deploying..." && \
deploy.sh
--><!-- RR[Full Setup]
project-name = #prompt("What is your project name?")
env = "development"
echo "Setting up #project-name in #env mode" && \
npm install && \
npm run setup
-->Environment variables from .env files can be used in your commands:
.env file:
APP_NAME=MyApp
API_KEY=secret-key-123
DEBUG=true
RR Block:
<!-- RR[Config Test]
echo "App: #APP_NAME"
echo "API Key: #API_KEY"
echo "Debug mode: #DEBUG"
-->Variables from .env files are automatically loaded and can be referenced using #VARIABLE_NAME syntax. Block variables take precedence over environment variables if there's a name conflict.
For complete syntax documentation, including all available features and detailed examples, see ReadmeRunerSyntax.md.
- Only RR blocks execute: Commands outside HTML comment blocks are completely ignored
- No accidental execution: Regular markdown code blocks and inline commands are safe
- Interactive prompts: Each block requires explicit approval before execution
- Block information: See exactly what commands will run before confirming
- Skip option: Choose to skip any block you're unsure about
- Content verification: Blocks are hashed based on their content (name, commands, variables)
- Automatic approval: Previously approved blocks run without prompts
- Change detection: Modified blocks require re-approval
your-project/
├── README.md # Your README with RR blocks
├── .env # Environment variables (optional)
├── .rr # Approval tracking file (auto-generated)
└── ...
.env: Optional file containing environment variables inKEY=VALUEformat. Automatically loaded if present in the project directory..rr: Automatically created in your project directory when you first approve a block. It contains SHA256 hashes of approved blocks.
- Name your blocks: Named blocks are easier to identify in confirmation prompts
- Use variables for secrets: Use
#prompt()for sensitive information like passwords, or store them in.envfiles (and add.envto.gitignore) - Keep blocks focused: Each block should have a single, clear purpose
- Review before approving: Always review the commands before confirming execution
- Version control
.rr: Consider adding.rrto your.gitignoreif you want per-developer approval tracking - Environment variables: Use
.envfiles for configuration that varies between environments (development, staging, production)
If you see "No RR blocks found in readme file", ensure:
- Your README file is named
README.mdorreadme.md - RR blocks use the correct syntax:
<!-- RR ... --> - Blocks are properly closed with
-->
- Check that you've confirmed the block with
ywhen prompted - Verify the block syntax is correct
- Ensure commands are inside the HTML comment block
Contributions are welcome! Please feel free to submit a Pull Request.
See LICENSE file for details.