As Martin Scharrer pointed out, preview or standalone classes see the Tikz picture as black boxes with some size reported by the TikZ bounding box. For this reason, it's only up to TikZ internals to compute the correct box.
However, arrows and line join artifacts don't contribute to bounding box calculations and I don't know a quick hack to fix this. Example:
\documentclass[tikz,border=0pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3,line width=3pt]
\draw[red] (0,0) grid (1,1);
\draw[blue,|->] (0,0) -- (1,1);
\draw[line join=miter] (1,1) -- (0,0.5) -- (1,0);
\end{tikzpicture}
\end{document}

You can manually change the bounding box to include the missing details for example with
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3,line width=3pt]
\draw[red] (0,0) grid (1,1);
\draw[blue,|->] (0,0) -- (1,1);
\draw[line join=miter] (1,1) -- (0,0.5) -- (1,0);
\useasboundingbox ([shift={(-0.5\pgflinewidth,-0.5\pgflinewidth)}]current
bounding box.south west) -- (current bounding box.north east);
\end{tikzpicture}
\end{document}

Note that the shift amount should be changed for each custom picture, I've just used a shortcut here.
\draw[line join=miter] (1,1) -- (0,0.5) -- (1,0);to see that. You have to update the bounding box. – percusse Sep 12 '12 at 17:18\useasboundingbox ([shift={(-0.5\pgflinewidth,-0.5\pgflinewidth)}]current bounding box.south west) -- (current bounding box.north east);– percusse Sep 12 '12 at 17:24standaloneorpreviewcan do here automatically, because they don't know about the actual content. Making TikZ increase the BB like @percusse stated is the way to go. – Martin Scharrer Sep 12 '12 at 17:35