Start with an executable account
Describe inputs, outputs, side effects, and error behavior using the current implementation and its callers. Find representative tests and note any gap between their assertions and the behavior you observe. Avoid calling a branch redundant until you understand who can reach it and with which values.
Use history as context
A commit message or issue can explain the constraint behind an unusual choice, but that constraint may no longer apply. Check the surrounding change and current dependencies. When history is unavailable, say that the original intent is unknown. You can still produce a useful explanation of today's behavior.
When is a refactor justified?
After you can describe the behavior to preserve and the concrete problem the refactor solves. Understanding old code does not automatically make replacing it the next task.
A question for your assistant
Explain [function] using its implementation, callers, and tests. Separate observed behavior, documented historical intent, and inference. Cite sources in the repository. Identify uncertain assumptions before suggesting any simplification. Do not edit files.