Yes. AI agents work best with clean code. That is a given. Either you know how to do it, or you will suffer (and pay way way more tokens than you should for suboptimal results, and you will think it's a matter of changing LLMs)
Full explanation on Clean Code for AI: