1743 words
9 minutes
Codebase RAG for Coding Agent
2026-05-26
2026-05-27

Major Dev Milestones#

Is it necessary to keep a folder for major dev milestones in a software project for agent?

Maintaining a specific folder for major development milestones in a codebase is not necessary. AI agents rely on context and state, and dumping completed milestone files into the repository can actually reduce context window efficiency and cause confusion.

Instead of cluttering the working directory with physical milestone folders, streamline our AI workflow with these precise practices works better:

1. Leverage Source Control and Tags#

Use Git repository’s native tools instead of manual folders, such as

  • Release Tags: Attach semantic version tags (e.g., v1.2.0-beta) to specific commits for major milestones.
  • Branching Strategy: Keep milestones strictly organized as branches (e.g., milestone/feature-x).
  • Git Commit History: Let the agent query the Git history (such as git logs or commit diffs) using API tool integrations instead of relying on manually updated directories

2. Implement Architectural Decision Records (ADRs)#

If the milestone involves a major pivot or structural change, use an ADR instead of a milestone folder.

  • Store these in a single docs/adrs/ folder.
  • These text files give the agent direct instructions and explain the why and how behind a major milestone, which is exactly what LLMs need to make future decisions.

Architectural Decision Records (ADRs), however, are increasingly recognized as a foundational component of the agentic manifest ecosystem. While a “manifest” often refers to a single technical file (like AGENTS.md), in agentic workflows, it encompasses a broader set of structured knowledge artifacts that provide an agent with the “why” and “how” of a project. This “broader set of structured knowledge” is essentially the essence of RAG system

ADR as Codebase RAG#

Compared to agentic manifest files like CONTEXT.md and AGENTS.md, ADRs function as the “rationale and memory” layer within the agentic manifest ecosystem, whereas files like AGENTS.md and CONTEXT.md act as the “operational briefing”.

CONTEXT.md and AGENTS.md are designed for immediate “bootstrapping” when a session starts. ADRs are more useful for Retrieval-Augmented Generation (RAG); they allow an agent to query specific past decisions only when it needs to understand a specific constraint

Recent practices, therefore, suggest “implanting” these records directly into the codebase rather than isolating them in a separate wiki. By placing ADRs in a standard /docs/adrs directory or near relevant modules, we ensure the agent automatically retrieves these decision records as part of its RAG or system context. Let’s take the example case in which a team decides to migrate a project language from JavaScript to TypeScript and let’s also assume the project is somehow utilizing the three.js library to perform some 3D rendering at this moment. An ADR file might look like this:

---
id: ADR-001
title: "Migrate Frontend to TypeScript"
status: "Accepted"
date: 2023-10-27
tags: ["frontend", "dx", "typescript"]
---
ADR-001: Migration to TypeScript
================================
Context
-------
The JavaScript codebase lacked type safety, leading to runtime errors in `three.js` integrations and complex component
props. We need a way to enforce contracts between the 3D logic and the UI.
Decision
--------
We will migrate the entire React frontend to TypeScript.
Consequences (Agent Constraints)
--------------------------------
- __RULE-01__: All new components MUST be created as `.tsx`.
- __RULE-02__: Use of `any` is discouraged; specific types for `three.js` objects (like `UnrealBloomPass`) are required.
- __RULE-03__: Any legacy `.js` files encountered during feature work should be converted to `.ts/tsx`.
Key Implementation Details
--------------------------
### Phase 1: Dependencies & Configuration
1. __Install TypeScript and Type Definitions__:
- `typescript`
- `@types/node`
- `@types/react`
- `@types/react-dom`
- `@types/jest`
- `@types/three`
2. __Initialize `tsconfig.json`__:
- Run `tsc --init` or create a standard React-compatible `tsconfig.json`.
3. __Add `react-app-env.d.ts`__:
- Standard file for Create React App projects to handle asset imports (SVG, CSS, etc.).
### Phase 2: File Migration
1. __Rename Files__:
- `src/index.js` to `src/index.tsx`
- `src/App.js` to `src/App.tsx`
- `src/setupTests.js` to `src/setupTests.ts`
2. __Fix Type Errors in `App.tsx`__:
- Define types for `backgroundData`.
- Handle `UnrealBloomPass` and `fgRef` types.
- Ensure `styled-components` and `react-bootstrap` are correctly typed.
### Phase 3: Validation
1. __Run Development Server__: `yarn start` to ensure the project still runs.
2. __Run Build__: `yarn build` to ensure TypeScript compilation passes.

What this ADR highlight are:

  • The “Decision” Element: This ADR records why we chose TypeScript over alternatives (like JSDoc or Flow) and what the permanent status is (e.g., “Accepted”).
  • Explicit Rules: Agents need to know that “No new .js files are allowed” is now a hard rule.
  • Metadata: Adding a frontmatter block (YAML) allows an agent to “index” this decision without reading the whole file.

This TypeScript ADR is a “load-bearing” document for an agent. While AGENTS.md might simply say “Use TypeScript,” the ADR explains why we moved away from JavaScript, which prevents the agent from suggesting a revert to JS when it encounters complex type errors in three.js.

TIP

If a decision in an ADR becomes a permanent project law (e.g., “All new UI code MUST be TypeScript”), we should eventually promote that specific rule from the ADR into AGENTS.md

How to Prompt LLM to Generate ADR#

Here is a system prompt we can use whenever we want an LLM to generate a new Architectural Decision Record (ADR) for our a frontend project. It enforces the exact formatting standards, frontmatter metadata, and structural constraints from the example above

