Skip to main content

Module git_exclude

Module git_exclude 

Source
Expand description

Keeps the startup files AgentMux writes for an agent out of the commits of the folder they are written into.

An agent’s working folder can be a git repository, and the startup file AgentMux composes for it (CLAUDE.md and the other harnesses’ equivalents, or .claude/AGENTMUX_MEMORY.md beside a CLAUDE.md that is the person’s own) holds the agent’s instructions and the memory it is given: it is not part of the project. So each time AgentMux writes one of these files, it first adds the file’s path to the repository’s own .git/info/exclude. That file is local to the clone: it is never committed or pushed, and it changes no tracked file. A file the project already tracks stays tracked, as an exclude entry does not apply to it.

The check is made at every write, so a folder that becomes a repository after the file was first written is covered by the next launch. It looks for the repository from the folder upward, as git does, and understands a linked worktree or a submodule (.git a file that points to the real git folder). It is best effort: a folder that is no repository is left alone, and a failure to write the exclude is logged and never stops a launch.

Functions§

keep_out_of_git
Adds each of names, files AgentMux writes in work_dir (a path relative to it, with /), to the exclude list of the git repository work_dir is in, if it is in one and the entry is not there yet.