# Working on branches with Niro

Your team decides what Niro indexes: you create projects, and each project
covers the repos and branches you choose. One project might index main,
another might index a develop or release branch. That is up to you.

When you ask a question, Niro picks the project that matches your repo and
the branch you are currently on. This page is about the moment when NO
project matches: you created a new branch and changed code that no project
has indexed yet. Two minutes to read.

## The short version

There is one command to remember:

    niro new-temp-project

Run it in your repo folder when Niro asks for it. That is all.

## What you will see

You create a branch that no project covers and start changing code.
Then you ask your AI assistant something about the code.

Niro notices that no project has indexed this branch. Instead of giving
you a wrong answer based on some other branch, it replies with something
like:

    I cannot answer this safely. Your branch has diverged
    from the branch Niro indexed.

Your assistant will offer to fix this by running:

    niro new-temp-project

Say yes, or run it yourself in the repo folder. It takes a few seconds.

## What the command does

It creates your own private copy of the project inside Niro.

- The copy follows your branch, including changes you have not committed.
- Every save updates the copy, as long as "niro watch" is running.
- Your original project is not changed. It keeps its own index.
- The copy is fully separate and disposable.

From then on, answers come from YOUR code.

## Switching branches

Nothing to do. Niro checks which branch you are on for every question.

- On your new branch: answers come from your private copy.
- On a branch one of your projects already indexes: answers come
  from that project.

## When your work is merged

Run this in the repo folder:

    niro discard-temp-project

It deletes your private copy. Your local files are never touched.
If you forget, Niro deletes unused copies by itself after two weeks.

## A feature that spans several repos

Run "niro new-temp-project" in each repo folder you branch.
All of them join the same private copy, so questions that cross repos
(for example: what breaks in service B if I change service A?) see all
of your changes together.

## Common questions

Does this change my original project?
No. The original project and its index stay exactly as they were.
The copy is separate; deleting it later loses nothing.

Does this work with my AI assistant and my git host?
Yes. Any assistant that supports MCP (Claude Code, Cursor, Windsurf,
Codex, and others) and any git server (GitHub, GitLab, Bitbucket,
self-hosted).

Is creating a copy slow?
No. Niro copies the existing index instead of re-reading your code.
It normally takes seconds.

I just created a branch and have not changed anything. Will Niro nag me?
No. Your code is still identical to the branch you started from, so Niro
answers normally. It only steps in once your code actually differs.

We already have projects for main and develop. Do I need this?
Not while you are on main or develop: Niro routes to the matching project
by itself. You only need a temporary project for a branch that none of
your projects cover.

What if I really want an answer from the shared project while on my branch?
Tell your assistant so. The answer will be clearly labeled as describing
the indexed branch, not your code.
