Striker Chris Martin bagged both Rams goals to earn McClaren's men an eighth win from nine games and move them into the automatic promotion places above Burnley and QPR, who both drew.
Martin opened the scoring with a deflected close-range finish in the eighth minute before heading the winner four minutes after the break, following Andre Wisdom's cross from the right. Barnsley substitute Tomaz Cywka halved the deficit after 62 minutes with a 25-yard strike against his former club.
Despite his side's league position, McClaren, who has led his team from 14th to second in three months, refused to get carried away.
"There's a still a long way to go but, as I've said before, if someone said you'd be where you're now (when he took over in September) I'd have said 'You're crazy, you're barking mad'.
"The players deserve the credit; everybody's responded from day one, which we've been very fortunate with because sometimes with a change of management it can take time.
"The fans have backed us in terms of coming back to Pride Park and supporting us and we've got 6,000 travelling supporters behind the goal (today). That's a lot of responsibility on the players and they took that responsibility today to get the result.
"I thought we controlled the game completely, then all of sudden from nowhere they have a shot and it's a goal and then it's chaos and mayhem, which is the Championship. The players dug in and showed great resilience and I think that's a big word and a key word that we'll be using over the next few months.
"When you're challenging at the top, the season really begins with the last 10 games and if we're in this situation and if we've got a chance in the last 10 games then I think all the expectation and all the pressure comes.
"What we're doing at the present moment is enjoying the ride and let's see in March and April where we are and maybe get excited a little bit but at the moment there's a long way to go."
Barnsley boss Danny Wilson felt his side started the game too slowly and said changes were needed.
"I've got mixed emotions," Wilson said. "I think the back end of the game was very positive from our point of view; the first part of the game, going two-nil down in the manner we did, was really disappointing.
"We can't allow a very good footballing side, as Derby are, time and space on the ball and we gave them too much. We allowed them to dictate the pattern and the pace of the game and that really hurt us.
"It was like 'After you, Claude' to a certain degree and losing the two goals in the manner we did was disappointing. They were soft goals from our perspective but at least we put a shift in in the second period of the game but again it's too late against a team with quality like that."
Wilson added: "We need a lot of work doing. We can't continue to keep saying 'We should've got something out of the game, we should've done this', I'm bored with it already, I've only had three games. Having the same old stuff to say all the time, I'm not prepared to do it.
"We have to move and move players around in January as best we can, whether we've got to let players go we'll have to wait and see but if it's for the better of the team then we're going to have to do it."