> ## Documentation Index
> Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Explore a code diff into a separate test repo

> Run the explore agent against a pull request in your application repo and write the generated tests into a separate Momentic test repo.

<Warning>The explore agent is in beta and may change.</Warning>

Plenty of teams keep their Momentic tests in a repo of their own, separate from
the application they cover. [`momentic ai explore`](/docs/ai/explore) still works
across that split, because the repo it diffs and the repo it writes to are
independent. `explore diff` diffs whatever repo you run it in, the current
working directory. `--config` picks the
[`momentic.config.yaml`](/docs/configuration/momentic-config) that defines the
project, and that config decides where tests are read from and written to.

This guide covers the pull-request setup: diff the app repo, write into the test
repo. If you would rather not manage two checkouts, see
[Seed a separate test repo against a running app](/docs/guides/explore/poly-repo-seed).

## Run it

Check both repos out side by side, say the app at `/code` and the tests at
`/tests`, and run explore from the app checkout with `--config` aimed at the
test repo:

```bash theme={null}
cd /code
npx momentic ai explore diff --config /tests/momentic.config.yaml
```

The diff is `/code`, so make sure that checkout has enough history to cover the
change under review (`fetch-depth: 0` on GitHub Actions). In CI the range
defaults to the pull request's window, so you rarely pass one explicitly. The
project is `/tests`, so the agent reads your existing tests from there and
writes new ones back into `/tests`.

## Delivering the tests

This is the catch with the pull-request setup. The **On successful explore**
setting in [Settings > Explore](https://app.momentic.ai/settings/explore)
commits and opens its PR against the repo explore ran in, which here is `/code`,
and it only picks up files git reports as changed there. The generated tests
landed in `/tests`, so that automatic PR never sees them.

Leave the setting on its default (`nothing`, which leaves the tests on disk) and
have your workflow commit the `/tests` changes and open the PR against the test
repo itself.

## Notes

* Explore never touches your application code. Its analysis is read-only with
  respect to the code repo.
* `--no-code` works here too if you want the diff window without handing the
  agent the code repo's files.
* A single run reads code from one repo. Pulling in source from several repos at
  once is not supported yet.
