In this paper, we develop in detail a fully geometrical method for deriving perturbation equations about a spatially homogeneous background. This method relies on the 3 + 1 splitting of the background space-time and does not use any particular set of coordinates: it is implemented in terms of geometrical quantities only, using the tensor algebra package xTensor in the xAct distribution along with the extension for perturbations xPert. Our algorithm allows one to obtain the perturbation equations for all types of homogeneous cosmologies, up to any order and in all possible gauges. As applications, we recover the well-known perturbed Einstein equations for Friedmann-Lemaître-Robertson-Walker cosmologies up to second order and for Bianchi I cosmologies at first order. This work paves the way to the study of these models at higher order and to that of any other perturbed Bianchi cosmologies, by circumventing the usually too cumbersome derivation of the perturbed equations.