There was a nice comment about this in Worse Than Failure today, quoting Phil Haack: “Avoid premature generalization. ... The first time you notice something that might repeat, don’t generalize it. The second time the situation occurs, develop in a similar fashion — possibly even copy/paste — but don’t generalize yet. On the third time, look to generalize the approach.”
This seems like a pretty good guideline. I’ve certainly worked on projects that were far more general-purpose than they ever needed to be, and were thus harder to learn and maintain.