Patterns of trait distribution among competing species can potentially reveal the processes that allow them to coexist. It has been recently proposed that competition may drive the spontaneous emergence of niches comprising clusters of similar species, in contrast with the dominant paradigm of greater-than-chance species differences. However, current clustering theory relies largely on heuristic rather than mechanistic models. Furthermore, studies of models incorporating demographic stochasticity and immigration, two key players in community assembly, did not observe clusters. Here we demonstrate clustering under partitioning of resources, partitioning of environmental gradients, and a competition-colonization tradeoff. We show that clusters are robust to demographic stochasticity, and can persist under immigration. While immigration may sustain clusters that are otherwise transient, too much dilutes the pattern. In order to detect and quantify clusters in nature, we introduce and validate metrics which have no free parameters nor require arbitrary trait binning, and weigh species by their abundances rather than relying on a presence-absence count. By generalizing beyond the circumstances where clusters have been observed, our study contributes to establishing them as an update to classical trait patterning theory.