Any task I'm working on has a GitHub issue - in a public repo for my open source work, or a private repo for other tasks (including personal research).
As I figure things out, I add comments. These might have copy pasted fragments of code, links to things I found useful, quoted chunks of text, screenshots or references to other issues.
I often end up with dozens of comments on an issue, all from me. They provide a detailed record of my process and also mean that if I get interrupted or switch to something else I can quickly pick up where I left off.
Here's a public example of one of my more involved research threads: https://github.com/simonw/public-notes/issues/1
I also create a new issue every day to plan the work I intend to get done and keep random notes in. I wrote about how that works here: https://til.simonwillison.net/github-actions/daily-planner