\documentclass{minimal}

% \usepackage{tikz}
\usepackage{pgfplots}

% Without the external library everything compiles.
\usepgfplotslibrary{external}
\tikzexternalize[mode=list and make,up to date check=md5]

\begin{document}
	\newcommand{\firstCommand}[1]{#1} % no error
	Text
	\begin{tikzpicture}
		\newcommand{\secondCommand}{1} % no error
		\newcommand{\thirdCommand}[0]{2} % no error
		\newcommand{\fourthCommand}[1]{#1} % error
		\draw (0,0) -- +(1,0);
	\end{tikzpicture}
\end{document}
