TikZ: How to pass default option to pic?

Is there a way to pass default options to a pic? In the MWE, the option transform shape is passed to an instance of a pic. Is it possible to make this option the default for all pics square such that one does not need to pass it to all instances?

\documentclass[tikz]{standalone}

\begin{document}

\begin{tikzpicture}[scale=0.8]
\tikzset{pics/square/.style={code={\fill[#1] (0,0) rectangle (1,1);}}}
\draw (-1,-1) grid (2,2);
\pic {square=green};
\pic[transform shape] {square=red};
\end{tikzpicture}
\end{document}


• Not an answer to your question, but if you use \tikzset{pics/square/.code={\fill[#1] (0,0) rectangle (1,1);}}, the transform shape is not needed. – Max Jan 9 at 12:48

You can set a key with a style in a different path by calling the complete path. The complete path of transform shape is /tikz/transform shape:

\documentclass[tikz]{standalone}

\begin{document}
\begin{tikzpicture}[
scale=0.8,
pics/square/.style={
/tikz/transform shape,
code={\fill[#1] (0,0) rectangle (1,1);}
}
]
\draw (-1,-1) grid (2,2);
\pic {square=green};
\pic {square=red};
\end{tikzpicture}
\end{document}


Result: