It's weird using Claude to optimize code because it's good at implementing optimizations, but has no sense of how fast things should be. You'll ask it why something is so slow, and it will explain that everything is reasonable and at best you could maybe make it 50% faster, and then you tell it to fix the obvious exponential-time algorithm and it's surprised by the size of the improvement.
Thinking about this right now as Claude explains to me that some code for trivial conversions of MathML to readable prose couldn't possibly execute faster than 50 ms[1](!) per article.
For comparison, we parse and the entire article (generally 10x more HTML than text), re-write links and images, strip JavaScript, and pull out the main text more than 10x faster than this.