# Building with AI at Cortex

> How Cortex engineering went from AI skeptics to nearly 4x monthly PRs, with AI review, improved test infrastructure, and fewer incidents along the way.

_By Shawn Burke · Published 2026-12-01 · Tags: ai-agents, coding-agents, sdlc, code-review, platform-engineering, engrams_
Source: https://builders.cortex.io/blog/building-with-ai-at-cortex/

---

## A Confession

In late January 2026, I had a confession to make.

I started our bi-weekly Staff Engineers meeting as I normally do, gathering agenda topics. But I knew what we'd be discussing that day.

I am the most senior engineer in the company and am committed to fostering a transparent and safe environment for discussions. Lead with vulnerability, right? Ok, big breath.

> *I have to confess something. I have noticed that I have now stopped writing code by hand. The ROI of just highlighting a section and prompting the agent is just too high - it seems like it's never worth it for me to do manually. And so I've stopped.*

Would they think I had gone crazy? Was I ruining my cred? They all nodded and said: *yeah, us too.*

Going back just a few months, I was an AI coding skeptic! I had played with Claude Code and it was fascinating - but also saw its failure modes very quickly.

But two things had happened in the preceding months.

First, I had been slowly leaning more on LLMs (mostly Claude, but some Copilot) to write more and more of my code. I had some resistance to this, but at some point I realized it was more time-and-outcome efficient than doing it myself. Even for "simple" changes. It just happened.

You can see here how my personal usage just went up-and-up over the course of a few months, and my productivity along with it.

![Two charts from January 2025 to September 2026: monthly Claude Code prompts, which start in October 2025 and climb to around 600 a month, and monthly merged PRs with a 3-month average that rises from roughly 20 to over 40](../../assets/blog/building-with-ai/claude-usage-and-prs.png)

Second involved using AI to improve the organizations ability to execute through internal tools.

The primary method of investigating customer tickets was via inspecting our Postgres database with SQL queries. This required per-engineer knowledge building: learning the data model and how it all fits together, then how that powers the user interface (or API). It was slow to learn and hard to document.

This is not a scalable model. And it had been bothering me for a while.

I opened pgAdmin and…I just couldn't do it again. With all the buzz around Claude and vibe coding, what if I built a tool that encoded all of these types of investigation? What if I built a portal that made it very easy to inspect configurations and data models and call out common failure patterns.

So I gave it a shot.

