Brownfield Code Surgeon
## The Problem Statement AI coding assistants are great on greenfield projects but not-so-great on brownfield ones — the sprawling, undertested, half-documented codebases.
Core trick
Runs a seven-phase workflow with a subagent and approval gate per phase, using characterization tests before any refactor on legacy code.
Description
## The Problem Statement
AI coding assistants are great on greenfield projects but not-so-great on brownfield ones — the sprawling, undertested, half-documented codebases. Unfortunately, the brownfield code makes up most real software work. AI assistants tend to quietly break things nobody had tests for, in such old codebases.
## The Approach
Brownfield Code Surgeon fixes that with a **seven-phase workflow** — Plan → Map → Break → Cover → Implement → Refactor → Finish.
The roots go back to Michael Feathers' *[Working Effectively with Legacy Code](https://objectmentor.com/resources/articles/WorkingEffectivelyWithLegacyCode.pdf)* (2002) — seams, characterization tests, the whole vocabulary humans have used on legacy code for two decades.
I, along with my colleagues, translated that workflow for agentic use in a [paper](https://doi.org/10.5281/zenodo.19640171) published April 2026.
This repository submission is the paper's productionized form. Each phase has its own subagent, its own approval gate, and a set of forbidden moves the agent can't bypass.
## What's in the Submission?
During the hackathon, I have created a Claude-code-focused package with one backbone, three ways to use it, all writing the same artifacts:
## Why Opus 4.7?
Opus 4.7's 1M context is doing real work here: a single subagent can hold an entire legacy module in view and find seams a human reviewer would skim past. The seven-phase split keeps every decision auditable.
## Proof It Works
PR #33 vs PR #34 on `vivganes/kanbanstr` github repo — same brownfield task, with-surgeon vs without — tighter diffs, real coverage, no forbidden moves. Coverage improved from 0.82% to 19.24%.
## Licensing & CI
Open source under MIT, 90% line coverage enforced in CI.
vivganes/brownfield-code-surgeon★ 01 forksTypeScriptMITCreated Apr 22, 2026 · last push Apr 27, 2026
README excerpt
# Brownfield Code Surgeon A package of tools that productionize the **seven-agent brownfield code-surgery workflow** — Plan, Map, Break, Cover, Implement, Refactor, Finish — from: > Ganesan, Vivek, Kamal Raj Sekar, and Kiran Kashyap. '*Agentic Code Surgery for Brownfield Systems*'. Zenodo, 18 April 2026. https://doi.org/10.5281/zenodo.19640171 Author of this package is the original author of the paper mentioned above. ## Screenshot  ## Motivation AI coding assistants are more helpful in greenfield development than for modifying brownfield code — large, undertested, poorly-maintained systems that make up the majority of professional programming. This package aims to change that. This package `brownfield-code-surgeon` will enable easily working with brownfield repositories using Claude code. ## One backbone, three user interface choices All interfaces read and write the same artifacts and emit the same events. | User Interface | Package | Purpose | Usage Guide | |---|---|---|---| | Claude Code plugin | `packages/plugin` | Native subagents + slash commands + forbidden-moves hooks. | Refer the plugin's [README.md](packages/plugin/README.md) | | CLI based SDK runner (with optional Claude managed runner for final phase) | `packages/sdk-runner` | Local Node CLI driving the pipeline via the Claude Agent SDK. Optionally hands-off the final phase to Claude managed runners | Refer the