Skip to content
Gopi Krishna Tummala
Esc

Back
Intermediate Agentic AI 12 min read

Making a Large Codebase Agentic: Build an Agent-Operable Repository, Not an Agent Framework

By Gopi Krishna Tummala

The harness isn’t only the agent’s runtime. Most of it is your repository: the context, procedures, commands and feedback loops an agent needs to do engineering work in a codebase it has never seen.

Part of the agent harness series, in the agentic AI series.


You join a team that maintains an inference platform: around 500,000 lines across a request gateway, a model-execution service, a GPU scheduler and a handful of shared libraries, in three languages, with tests scattered through every module. Everyone on the team uses a coding agent daily.

You open the repository, start the agent, and ask for the feature at the top of your list: streaming responses, so clients get tokens as they are produced instead of waiting for a complete reply.

The agent searches, finds the response handler, adds a streaming path, writes a test, runs it, and reports success. The change also breaks the gateway’s response contract, which a second service parses, and the integration test that would have caught it sits in a directory the agent never ran.

So you try again with more instructions. The second attempt is better. But by the third feature you notice what you are actually doing: re-explaining the same architecture, the same test commands and the same compatibility rules every session, to an agent that starts each one knowing none of it.

The model is not the bottleneck here.

The repository was built for humans who already have that context in their heads. What makes an agent effective is an environment that supplies it: where things live, how to perform the recurring procedures, which operations are available, and how to find out whether a change is actually correct. Part 1 looked at harnesses as runtimes — the loop, tools, context and permissions that ship with Claude Code or Copilot. This post is about the half of the harness that you own, in your own repository, and what to build in which order.

The rule underneath all of it: don’t start by building an agent framework; start by making the repository operable by an agent. Add orchestration later, only where a workflow needs control that a chat session can’t give it.

The idea in one picture

flowchart TB
  R["Agent runtime<br/>Claude Code, Copilot, your own loop"]
  subgraph REPO["What you build in the repository"]
    direction TB
    C["Context<br/>AGENTS.md, architecture docs"]
    K["Procedures<br/>skills with bundled scripts"]
    X["Capabilities<br/>scripts, make targets, MCP servers"]
    O["Orchestration<br/>subagents, test-and-repair loop"]
    E["Evaluation<br/>one validation command, hooks, CI"]
    M["Engineering knowledge<br/>decisions, recurring failures"]
  end
  R --> C --> K --> X --> O --> E --> M
  M -. "next task starts better" .-> C

Six layers, each answering a different question. The arrow back from knowledge to context is the part most teams skip, and it’s what makes the repository get easier for agents over time rather than staying the same.

A useful way to decide where something belongs:

  • Always needed to work here: repository instructions.
  • Needed for one kind of task: a skill.
  • An operation to perform: a script, a make target, a tool.
  • Multiple steps to coordinate: a workflow.
  • Something checkable: an evaluator.
  • A lesson that should outlive the session: maintained knowledge, or better, a test.

That list is also roughly the build order.

Make the repository findable before anything else

An agent’s first twenty minutes in a large repository go to guessing: which directory holds the gateway, whether tests run with pytest or a make target, whether libs/protocol is generated. None of that guessing produces value, and some of it produces confident mistakes.

Write it down once, in an instruction file the agent reads automatically. Claude Code reads CLAUDE.md, Copilot reads .github/copilot-instructions.md, and AGENTS.md has become the cross-tool convention; the practical setup is one AGENTS.md holding the real content, with small tool-specific files pointing at it.

What belongs there is an operational map, not a tutorial: what the system does in two lines, which directory owns what, the exact bootstrap, build, test and lint commands, and the rules that are expensive to violate. For our platform, the rules that matter are the ones the streaming change broke: public API responses are a contract parsed by other services, libs/protocol is generated and never hand-edited, and any behavior change that crosses a service boundary needs an integration test.

One file cannot carry thirty services. Put the overall map at the root and the local conventions next to the code:

