Contents

Private ai configuration

Private ai configuration on public repository

Let’s be honest. Almost all of us use, or have already used, the benefits of artificial intelligence. If you’re a programmer, you’re surely using an agent to work on your program. You probably also know that it performs better when you describe your project to it. But how do you maintain such a configuration if you can’t save it directly to the repository?

Warning
This article was translated with DeepL.com (free version) from polish language. I have made every effort to make it correct. However, if you found any errors or inaccuracies, please let me know.

tl;dr

  • AI agents can be configured using AGENTS.md files located in the code
  • The stow tool allows you to link files and directories to the structure of another repository
  • We use .git/info/exclude to ignore linked files
  • Other ideas for using stow configuration here

AI Configuration

Thanks to AI agents, we are able to manage our code more effectively. They can analyze the project and make changes exactly where they are needed. However, this information isn’t always immediately apparent. An agent can’t always figure out on its own how to navigate our code.

To help agents edit our code correctly, it’s worth providing them with some information about the architecture of the solution we’re using. This data is most often saved to AGENTS.md files located in the repository. For many models, this file may have different names, but it is most often a set of instructions appended to the main query.

Another source of data can also be tools called skills or agents (depending on the service used). They provide additional instructions for a specific action we want to take. This could be, for example, code review, creating documentation, or checking code correctness. They look similar to the aforementioned AGENTS.md files, but are added at the developer’s request. Copilot, for example, locates them in the .github folder

Configuration files can be included in the main code repository and thus made available to all users. But what if we don’t want to include these files in the official code, yet would like to keep them in an external repository that is properly linked to the main code?

Configuration in an external repository

If you want to synchronize agent files in a private repository, it’s a good idea to ensure that the process of uploading new changes is as automated as possible.

I use the stow tool for this. It is a simple program that creates links for configuration files from the internal repository to a selected location in the file structure, allowing for quick editing in the main repository. In other words, if we create a configuration file in our private repository, we link it to the work repository. This way, we can edit the configuration file at the company repository level and save changes to the private repository.

It’s worth noting that this tool was originally created to synchronize configurations in Linux /home files, which made it easier to transfer them between a user’s devices.

So let’s create a private repository where we’ll store our configuration. The repository should contain a folder named after our configuration. This way, we’ll be able to store settings for multiple projects—or multiple configurations that we can switch between—all in a single repository.

mkdir private-config && cd private-config
git init
mkdir main-config

Now, in the configuration directory (in our example, main-config), we create a directory structure that matches our project and add the selected files there.

touch main-config/AGENT.md ## AGENT.md will be located in the main directory

mkdir main-config/.github/agents && touch main-config/.github/agents/pull-request.md ## pull-request will be created in the .github/agents directory

Now simply use the stow tool to link our configuration:

stow --target <path_to_workspace> main-config

Now stow will automatically add symbolic links to the files from main-config, and they will be visible in the main repository. In the case of the .github/agents folder, if it existed previously, the files within it will be included. If this directory did not exist previously, it will be added in its entirety, so that newly added files will automatically end up in the private configuration repository.

Hiding Configuration Files in the Repo

One drawback of our solution is that the version control system will suggest adding our files to version control. We can therefore list them in our .gitignore file located in the repository. But what if we don’t want to leave any traces in the main repository?

A great alternative is the .git/info/exclude file. It serves the same purpose as .gitignore but is not subject to version control. It can therefore be used to list files that should be “invisible” to the version control system.

Sample file content for our case:

AGENTS.md
/.github/agents

You might be tempted to add this file to a private repository with the configuration, but I recommend caution in this case. If you want to add several different configurations (profiles), conflicts may occur, and the tool won’t know which exclude file to use.

Let’s configure a few more things

Using the tools I mentioned, you can upload not only agent configurations but also other types of settings. Here are a few examples:

  • Global tool settings. (links to the /home file)
  • Configuration of your favorite IDE (e.g., IntelliJ issue link)
  • Adding a documentation repository directly to the code repository
  • Adding private scripts inside the repo
  • An additional build system to facilitate navigation within the repository, e.g., Taskfile
  • Extending the application code with additional files containing tools for quick debugging (e.g., a custom logger defined in an additional file)

Bibliography

  1. https://www.gnu.org/software/stow/manual/stow.html - Stow documentation
  2. https://git-scm.com/docs/gitignore - Gitignore documentation