Niro keeps one graph per folder and per branch. When you switch branch, Niro answers from that branch's graph. A git worktree is a second folder checked out from the same repository. When you open a new worktree, Niro builds it too.

How Niro knows your branch

Niro reads the file .git/HEAD in the folder. It never runs git.

Switching branch

New worktrees

The background watcher builds a new worktree of a repository Niro already indexes. Worktrees that already existed when Niro first saw the repository are noted, but not built. Build one of those with niro build in its folder.

If a worktree's build fails, the watcher tries again after 2 minutes and after 10 minutes. After 3 tries it stops, and logs "Gave up building <folder> after N tries; run niro build there to see why."

Which folder an agent's questions are about

Niro's tools answer for the folder the agent's session started in. If you work in another folder (another worktree, or another service), two things help:

Clean-up

Niro removes old copies by itself. It does this at the end of a build, never while answering a question:

Change the 14 days with NIRO_LOCAL_BRANCH_INDEX_IDLE_DAYS and NIRO_LOCAL_MISSING_FOLDER_DAYS. Set either to 0 to turn that clean-up off.