# AOCI-CODE

> A Git-versioned, one-line-per-file map of your codebase that coding agents read before they act

- Category: Retrieval & Knowledge (RAG) / Code Indexing & Search
- Language: Go
- Licence: FSL-1.1-MIT (Fair Source, source-available)
- Repository: https://github.com/aoci-spec/aoci-code
- Canonical page: https://ai-tldr.dev/tools/aoci-code/
- Updated: 2026-10-09

## In short

AOCI-CODE keeps a persistent map of a whole codebase that a coding agent reads once at the start of a session instead of re-searching the repository for every task. It sits in the Code Indexing & Search category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Go and licensed FSL-1.1-MIT (Fair Source, source-available).

## Overview

AOCI-CODE keeps a persistent map of a whole codebase that a coding agent reads once at the start of a session instead of re-searching the repository for every task. The map is plain text stored in the repository next to the code and versioned by Git, so when a project changes hands, switches agents or opens a new conversation, one read of the index picks up where the last one left off. It works with MCP hosts such as Codex, Claude Code, Cursor and OpenCode.

The index is written by the agent's own model, one line per file, in a fixed format called FRAS: F is what the file is responsible for, R is what must be read along with it, A is what callers depend on, and S records constraints that cannot be inferred from the code but must not be broken. A compact tag places each file by layer, domain, importance and size. AOCI-CODE itself does not invent meaning from filenames or ASTs; its job is governance — establishing the managed scope and Baseline, validating candidate entries, committing them with locks and atomic writes, and detecting drift between the index and the source.

The project is a single CGO-free Go binary that runs locally: the `aoci` CLI plus a stdio MCP server exposing exactly nine tools. After the first index is built, the MCP server detects code changes and has the agent update the affected entries as it finishes each task. It can also index PostgreSQL, MySQL and (with constraints) openGauss schemas at table level, reading only catalog metadata, with credentials referenced by environment-variable name rather than stored.

## What it does

- Model-authored FRAS entries — Function, Relations, API and non-obvious constraints — one line per managed file
- Index stored as plain-text Cognition Volumes (aoci.txt, aoci.meta.txt, aoci.code.txt, optional aoci.database.txt) that Git can diff, review and roll back
- stdio MCP server with nine tools, including aoci_overview, aoci_search, aoci_maintain and aoci_update_entry
- Drift detection and governance gates via `aoci verify` and `aoci check`, reporting Missing, Orphan, Stale and Unbaselined objects
- Optional Database Cognition for PostgreSQL, MySQL and openGauss 6.0.5, reading only schema metadata and never business rows
- Local read-only panel (`aoci ui`) showing the index verbatim, token budget, compression ratio, drift and running MCP servers
- Host setup via `aoci init --agent` for Codex, Claude Code, OpenCode and Qoder, plus a reference snippet for Cursor

## Getting started

Get a binary from a signed GitHub Release or build it from source, initialize the target repository, then ask your agent to build the index through the MCP tools.

1. Download a release or build from source

   Release packages are on the GitHub Releases page; verify them with the project's installation guide. To build from source you need the Go toolchain declared in go.mod and make.

```bash
git clone https://github.com/aoci-spec/aoci-code.git
cd aoci-code
mkdir -p build
make build
./build/aoci --version
```

2. Initialize the target repository

   From the root of the project you want indexed, point at the binary by a stable absolute path. `init` writes the locale configuration, the managed AGENTS.md rules block, Git boundaries, an empty index skeleton and the host's MCP configuration; `scan` establishes the managed Baseline. Do not add the index files init writes to .gitignore — scan takes its inventory from Git.

```bash
AOCI=/absolute/path/to/aoci-code/build/aoci
"$AOCI" --repo . init --locale en-US --agent codex
"$AOCI" --repo . scan
```

3. Restart the agent and ask it to build the index

   Restart the host so it loads the newly written MCP server, then send this instruction. The agent reads every managed file and writes one entry per file; the README estimates about an hour per 200,000 lines, resumable if interrupted.

```text
First confirm the AOCI MCP server is connected, then build the AOCI index for this project. When it is complete, give me the AOCI panel link.
```

4. Verify alignment and open the panel

   The index and the managed source should converge to `aligned`. The read-only panel binds to loopback only.

```bash
"$AOCI" --repo . verify
"$AOCI" --repo . check
"$AOCI" ui --open
```

## When to use it

- Hand an existing codebase of hundreds of thousands of lines to a coding agent and have it start each task already knowing what every file is for
- Keep system knowledge across agents, sessions and team members by versioning the index in Git alongside the code
- Give an agent table-level knowledge of a PostgreSQL or MySQL schema together with the code that uses it
- Pair with a code graph tool such as CodeGraph: the index for the whole-system picture, the graph for exact source and call paths

## Version history

- 2026-10-09 v0.1.0-rc20: Release candidate adding an E scale audit to verify and check, reporting git submodules as boundaries, and root-anchored exclude_root_dirs for new repositories, built with Go 1.26.9.