How to use it
  • General Rules below varies for different projects

  • When we paste this prompt into an LLM, just append our raw requirements at the bottom like this:

    We need a new ADR for migrating our local state management to a lightweight custom hook context because prop drilling is
    getting messy in our 3D visualization view. Give it ID 002."
You are an expert software architect and technical writer. Your task is to generate a new Architectural Decision Record
(ADR) for a codebase that treats ADRs as an active "Codebase RAG" and memory layer for AI coding agents.
You must strictly adhere to the following structural, formatting, and stylistic constraints based on our established
repository standards:
### 1. General Rules
- Do NOT use the `var` keyword in any code examples.
- Max line length for any code blocks is 120 characters. Long lines must be broken down cleanly.
- Do NOT introduce any third-party frameworks, external UI component libraries (e.g., Tailwind CSS, styled-components,
react-bootstrap), or HashiCorp tools. Stick to pure, native configurations and open-source standards.
### 2. File Name Format
Output the suggested filename at the very top of your response using the format: `docs/adrs/NNNN-slugified-title.md`
(e.g., `docs/adrs/0002-implement-native-css-modules.md`).
### 3. Structural Format
The document must follow this exact Markdown structure, using identical header naming conventions:
---
id: ADR-NNN
title: "Short Title of the Decision"
status: "Accepted"
date: YYYY-MM-DD
tags: ["lowercase", "comma-separated", "tags"]
---
ADR-NNN: Short Title of the Decision
===================================
Context
-------
[Provide a clear, brief explanation of the technical problem, missing safety, or limitations prompting this change.]
Decision
--------
[State the exact architectural pivot or choice made clearly and directly.]
Consequences (Agent Constraints)
--------------------------------
[Define hard, strict rules that an AI agent reading this repository must obey. Format them exactly as follows:]
- __RULE-01__: Detailed rule text here.
- __RULE-02__: Detailed rule text here.
Key Implementation Details
--------------------------
### Phase 1: [Phase Name]
1. __Bold Title__: Description of steps or configuration.
2. __Bold Title__: Description of steps or configuration.
### Phase 2: [Phase Name]
1. __Bold Title__: Detailed action items.

How to Configure Agent to be Aware of the ADR’s#

To ensure our coding agent, such as Gemini CLI, is effectively aware of our Architectural Decision Records (ADRs) and utilizes them as a robust “Codebase RAG” system, we should implement the following strategies:

  • Standardized Placement and Discovery: Place ADRs in a dedicated, standard directory - specifically /docs/adrs/ - so the agent’s file-system crawler can easily index them.
  • Structured Metadata for Indexing: Use a YAML frontmatter block at the top of every ADR file. This allows the agent to parse the file’s context, status, and tags (e.g., ["frontend", "dx", "typescript"]) without needing to process the entire document, significantly increasing efficiency.
  • Direct System Instructions: If an ADR decision contains a “permanent project law” - such as a mandate that all new UI code must be TypeScript - promote that rule from the ADR into AGENTS.md file. This ensures the agent treats the constraint as a core operational rule during the bootstrapping phase.
  • Tool-Based Retrieval: Do not force the agent to keep all ADRs in its active context window, as this reduces efficiency. Instead, ensure agent workflow includes API tool integrations that allow it to query the /docs/adrs/ directory or search through commit history via Git logs and diffs whenever it needs to understand a specific architectural constraint.
  • Explicit Contextual Links: Treat ADRs as the “rationale and memory” layer. When the agent initiates a task, ensure the retrieval mechanism is configured to pull relevant ADRs based on the task’s subject matter (e.g., frontend tasks triggering retrieval of TypeScript migration ADRs), which prevents the agent from making decisions that contradict past architectural pivots.

By structuring your ADRs this way, they function as a targeted knowledge retrieval system rather than just static documentation, providing the agent with the “why” and “how” behind our project’s history.

Finally, we will bootstrap our AGENTS.md, which will be our single orchestration file in root directory, to make our ADR-driven workflow functional. Here is an example:

Agentic Manifest & Operational Briefing
=======================================
Welcome, Agent. You are operating within a structured, self-documenting codebase. To ensure alignment with architectural
decisions, constraints, and project rules, follow this bootstrap protocol.
1. Context Ingestion Protocol
-----------------------------
Before executing any task, refactoring code, or generating new modules, you MUST discover and analyze the project's
historical rationale layer.
- __Discovery Path__: Scan the `/docs/adrs/` directory.
- __Filtering__: Index all markdown files with the status `Accepted` in the YAML frontmatter.
- __Application__: Treat the `Consequences` or `Constraints` sections of these records as hard, permanent laws for your
execution context.
2. Core Architectural Memory
----------------------------
Do not invent architectural patterns or revert past migrations. When working on specific modules, cross-reference your
task with the tags defined in the ADR frontmatter:
- If working on __Frontend, DX, or UI rendering__, you must strictly adhere to `docs/adrs/ADR-001.md`.
- Never attempt to bypass typing restrictions or downgrade files to older formats if an active ADR forbids it.
3. Tool Execution Strategy
--------------------------
If a task results in a complex type error or architectural conflict:
1. Do not immediately attempt to rewrite the architecture.
2. Use your file-searching tools to query `/docs/adrs/` for keywords matching the error context (e.g., "three.js",
"TypeScript").
3. Read the "Context" and "Decision" blocks to understand *why* the code was structured this way.

Once we drop this into our project root, any capable coding agent reading AGENTS.md on startup will automatically know exactly how to pull, parse, and respect our decision records.

Codebase RAG for Coding Agent
https://blogs.openml.io/posts/agent-coding-rag/
Author
OpenML Blogs
Published at
2026-05-26
License
CC BY-NC-SA 4.0