I was wondering if something similar for the shell would be useful. It could for example alter the history to only have the commands that you used in the context of working on a paritcular task. It could maybe even set up env accordingly.
I don't know if I've understood your problem but I'll hazard a guess.
I don't know if a specific plugin or a software available for bash that does this, but command completion with ^r is one way to look at your problem. Am I correct ? Would that solve your problem or you are looking for something more deeper than that, something which actually understands the context you're working in ?