AGENTS.md                      architecture map, commands, global rules
services/AGENTS.md             conventions shared by all services
services/gateway/AGENTS.md     the response contract, streaming constraints
services/inference/AGENTS.md   model lifecycle, GPU memory, batching
docs/architecture/*.md         the long explanations, linked not inlined

An agent working in services/gateway then sees the two files that matter instead of a 4,000-line document about everything. The root file’s job is mostly to say where authoritative information lives, so the agent can load it when the task needs it. That’s the just-in-time loading pattern from Part 2 of the design-patterns series, applied to documentation you write rather than files the agent searches.

The honest limit: instruction files rot, and a confidently wrong one is worse than none at all, because the agent trusts it over the code. Keep them short enough to stay true, and treat a stale line in AGENTS.md as a bug in the repository.

Turn your repeated procedures into skills

Some tasks come back every month: adding an endpoint, onboarding a new model architecture, chasing a flaky integration test, profiling a latency regression, cutting a release. Each has a correct order of operations that senior engineers know and nobody has written down.

A skill is that procedure, packaged so an agent can discover it when relevant and load it only then — a runbook written for an agent instead of a new hire. The portable shape is a directory with a SKILL.md, reference documents and, most importantly, scripts:

skills/add-streaming-endpoint/
  SKILL.md                 objective, workflow, constraints, validation
  references/
    response-contract.md   what clients parse, what may change
  scripts/
    check_contract.py      diffs the response schema against the committed one

Ours lists the steps in order — read the contract, add the streaming path behind a capability flag, keep the non-streaming response byte-identical, add a unit test, add a cross-service integration test — then names the constraints and ends with the commands that prove it worked. The scripts are the part that changes outcomes: check_contract.py turns “don’t break the gateway’s response contract” from a sentence the agent may or may not honor into a check that fails.

Start with five to eight, for the workflows your team genuinely repeats, not fifty on the first day. A skill earns its place when a procedure has several steps and requires knowledge that isn’t obvious from the code.

The limit is documentation’s, slightly worse: a skill that restates logic also living in code will drift from it. Prefer skills that point at the code and run the checks over skills that paraphrase it.

Give the agent one command that tells it the truth

Here is the asymmetry that matters most. An agent can write code, and it can also report that the code works. Those are different claims, and only one of them is cheap to verify.

The evaluator has to be more trustworthy than the agent’s claim of success. Everything else in this post is support; this is the load-bearing part.

In practice that means one command, committed in the repository, that runs the real checks in a fixed order:

# scripts/agent/validate.sh — illustrative
set -euo pipefail
make format-check
make lint
make test-unit
make test-affected   # integration tests for modules the diff touches

Now the agent runs a known sequence instead of inventing a plausible one, and so do you, and so does CI. For a 500,000-line repository the interesting part is test-affected: map changed files to modules, modules to dependent services, services to their suites. Our streaming change touches the gateway’s response path, which services/billing parses, so its integration tests are in scope whether or not the agent thought to look there. Full CI stays the authority before merge; the local command only has to be fast enough to run every few minutes and honest enough to be worth running.

Two mechanisms make the rules hold instead of merely existing. Hooks run deterministic actions at lifecycle points — format after every file edit, rather than asking the agent to remember. Permissions and CI block what must not happen: an edit to a generated file under libs/protocol should be refused by configuration, not discouraged by a paragraph. My division of labor:

RequirementWhere it belongs
Explain the architecture and commandsInstruction files
Follow a multi-step procedure correctlySkill, with scripts
Format and lint changed codeHook
Never touch generated filesPermissions, enforced
Decide whether the change is correctValidation command, then CI
Approve a risky changeA human gate in the workflow

Anything you care about enforcing should move down that table, from prose toward execution.

Split roles only where the work is isolated

With context, procedures and a trustworthy evaluator in place, specialization starts to pay. The clearest win is review, because an agent that just wrote an implementation is the worst judge of it: it will re-derive the same assumptions that produced the bug.

So give review its own agent, with its own context, and make it read-only:

---
name: reviewer
description: Review a diff for correctness, compatibility and regressions.
---

You are a read-only reviewer. Inspect the git diff only; do not modify files.

Check, in this order: correctness and edge cases; compatibility of any
public response or interface; concurrency and resource handling; error
paths; missing tests. Report severity, file and line, why it is wrong,
and the suggested correction. Do not report style preferences as defects.

The same logic applies to investigation. Three independent services, two candidate designs, four unrelated test failures: those parallelize cleanly because nothing is being written, and reviewing security and performance separately gives better findings than asking one agent to hold both lenses at once.

Where it stops working is writes. Two agents editing the same files cost more in conflict resolution than they save in wall-clock time. Keep ownership of source changes in one place, and add agents only for work that reads.

Close the loop, and know when it has to leave the chat

A coding agent already runs a loop: observe, act, observe the result, continue. What it doesn’t have is a lifecycle for a software change, with explicit state about what has been tried.

flowchart TB
  REQ["Feature request<br/>streaming responses"] --> PLAN["Plan<br/>files, contracts, risks"]
  PLAN --> APPROVE{"Human approval<br/>if risky"}
  APPROVE --> IMPL["Implement<br/>following the skill"]
  IMPL --> VAL["validate.sh<br/>lint, unit, affected tests"]
  VAL --> Q{"Pass?"}
  Q -- "yes" --> REV["Read-only review<br/>of the diff"]
  Q -- "no, attempt < 3" --> FIX["Repair<br/>with the actual failure output"]
  FIX --> VAL
  Q -- "no, attempt = 3" --> STOP["Stop and report<br/>what failed and where"]
  REV --> DONE["Report: changes, evidence,<br/>what was not run"]

The bounded repair loop is the whole point. Without a retry cap an agent will keep editing until the tests pass by coincidence; with one, a third failure becomes information for a human instead of more churn.

The loop needs real state: the objective, the plan, the changed files, the last test output, the review findings, the attempt count, and the status. Without it, a long session loses track of which stage failed and starts solving a problem it already solved.

Should this be LangGraph or an equivalent orchestrator? Not at first. If people are working interactively, the coding agent already supplies the runtime, the tools, the context management and the loop, and rebuilding that in a graph buys nothing. Native skills, subagents, hooks, shell scripts and CI get you surprisingly far.

An explicit orchestrator earns its place when the workflow has to outlive a session: running a pipeline overnight, coordinating work across repositories, persisting state so an interrupted run resumes instead of restarting, routing on test results, pausing for approval before something sensitive. Those are properties of a long-lived workflow, not of a conversation.

One thing the pipeline should not do is commit or merge on its own. Produce the change, the evidence and the report; leave the decision behind a human gate or repository policy.

The report matters more than it sounds. The useful shape separates what was verified from what wasn’t:

Task: streaming responses in the gateway

Modified:  services/gateway/stream.py, services/gateway/handlers.py,
           tests/gateway/test_stream.py, tests/integration/test_billing_parse.py
Validated: lint PASS, unit PASS, affected integration PASS
Review:    no blocking findings
Not run:   GPU throughput benchmark (no GPU in this environment)

An agent that reports a benchmark it never executed has broken the only thing that made the rest of the system worth trusting.

Turn recurring failures into guardrails

Now the part that decides whether any of this compounds. Your agent makes a mistake. You correct it. Next week, in a fresh session, it makes the same mistake, because nothing in the repository changed.

A small amount of maintained engineering knowledge helps: the architectural decisions and their reasons, and the recurring failures with their symptom, root cause and correct approach. Our platform has one worth writing down — model registration goes through the explicit registry, because dynamic module discovery made initialization order unpredictable — and that single entry prevents a class of import-time bugs that otherwise gets rediscovered every few months.

But don’t let agents append every observation to a permanent instruction file. That produces a growing pile of stale, contradictory, low-value text that fills context and misleads. Put a filter in front of it:

flowchart LR
  F["Agent failure"] --> RC["Root cause"]
  RC --> Q{"Repeatable?"}
  Q -- "no" --> DROP["Drop it"]
  Q -- "yes" --> P{"Can it be prevented<br/>by something executable?"}
  P -- "yes" --> G["Add a test, hook,<br/>permission or skill script"]
  P -- "no" --> D["One entry in the<br/>knowledge file"]
  G --> H["Human review"]
  D --> H

Prefer the left branch. A regression test or a hook prevents the failure; a paragraph only hopes to.

The streaming regression is a good example of the preference. The lesson isn’t “remember that billing parses gateway responses.” It’s check_contract.py in the skill, plus the integration test in test-affected, so the next agent that touches that path gets a red check instead of a warning it might skim past.

What I’d build first

Three stages, in this order, each useful on its own:

Week one: make the repository understandable. A root AGENTS.md with the real commands, module-level files for the two or three services that see the most change, architecture docs linked rather than inlined, and one validate.sh that runs lint and tests honestly. Most of the pain in the opening story comes from this layer being missing.

Month one: make recurring work repeatable. Five to eight skills with scripts bundled so validation is executable, a read-only reviewer and explorer, and dependency-aware test selection so the fast local check covers the right suites. Then measure: run five representative tasks and see what happens.

After that: add control where it’s missing. A bounded test-and-repair loop with a retry cap, explicit task state, a human approval gate for risky changes, CI as the authority, and a reviewed path from recurring failures into tests and hooks. Introduce a separate orchestrator only when you need a workflow that survives a closed laptop.

Measure the outcome, not the artifact count. Fifty skills is not progress. These are the numbers I’d watch:

SignalWhat it tells you
First-pass validation successHow often the first implementation is actually correct
Repair iterations per taskHow much rework the harness is absorbing
Human intervention rateWhether people still have to take over mid-task
Regression rateWhether changes are breaking behavior the tests missed
Cost and latency per completed taskWhether the orchestration is paying for itself

That last row is a real constraint. A pipeline that spends five agents and a hundred model calls on a rename is not better than one agent running a good test suite. The goal isn’t maximum autonomy; it’s reliable autonomy at a cost that makes sense.

What I’d remember

  • Build an agent-operable repository before an agent framework. Context, procedures and a trustworthy validation command beat orchestration you added early.
  • Layer the instructions. A root map plus module-level files, with the long explanations linked, not inlined.
  • Skills are procedures; agents are workers. A skill is a runbook with scripts that an agent loads when relevant. An agent is a separate worker with its own context and responsibility. They solve different problems.
  • Make validation executable. Prose asks; hooks, permissions, tests and CI enforce. Move anything you care about from the first column to the second.
  • Bound the repair loop and report honestly. A retry cap turns a third failure into information, and an agent must never report a check it didn’t run.
  • Feed failures back as guardrails, not paragraphs. A regression test prevents the mistake; another line in an instruction file only hopes to.

A well-engineered repository shouldn’t need you to re-explain how to build, test, debug and review the same system in every conversation. The aim isn’t an AI that writes code. It’s a codebase that knows how to be worked on by one.

Where to go next

Questions to sit with

  1. In your repository, how long does an agent spend guessing before it does anything useful, and which file would remove most of that?
  2. Which of your engineering rules are currently paragraphs that should be tests, hooks or permissions?
  3. The last mistake your agent repeated twice: what executable check would have caught it the second time?