> For the complete documentation index, see [llms.txt](https://docs.neohive.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.neohive.ai/add-your-context/repositories.md).

# Add a repository

Add a GitHub or GitLab repository to a Code or Documentation Index so your agent finds your code and docs by describing what they do.

Connect a repository once, and your agent can find code by describing what the code does, such as `retry handling in the sync engine`, even when the code does not use those words. NeoHive stores the repository in a [Code](/reference/glossary.md#code-index) or [Documentation Index](/reference/glossary.md#documentation-index) inside your [Hive](/reference/glossary.md#hive). Scheduled syncs keep the [Index](/reference/glossary.md#index) up to date.

<figure><img src="https://3192197639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4OPHduIiSuhnAhSI2yPb%2Fuploads%2Fgit-blob-f7bfe1273ef72afab86d5c38d711c1fa1cb0bd29%2Fcontext-repositories.svg?alt=media" alt="NeoHive reads a GitHub or GitLab repository through a connection, which is a saved token or SSH key. NeoHive stores the code in a Code Index in a searchable form. Your agent finds the code with memory_recall. A sync runs every 4 hours, or when you select Trigger sync, and copies repository changes into the Index."><figcaption></figcaption></figure>

Before you start, you need a Hive and read access to the repository.

To add a repository, do the following:

1. To create a personal access token (PAT) or SSH key for the repository, see [Create a token](/add-your-context/repositories/connect.md#create-a-token).
2. To save the token or key as a connection, select the repository and branch, and create the Index, see [Connect GitHub or GitLab](/add-your-context/repositories/connect.md).

After you create the Index, you can also do the following:

* To keep generated code, fixtures, and other unwanted files out of the Index, see [Choose which files are included](/add-your-context/repositories/file-patterns.md).
* To set the sync schedule, sync on demand, or read the sync history, see [Keep a repository up to date](/add-your-context/repositories/sync.md).

NeoHive copies and indexes the code on the machine it runs on. NeoHive does not send the code to an outside service. For more information, see [What stays on your machine](/security-and-privacy/local-only.md).

{% hint style="info" %}
The first sync reads every file, so on a large repository it can take much longer than later syncs, which read only the files that changed. To make indexing faster, run NeoHive on a GPU. For more information, see [GPU and CPU](/administration/gpu-cpu.md).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.neohive.ai/add-your-context/repositories.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
