  The classification of complex of real finite dimensional Lie algebras which
are not semi simple is still in its early stages. For example the nilpotent Lie
algebras are classified only up to the dimension 7. Moreover, to recognize a
given Lie algebra in a classification list is not so easy. In this work we
propose a different approach to this problem. We determine families for some
fixed invariants, the classification follows by a deformation process or
contraction process. We focus on the case of 2 and 3-step nilpotent Lie
algebras. We describe in both cases a deformation cohomology of this type of
algebras and the algebras which are rigid regarding this cohomology. Other
$p$-step nilpotent Lie algebras are obtained by contraction of the rigid ones.
