When your coding LLM like Claude Code, Google Gemini CLI, or ChatGPT Codex CLU get off track and start making up their own tasks to do, forgetting what told them to do, the way to stop that from happening is FIRST Have it..
# MAKE A PLAN DOCUMENT!
Tell it what you want it to accomplish and have it create a plan document to flesh out the full plan of how to make it happen. Then tell it to begin that plan AND keep it updated with progress as it goes along. Put the "you must udpate this continously" IN the plan document or it WILL FAIL to do so, and may still even IF you say it in the plan document, but less likely to forget.
You'll see SIGNIFICANT improvement in the quality of work it does and the time it takes to complete it AND you'll have a document you can monitor to see the actual progress.