Im watching the show for the second time and I'am wondering if Barney is a FBI agent or some kind of special federal agent or even a spy.

We know that he is at least an informant & mole to the FBI but he has a few skills that your average civilian doesn't have.

He can hold his breath for more than 12 minutes, in the subway war he was good at orientation and he was really fast,

Barney even completed a marathon without training beforehand.

Barney has great stamina and mental resistance.

Ted mentioned that he would disappear for weeks sometime.

Was Barney in a secret mission?

To top it off he speaks a few languages, Barney Stinson speaks Korean, Mandarin and Ukranian.