Skip to main content

setup_worktree_agents_md

Function setup_worktree_agents_md 

Source
pub fn setup_worktree_agents_md(
    repo_root: &Path,
    worktree_root: &Path,
    assignment: &WorktreeAssignment,
) -> Result<(), PawError>
Expand description

Reads the root repo’s AGENTS.md, injects the worktree assignment section, writes the result to the worktree root, and protects it from being committed.

Uses two layers of protection:

  1. .git/info/exclude — hides AGENTS.md from git status
  2. git update-index --assume-unchanged — prevents git add -A from staging it

The second layer is critical for AI agents that run git add -A or git add . to commit their work — without it, the injected session content would be committed to the branch.