My rule of thumb is to hang onto all one-offs in a separate folder from the rest of my "production" scripts. If the same problem comes up again, then I look into cleaning it up assuming that if I need it twice, then I'll probably need it a third time (and beyond).

I also toss in some comments with keywords that I may want to search for in the future. That helps me get through the clutter of the one-off folder. In practice, I treat the one-off folder like you do your template file. That's my guess at least.