From Wiktionary:

  1. (idiomatic) Any apparently useless activity which, by allowing you to overcome intermediate difficulties, allows you to solve a larger problem.
    I was doing a bit of yak shaving this morning, and it looks like it might have paid off.
  2. (idiomatic) A less useful activity done to consciously or unconsciously procrastinate about a larger but more useful task.
    I looked at a reference manual for my car just to answer one question, but I spent the whole afternoon with my nose buried in it, just yak shaving, and got no work done on the car itself.

I ran into this one on Hacker News and looked it up on Wiktionary, only to find two seemingly contradictory definitions. The origin seems to be from an episode of the old Ren & Stimpy cartoon, but I was immediately interested in who created the term, which drew me to an old post by Scott Hanselman:

Yak shaving is what you are doing when you’re doing some stupid, fiddly little task that bears no obvious relationship to what you’re supposed to be working on, but yet a chain of twelve causal relations links what you’re doing to the original meta-task.

This then led me to the original coining of the term, on an MIT mailing list:

I was working on my thesis and realized I needed a reference. I’d seen a post on comp.arch recently that cited a paper, so I fired up gnus. While I was searching the for the post, I came across another post whose MIME encoding screwed up my ancient version of gnus, so I stopped and downloaded the latest version of gnus.

It does seem like there is some ambiguity in the modern usage, as reflected in the above definition. It can either refer to a chain that leads you to be doing something that is seemingly unrelated to your original goal, but actually makes sense when you explain the series of steps, or it can be the result of a short attention span and an endless ability to be distracted, especially possible these days fast Internet connections and social networks.

I try to keep my yak-shaving to a minimum at work. Sometimes it’s unavoidable in software development, when you fall down the rabbit hole of “well, I needed to test this, when I ran into this bug, which required me to contact this guy, who needed this other thing from me”, especially when dealing with legacy code or finicky testing environments. Automation and unit testing can catch problems earlier, but there will always be times when the shears have to come out.