I often use isearch (
C-s normally or
/ in evil) and then want to use that query (or part of it) for replacing. This answer explains how to cycle history, but
M-p cycles the history for each mode separately so I don't see isearch queries from query-replace.
Ideally, the query I used for either search is automatically saved and I can use a key binding to insert the query into a buffer or minibuffer.
Example: search for "fib-function",
C-h f and insert "fib-function" for help, or helm-do-grep to search for it in files, or just insert it into the current file to start defining it.