rh is designed for efficient input and output from AI agents by minimizing reads and reducing output tokens for writing.
For best usage, add the system prompt to your agent.
Requires Go 1.25+.
Install directly:
Requires
~/go/bin(or$GOPATH/bin) to be on your$PATH. Ifrhisn't found after install, addexport PATH="$PATH:$(go env GOPATH)/bin"to your shell profile.
go install github.com/use-focus/rh@latestOr clone and build:
git clone https://github.com/use-focus/rh
cd rh
make install| Command | Description |
|---|---|
rh read <file> |
Print every line prefixed with its hash. Run this first to register a file. |
rh grep <grep_args...> |
Run grep and replace line numbers with stable hashes. Registered files are ready to write immediately. |
rh preview <file> <start_hash> <end_hash> |
Show a line range without modifying the file. Registers the file for subsequent writes. |
rh write <file> <start_hash> <end_hash> |
Replace lines from start_hash to end_hash (inclusive) with content from stdin. Empty stdin deletes the range. |
rh append <file> |
Add content from stdin to the end of the file. |
Read a file to get hashes:
rh read main.go
# abcd func main() {
# efgh fmt.Println("hello")
# ijkl }Write (replace) a range using a heredoc:
rh write main.go efgh efgh << 'EOF'
fmt.Println("world")
EOFDelete a range (empty stdin):
echo -n | rh write main.go efgh ijklAppend content:
echo "// end of file" | rh append main.goGrep across files:
rh grep -R 'func ' .
rh grep -i -E 'usage|error' *.gorh write and rh append are blocked if the file was modified outside of rh since the last read/grep/preview/write. Run rh read, rh grep, or rh preview to resync before writing.