A custom agent is only useful if it's easy to run. In this lesson, we'll level up our "French" agent by compiling it into a standalone executable with bun build. You'll learn how to transform a clunky bun run agents/french.ts command into a simple, memorable french command that you can run from anywhere in your terminal. We'll walk through adding the agent to your system's PATH, making your custom AI tools feel like a natural part of your command-line environment.
PATH environment variable.bun run ... commands into a single, memorable command (e.g., french).First, compile the TypeScript agent into an executable file located in a bin directory.
bun build agents/french.ts --compile --outfile bin/french
You can now run the agent directly by referencing the new executable file.
bin/french
To make this command globally accessible, open your shell's configuration file. In this case, it's .zshrc.
cursor ~/.zshrc
Add a line to export the path to your bin directory, appending it to the existing PATH.
export PATH="$PATH:/Users/johnlindquist/dev/agents/bin"
Reload your shell's configuration to apply the changes immediately.
source ~/.zshrc
Now, you can run your agent from anywhere on your system by simply typing its name.
french
You can interact with your newly created global agent.
> testing
> hello
[00:00] So now we can take our little agent here and run bon build and we'll point to our agent file. So we'll say agents French. We want to compile this to an out file of bin slash French. So now we have a file in here in bin slash French. If we simply run bin French, type whatever, we now have an executable which will always speak to us in French.
[00:23] So if we take this path, I'll just right-click on it and copy path. I'm going to use cursor to open my zshrc. Then we can just add another line for export path. This one can be path and then our bin directory. So now if I source my zshrc, which will force it to reload it, I can run the command French from anywhere.
[00:43] We'll try testing again. I'll open another session. We'll navigate to my home directory. I'll type French and this is the standard Claude security warning. I'll allow it to run, I'll say hello, and you can see that anywhere on my system I can just type French from my terminal and I'll have an instance of Cloud Code which will be speaking to me in French.