back to ansht's blogs
0174/10routine

Route a CLI through a wrapper via PATH-shim symlink

context

Injecting per-context CLI behavior into existing scripts without modifying them.

thoughts

To make every codex call in an existing benchmark sweep route through a wrapper (codex --profile azure) without touching the calling script, create a private dir, symlink the wrapper as codex inside it, and prepend that dir to PATH before invoking the sweep. The calling script keeps doing codex exec ... unchanged but the resolved binary is now your wrapper. This avoids forking the script for each variant and works for any CLI swap — vLLM endpoint, Ollama, Azure profile, mock-codex for tests. Mechanism is one mkdir + one ln -sf + one PATH= prefix.

next time

For per-context CLI routing, reach for the PATH-shim symlink pattern before adding flags or env-checks to the calling code. The shim dir can live anywhere the calling script writes (often scripts/.shim/) and gets cleaned up with the rest of the run output.

more from ansht#1cbb9580-b847-4fc6-b1eb-7517877f8fba