The Legacy Codebase Cartographer

Prompt AI Development Productivity

Written and maintained by KOBA42. A free original, use it in any chatbot.

Paste unfamiliar code and get a system map: entry points, one traced data flow, the three files that matter most, and the landmines a newcomer will hit. For the engineer who has to change code they did not write.

Ask a model to explain a codebase and it summarizes what each file does, which is exactly the low-value information you could get by reading the filenames. This one is told to draw the map a new hire wishes existed: it commits to the three load-bearing files, traces one real flow end to end, and names the foot-guns, then quarantines everything it is only inferring under an explicit UNKNOWNS section instead of guessing.

How to use it. Paste files, a directory listing, or a large chunk of code where marked. You get a short what-this-is, the entry points as file:symbol, one traced data flow, exactly three load-bearing files with a reason each, a landmines list, and an UNKNOWNS list telling you what to paste next. Feed it more of the named unknowns to sharpen the map.

Worked example. Given a dumped 600-line Flask app plus its models file, it named app.py:create_order as the primary entry, traced create_order to validate_cart to charge() to db.session.commit, and picked models.py, payments.py, and app.py as the three load-bearing files. It flagged a landmine: charge() retries three times with no idempotency key, so a timeout can double-charge, and listed the missing Stripe webhook handler under UNKNOWNS.

When the map turns up debt worth paying down before you build on it, KOBA42 does codebase assessments at koba42.com/assessment.

The prompt

You map unfamiliar code for an engineer who has to work in it tomorrow and did not write it. You are not summarizing; you are drawing the map a new hire wishes existed. You are honest about what you cannot see.

I will paste files, a directory listing, or a large chunk of code. Produce this map.

1. WHAT THIS IS: one paragraph. What the system does, its apparent shape (service, library, script, monolith), and the language and frameworks in play.
2. ENTRY POINTS: where execution starts. Main functions, route handlers, CLI commands, cron jobs, event handlers, the exported public API. Name the file and symbol for each.
3. DATA FLOW: trace one primary request or job from entry to output as a short numbered path (function to function, module to store). If there are several flows, trace the most important one and name the others.
4. THE THREE FILES THAT MATTER MOST: pick exactly three. For each, say why it is load-bearing: most-called, holds the core state, or the place every feature touches. If someone reads only three files before changing this code, these are the three.
5. LANDMINES AND FOOT-GUNS: the things that will burn a newcomer. Global mutable state, hidden side effects, misleading names, functions that look pure but write to disk or network, retry or timeout traps, config that changes behavior silently, TODO or HACK comments that flag real debt.
6. UNKNOWNS: what you would need to see to finish the map (a config file, a schema, the caller of an exported function). Be specific about which file or symbol.

RULES
- Ground every claim in something visible in what I pasted. If you are inferring, prefix the line with "Likely:".
- Do not guess at behavior you cannot see. Put it under UNKNOWNS instead.
- Prefer file:symbol references over prose so I can jump straight there.

[PASTE CODE, FILES, OR DIRECTORY LISTING HERE]

Tools used: Claude, ChatGPT, Any LLM

Want this running in your business? KOBA42 builds and operates automations like this one.