Context.The overwhelming majority of diagnostic tools for galactic activity are focused mainly on the classes of active galaxies. Passive or dormant galaxies are often excluded from these diagnostics, which usually employ emission-line features (e.g., forbidden emission lines). Thus, most of them focus on specific types of activity or only on one activity class, for example active galactic nucleus (AGN) galaxiesAims.In this work we used infrared and optical colors to build an all-inclusive galactic activity diagnostic tool that can discriminate between star-forming, AGN, low-ionization nuclear emission-line region, composite, and passive galaxies, and which can be used in local and low-redshift galaxies.Methods.We used the random forest algorithm to define a new activity diagnostic tool. As the ground truth for the training of the algorithm, we considered galaxies that have been classified based on their optical spectral lines. We explored classification criteria based on infrared colors from the first three WISE bands (bands 1, 2, and 3) supplemented with optical colors from theu, g, andrSDSS bands. From them, we sought the combination with the minimum number of colors that provides optimal results. Furthermore, to mitigate biases related to aperture effects, we introduced a new WISE photometric scheme that combines apertures of different sizes.Results.Using machine learning methods, we developed a diagnostic tool that accommodates both active and passive galaxies under one unified classification scheme using just three colors. We find that the combination ofW1-W2, W2-W3, and g-r colors offers a good performance, while the broad availability of these colors for a large number of galaxies ensures it can be applied to large galaxy samples. The overall accuracy is ~81%, and the achieved completeness for each class is ~81% for star-forming, ~56% for AGN, ~68% for LINER, ~65% for composite, and ~85% for passive galaxies.Conclusions.Our diagnostic represents a significant improvement over existing infrared diagnostics because it includes all types of active galaxies, as well as passive galaxies, extending their application to the local Universe. The inclusion of the optical colors improves its ability to identify low-luminosity AGN galaxies, which are generally confused with star-forming galaxies, and helps us identify cases of starbursts with extreme mid-infrared colors that mimic obscured AGN galaxies, a well-known problem for most infrared diagnostics.