Relevant reading is most notably anthropic’s research on the J-space. LLMs will plan ahead of time helped with CoT, get to a plan and “store” it in j-space, and execute on that plan which means they can in fact “backtrack” and give you reasoning on why they did something, because it IS part of their state.
My global CLAUDE.md explicitly states "When commenting on code and configs, or writing MD files, strictly write within the domain of the content being commented on. DO NOT include information, negatives or ramblings from work sessions. For e.g. if commenting on a proto string field that is replacing an int field, do not comment that 'this is not an int field'".
This reduced the idiocy of the agent (Opus 5 included) when writing documents. But I'm still catching it writing README.md talking about the negatives that it removed. Those belong in the memory if it is actually that important (most of the time it's junk), but Claude doesn't seem to understand and never ever learns.