Pattern 10: Code Archaeology
Use AI to X-Ray Legacy Code and Reconstruct Lost Knowledge
Overview
This pattern helps you dig meaning from codebases everyone fears to touch. When docs are missing and authors are gone, AI becomes your guide.
Use this pattern when:
- You inherit a black-box monolith—no tests, no README, no survivors
- Business rules hide under years of patches
- A rewrite needs preserving hidden behavior
- You need to know what happens if you change something
AI excels at tracing execution, spotting patterns, and turning spaghetti code into readable maps.
Key Principles
- Follow the data – Watch values, not variables
- Map dependencies – Track who calls whom and what breaks
- Spot patterns – Naming quirks reveal conventions
- Write it down – Push insights to repo, not wikis
Exercise
TBD
Your Turn
Pick legacy code you’ve avoided:
- 2012 Asteroids clone in 1,400 lines—map game loop, collisions, scoring
- WordPress plugin with mystery AJAX—diagram one save_post action
- React 0.13 dashboard—draw prop tree, flag old lifecycle methods
Rule: Create the documentation file you wish had existed when you started. AI has read the code—now make it speak.