Slight tangent: you want to read the diff between your branch and the merge-base with origin/main. Otherwise you get lots of spurious spam in your diff, if main moved since you branched off.
One thing that seems important is to have the agent write down their plan and any useful memory in markdown files, so that further invocations can just read from it