-
Notifications
You must be signed in to change notification settings - Fork 0
direnv
direnv
automatically loads and unloads environment variables depending on the current directory. The values set remain set for all sub-directories. When you cd
out of the directory tree, the envars will be either dropped or their prior values restored.
Installation: brew install direnv
Website: https://direnv.net/
Here are some of the ways in which using direnv
can enhance your prompt engineering / usage experience.
Suppose you have one directory tree with program source code. In another directory tree you have documentation or articles you are writing. Lets start these two directory trees at src
and doc
respectively.
The file src/.envrc
contains this:
export AIA_SHELL=true
export ROLE="ruby software engineering expert"
The file doc/.envrc
contains this:
export AIA_SHELL=true
export ROLE="editorial reviewer of technical documents"
Now let's suppose that you have a prompt ID (advise_me_on) that has the following text:
As $ROLE advise me on how to improve the following file:
When you are in the src
directory you might do:
aia advise_me_on my_class.rb
and when you are in the doc
directory tree you might do:
aia advise_me_on article_20240105.md
You are reusing the same prompt but because $AIA_SHELL
and $ROLE
envars are set, the prompt returns different responses because the context of the prompt is different.
Recall that setting $AIA_SHELL
to true is the same as if you used the --shell
option on the aia
execution. It enables the prompt text to have envars replaced with their value.