Ask AI to record in a projects directory memory: LOG.md, HANDOFF.md, DECISIONS.md, a plan folder. Reference code with absolute paths. Keep repeatable processes in skills. Version control it all, and use a dreaming process across multiple sessions to stop repeat mistakes.
That's what's worked for me, but there's many variations of this.