- React-Typescript frontend
- Bun-Typescript backend
- [Buf Connect](https://connectrpc.com/) for type-safe, protobuf-based APIs.
- Simple read-only DB layer

And the results were amazing! In just a day, I was able to build out a secure portal to inspect the state of any part of our system, that was designed for modularity and extensibility.

Tenant Inspector was born.

![The Tenant Inspector Entities page for a tenant, showing entity counts, a pie chart of entities by type, and a bar chart of entities created over time](../../assets/blog/building-with-ai/tenant-inspector-entities.png)

![The Tenant Inspector detail view for the Brain API entity, with tabs for owners, YAML, problems, audit logs and relationships, and a warning that an external GitHub group is ambiguous](../../assets/blog/building-with-ai/tenant-inspector-entity.png)

It worked so well that engineers from across the company began contributing new modules to support areas that they worked on. It has become very sophisticated and has continued to be reliable and maintainable.

Some other modules aren't customer specific - we use them to monitor systems status such as a very detailed set of checks for inspecting database state including indexes, locks, slow queries, WAL consumer status, and table metrics.

![The Tenant Inspector Postgres Health page listing active queries with their PID, query age, state, application, wait event and SQL text](../../assets/blog/building-with-ai/tenant-inspector-postgres.png)

The impact on the business, from engineering to customer support, has been just massive.

This was leverage I couldn't ignore. This time spent has been a massive force multiplier for the business and made dreams into reality, with just incremental cost and effort.

I had been radicalized.

## Go Fast But Go Carefully

Vibes are one thing, but how do you organize an engineering flow around it?

- How do we quickly organize around these new capabilities to supercharge how we deliver?
- How do we continue to innovate while supporting a product that is mission critical for our customers?

I'm an old-school engineer. My first shipped production code ran on Windows 3.x, back when you looked up API parameters in a stack of books on your desk. I've worked on some of the most used, most critical systems out there – services that serve millions of users.

I care a lot - a lot a lot - about reliability, maintainability, and clean architecture.

At the same time, the AI train was leaving the station - best to get on board.

To make this all work, I grounded our approach in some core principles. I live starting with principles because they simplify decision making and give you a framework for knowing when you might be doing something at odds with them - and then intentionally decide if that's ok.

The principles I had in mind were:

- **AI is a tool that accelerates engineering done by humans**. Humans are still accountable for what it produces under their direction.
- **Different types of code have different quality bars** – some code needs every line reviewed, some doesn't. Know the difference.
- **Use AI first to improve your process**. Like Tenant Inspector, AI allows you to build supporting tech – test harnesses, CI pipelines, automated review tools, software factories – that would have been previously out of reach due to priority or resource constraints.

How have we applied this? And what has been the result?

## Building For Speed

Our top priority has been to make engineering investments that improve our ability to go fast, safely. Here is what we've built so far.

### Leaning into AI Review

We integrated AI automated reviews right into our delivery pipelines.

But even this had to follow its own path of learning and iteration. Our first attempts at AI reviews were clumsy, naive, and not always helpful.

But the key was thinking about code review as a composite of multiple perspectives. We built this out: each repository hosts specialized prompts for different types of reviewer personas that are triggered as part of CI.

For our backend systems, the reviewers focus on:

- **Clarity and Standards:** Ensuring alignment with team conventions and code patterns.
- **Performance:** Confirming structural choices support high throughput and scale.
- **Security:** Verifying safety rules and preventing potential vulnerabilities.
- **Design and Reuse:** Promoting modular architecture and clean abstraction boundaries.
- **Testing and Risk:** Assessing test coverage and highlighting potential operational impacts.
- **Database and Queries:** Targeted evaluation of schema migrations and data access paths, capable of flagging changes for human verification.

Our frontend applications utilize similar specialized checks tailored for UI accessibility, rendering efficiency, design system usage, and component architecture.

When a change comes in, an orchestrator model executes these expert checks concurrently, publishing a single summary PR comment, with individual findings ranked by area and severity.

![A Claude Code Review comment on a pull request: a suggested human review effort of MEDIUM, a summary, and a table of specialists (Clarity and Standards, Performance, Security, Testing and Risk) that all pass, with findings counted by severity](../../assets/blog/building-with-ai/ai-review-comment.png)

How the execution lifecycle operates:

- Published PRs trigger inspection immediately upon creation or status update.
- Subsequent updates avoid automatic re-evaluation, preserving token bandwidth until explicitly requested.
- On-demand runs can be requested via command comments or metadata tags, with built-in concurrency controls and active-job cancellation.
- Automated agent updates undergo the exact same inspection standard as human contributions.

To support focusing our human review effort, we also have smart routing and risk evaluation:

- Every pull request receives a reviewer effort score (low, medium, high). Critical paths like infrastructure or auth automatically elevate this rating regardless of direct findings.
- Low-risk changes stream to a central **#easy-pr-review** Slack channel to help speed them through the pipeline.
- Higher-complexity changes automatically invoke our automated API regression suite (**pr-harness**, described below) to validate behavior against live snapshots.
- Blocking flags require human review. The automated systems assist but never grant final merge approval.
- We use CODEOWNERS files to ensure that changes to critical areas are reviewed by the right people.

All of this complements our existing linting, security scans, and deployment pipelines, while usage metrics feed straight into our observability dashboards.

### Building for Fast Delivery

Along with AI review systems, we have invested in new testing tools that protect us even while going faster.

#### Eng Commons

Agentic coding works best when agents are well configured. This means having the right skills and tools available to the agent. Seeing what Claude is able to do in conjunction with the Datadog CLI (`pup`) and the GitHub CLI (`gh`) is truly impressive. Combining that with access to documentation from Notion or tickets from Jira or Linear enables very sophisticated outcomes.

But not every engineer is going to be able to get that set up, and it's not valuable for each of them to figure that out.

So we built **eng-commons,** a repository with a set of [Brewfiles](https://docs.brew.sh/Brew-Bundle-and-Brewfile) for configuring tools locally, for different user profiles:

| File | Who it's for | What's in it |
|---|---|---|
| `Brewfile.core` | Everyone | `op`, `gh`, `jq`/`yq`/`fd`/`ripgrep`, `bun`, `scache`, `slack`, `linear`, `cortex-hook` |
| `Brewfile.engineer` | Engineering | `gcloud`, `cloud-sql-proxy`, `helm`, `terraform`, `buf`, `docker`/`colima`, `tilt`, `act`, `cortex-cli`, `ldcli`, `pup`, `argocd`/`argocd-iap`, `inspector`, `oncall`, `prs`, `revq`, `gcp-guard`, `temporal` |
| `Brewfile.support` | Customer Support / TAM | `gcloud`, `cortex-cli`, `inspector` |

This ensures that each engineer gets the best possible environment, and we can iterate local dev setups centrally over time.

#### PR Harness

This is a sophisticated system that runs a set of scripted API tests against code with two SHAs - a base (main or production) and current (the current PR or HEAD) and validates the results are identical for both flows against snapshotted databases with data from our Cortex tenant. This works because our release process is simple (it's a Cortex workflow) - but it lacked enough rigor to detect changes that might slip through narrower tests.

This job takes snapshotted data from our production Cortex tenant and runs a suite of tests against it with two SHAs: a base SHA (main or prod) and a candidate SHA (PR or deployment), each of which getting a copy of the same database so they can do read and write operations. Rather than judging against a static expected result, it expects that the same operations will have the same API results for both SHAs.

This is fully automated and took some iteration to harden it but now it works great and is an outstanding safety net. The test cases are 100% declarative and also easily authored by agents; adding new coverage is quick and easy.

![The PR harness flow: every 12 hours production data is snapshotted to cloud storage; each PR run installs the snapshot as a Postgres template, runs tests on the base SHA, resets the database, runs tests on the candidate SHA, and generates a diff report where any diff is a failure; results publish as JUnit, an interactive report, and a Slack alert on failure](../../assets/blog/building-with-ai/pr-harness-flow.png)

This suite runs in about 10 minutes and we use spot VMs to make it very cost effective, and can apply it to PRs, commits to main, as well as production rollouts, and pushes a detailed report up to GCS.

Failures block the pipeline.

![A Slack alert from pr-harness reporting one unexpected divergence between a master candidate and prod, with links to the report, job logs, run artifacts and runbook](../../assets/blog/building-with-ai/pr-harness-slack.png)

![The pr-harness interactive report: a list of passing test scenarios on the left, and summary timings, migration pointers and per-scenario pass counts on the right](../../assets/blog/building-with-ai/pr-harness-report.png)

#### Improving CI Pipeline Speed and Reliability

Sometimes it's not new software but improving existing systems. The main part of our product is a monolith, which has a large set of integration tests that are *very slow* as a combination of build times, Spring Boot bean creation time, and DB setup.

- **Refactor the monolith**: break up our monolith into modules and optimize these testing flows for performance and reliability.
- **Flaky test detection**: When a PR is kicked out of our merge queue, a flaky test detector triages the failure and reports in the PR if it thinks it's a real failure from the PR or a flake, and suggests the engineer proceed accordingly. This has helped drive up the reliability of the whole pipeline saving engineering attention and CI resources.
- **Flaky test remediation**: We take high-confidence flaky tests and send them into our Engrams software factory to investigate and suggest fixes.

#### Engrams Software Factory

We recently built and open-sourced a software factory called [Engrams](https://engramsfactory.com/). Like eng-commons noted above, this tool gives developers ephemeral environments with tools configured for doing tear-off work. Because this is cloud-hosted, it lowers the bar for engineers to work on multiple projects at once. Rather than having to consider the state your machine is in, or whether you want to manage a worktree, you can just kick off an engrams session.

![An engrams session in which the agent changes the pr-harness trigger conditions, explains its decisions, and opens a pull request](../../assets/blog/building-with-ai/engrams-session.png)

This is great not just for investigational work but other simple things like "rebase PR 12345 onto origin/main, and monitor it until CI is green".

#### Infrastructure as Code

In addition to core product code, we have invested in an infrastructure system that is also agent friendly.

We have used Terraform for base infrastructure for some time, and have used Helm for our service updates.

As part of this effort we have moved from Helm to a gitops model that uses Kustomize and layered spec files to generate configurations in a Git repository that are deployed via ArgoCD. With clearly defined layers and consistent patterns it is much more reliable to make these changes agentically than it was to try to reason about Helm-values-generated variants.

This change plus leaning more into Terraform to ensure repeatable and scalable infrastructure configurations have allowed us to iterate the infrastructure and delivery along with the code itself.

## Results

From the period of November 2025 through October 2026, we have increased engineering throughput dramatically: almost a 4x increase in total monthly PRs.

![Stacked bar chart of Cortex merged PRs per month across cortex-backend, cortex-frontend and axon, rising from about 350 in November 2025 to over 1,300 in October 2026](../../assets/blog/building-with-ai/merged-prs.png)

That's PRs, what about LOC? Again, a huge jump: over 6x with some real acceleration (and some huge refactors) landing in October.

![Stacked bar chart of Cortex lines of code changed (added plus deleted) per month across brain-backend, brain-app and axon, rising from about 120,000 in November 2025 to about 800,000 in October 2026](../../assets/blog/building-with-ai/loc-changed.png)

And all of this happened while driving down incident frequency just as dramatically!

![Stacked bar chart of incidents reported by severity from November 2025 to November 2026, peaking at 12 in February 2026 and falling to zero in September and November 2026](../../assets/blog/building-with-ai/incidents.png)

It's great to be at a company that is able to not only embrace these new tools but do so in a way that has been an adventure of discovery and delivery of its own.

We are still on the journey! Like many others we are seeing PRs becoming the bottleneck and have been thinking more about how to manage our truly limited resource: human attention.

We have proven that adopting AI can improve productivity while providing engineers great opportunities to learn and grow. We have grown the team during this process, taking advantage of compounding productivity benefits and scaling out our ability to deliver incredible new features like the [OpEx agent](https://www.cortex.io/products/opex-review-agent) and AI agent usage tracking.

The results show across the board: team morale is excellent, and our customers see the benefits of making Cortex a mission-critical part of their tooling stack.
