A couple of weeks after building kommit
(as mentioned in the
previous post), I found
myself working with the AWS CLI quite a bit. I was trying to figure out which
VPC had a security group that whitelisted an IP, so I could use it as an ingress
point for an EC2 instance. It took a few commands to get there, and I thought I
should wrap this as a CLI tool so I wouldn’t have to switch between my terminal
and browser.
Yet another weekend effort resulted in cfor.

This tool is very straightforward. You can install it with Homebrew:
brew install cowboy-bebug/tap/cfor
Or from source:
git clone https://github.com/cowboy-bebug/cfor.git && cd cfor
make install
You’ll need to export one of these environment variables (the CFOR_
one takes
precedence), just like with kommit
:
export OPENAI_API_KEY="sk-..."
export CFOR_OPENAI_API_KEY="sk-..."
And using it is as simple as:
cfor "list security groups in AWS"
And the result is a list of commands matching the question.
What I Learned
The results aren’t as good as kommit
. I think cfor
needs more work around
prompt optimisation.
One neat thing I learned was how to use syscall.TIOCSTI
to inject a selected
command directly into the next terminal prompt. This lets cfor
write the
generated command into your shell input buffer, as if you had typed it manually,
so you can review or edit it before executing.
Behind the scenes, it uses a low-level ioctl
call to simulate keystrokes,
character by character. This works on both macOS and Linux with
platform-specific constants.
The inject function
disables terminal echo, then uses syscall.TIOCSTI
to push each character of
the command into the shell’s input buffer via SYS_IOCTL
. Once done, it
restores the original terminal state.
This allows the user to “see” the generated command as if they’d typed it, making it feel native while keeping full control over whether to run or modify it.
It felt a bit like a hack, but a fun one, and surprisingly effective.
Again, this is probably made obsolete by claude
🥲