The system of second-order $ZFC$, presented in Shapiro, "Foundations without Foundationalism", is formulated in second-order logic and includes the usual axioms of extensionality, foundation, pairs, unions, powerset, and infinity from $ZFC$, plus the second-order axiom of replacement:
$$ \forall f\forall x\exists y\forall z(z\in y \iff \exists w(w\in x \land z=f(w))) $$
where $x,y,z,w$ are sets as usual, and $f$ is a function quantified over.
To these should be added an axiom of choice, since Shapiro takes choice to be part of his deductive system, however shows this is not really necessary and a deductive system without inherent choice can be contructed. In that case, we will have to add choice to our axioms of set-theory.
The resulting theory is very beautiful in my eyes; It has been discussed several times here that this theory is 'almost categorical', and that it is in some sense 'the most categorical' set theory will ever get.
My question, how can this theory be expanded to include classes in general? Like first-order $ZFC$ is expanded to include classes in MK set theory, I suppose this theory can also be expanded to accomodate classes. The primitive objects in the theory will be classes only, and the definition of a set can be carried over from MK set theory. However, it is very unclear to me how should the other axioms be changed to accomodate for classes without creating contradictions. How can this be done?