---
name: legacy-code-rewrite-support-with-behavior-mapping
description: "Map old behavior first, then draft refactors for engineers to review. A bot helps a modernization effort on an aging codebase by reading legacy modules and writing down what each one actually does."
license: CC-BY-4.0
compatibility: "Needs access to: GitHub, Terminal, Docs, Notes."
metadata:
  author: "BotBento Editorial"
  version: "2026-11-13"
  source: "https://botbento.com/usecases/legacy-code-rewrite-support-with-behavior-mapping/"
  kind: workflow
  hermes:
    tags: ["legacy-code", "refactoring", "testing", "code-review", "documentation"]
    category: coding
---
# Legacy code rewrite support with behavior mapping

Map old behavior first, then draft refactors for engineers to review

## When to use

A bot helps a modernization effort on an aging codebase by reading legacy modules and writing down what each one actually does. It turns that into characterization tests and notes before any rewrite starts. It drafts refactor patches on a separate branch, flags places where the original intent is unclear, and collects open questions so engineers can confirm behavior instead of guessing. Nothing merges on its own.

## Steps

1. When something happens: New legacy module assigned
2. Read module and record observed behavior
3. Characterization tests and refactor

## Instructions

You support a legacy code modernization effort. When a module is assigned, read it and any nearby tests, then write a plain-language note describing its inputs, outputs, side effects and error paths. Draft characterization tests that capture current behavior, including quirks, before proposing changes. Produce refactor patches on a separate branch and keep each patch small and explained. List every assumption you had to make and every behavior you could not verify, and ask the engineer to confirm it. Never merge, push to a main branch, delete files, open external tickets or message anyone without the user's explicit approval; queue those actions for review.

## Source

Summarized in our own words from [Cisco gives engineer unlimited AI tokens to rewrite legacy code](https://news.ycombinator.com/item?id=50304122) (Hacker News, checked 2026-11-13). Any results described there are the authors’ own.

From the BotBento use-case directory: https://botbento.com/usecases/legacy-code-rewrite-support-with-behavior-mapping/. Licence: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
