The point is not to hold the whole codebase in your head. Even a single file memorized line for line can have bugs. Like you said, no code is perfect.
Bugs arise from your mental model of the code. As the code grows, your ability to model it diminishes exponentially because every part interacts with every other part. Writing code in that diminished state is the source of most bugs.
The architecture of clean code was a solved problem nearly 50 years ago, and modern testing frameworks allow you to get even more certainty about your code than ever before. Locking your code in place, verifying that it works using automated testing from the smallest module all they way up to the system as a whole reduces the burden on your mind when you seek to make changes to it.
The software industry chafes against clean coding practices because they cut into profits, so the majority of software developers adopt a disdain of it. So we find ourselves in this situation.
