Summary
Two related issues with rtk psql and the hook rewrite system:
1. psql -h (host) conflicts with rtk psql -h (help)
When the hook rewrites psql -h localhost -p 54322 ... → rtk psql -h localhost -p 54322 ..., RTK interprets -h as its own --help flag instead of passing it through to psql as the host flag.
Repro:
# This prints RTK help instead of connecting to postgres:
PGPASSWORD=postgres rtk psql -h localhost -p 54322 -U postgres -d postgres -c 'SELECT 1'
# Workaround — use `--` separator:
PGPASSWORD=postgres rtk psql -- -h localhost -p 54322 -U postgres -d postgres -c 'SELECT 1'
# ✅ Works correctly
The -- workaround works, but the hook-generated rewrite doesn't include it, so psql is broken out of the box when used with -h for host.
2. exclude_commands in config.toml doesn't match env-var-prefixed commands
Setting exclude_commands = ["psql"] in config.toml correctly excludes bare psql commands:
rtk rewrite "psql -h localhost" # EXIT: 1 ✅ excluded
But the common pattern PGPASSWORD=x psql ... is still rewritten:
rtk rewrite "PGPASSWORD=postgres psql -h localhost -p 54322 -U postgres -d postgres"
# Output: PGPASSWORD=postgres rtk psql -h localhost ... (EXIT: 0 — still rewritten)
It seems rtk rewrite parses the first token as the command name. When the command is prefixed with env vars (PGPASSWORD=postgres psql ...), the exclude check doesn't match psql because the first token is PGPASSWORD=postgres.
Expected behavior
rtk psql should not consume -h as its own help flag — psql's -h means host, not help. Either use a different flag for RTK help or auto-insert -- before psql args.
exclude_commands should match the actual command name even when preceded by inline env vars (e.g., VAR=val psql should still match the psql exclusion).
Environment
- rtk 0.34.1
- macOS (Darwin 25.4.0, arm64)
- Claude Code hook v3
- psql (PostgreSQL) 18.0
Summary
Two related issues with
rtk psqland the hook rewrite system:1.
psql -h(host) conflicts withrtk psql -h(help)When the hook rewrites
psql -h localhost -p 54322 ...→rtk psql -h localhost -p 54322 ..., RTK interprets-has its own--helpflag instead of passing it through to psql as the host flag.Repro:
The
--workaround works, but the hook-generated rewrite doesn't include it, so psql is broken out of the box when used with-hfor host.2.
exclude_commandsin config.toml doesn't match env-var-prefixed commandsSetting
exclude_commands = ["psql"]inconfig.tomlcorrectly excludes barepsqlcommands:But the common pattern
PGPASSWORD=x psql ...is still rewritten:It seems
rtk rewriteparses the first token as the command name. When the command is prefixed with env vars (PGPASSWORD=postgres psql ...), the exclude check doesn't matchpsqlbecause the first token isPGPASSWORD=postgres.Expected behavior
rtk psqlshould not consume-has its own help flag — psql's-hmeans host, not help. Either use a different flag for RTK help or auto-insert--before psql args.exclude_commandsshould match the actual command name even when preceded by inline env vars (e.g.,VAR=val psqlshould still match thepsqlexclusion).Environment