Cocaine use disorder (CUD) is a prevalent substance abuse disorder, and repetitive transcranial magnetic stimulation (rTMS) has shown potential in reducing cocaine cravings. However, a robust and replicable biomarker for CUD phenotyping is lacking, and the association between CUD brain phenotypes and treatment response remains unclear. Our study successfully established a cross-validated functional connectivity signature for accurate CUD phenotyping, using resting-state functional magnetic resonance imaging from a discovery cohort, and demonstrated its generalizability in an independent replication cohort. We identified phenotyping FCs involving increased connectivity between the visual network and dorsal attention network, and between the frontoparietal control network and ventral attention network, as well as decreased connectivity between the default mode network and limbic network in CUD patients compared to healthy controls. These abnormal connections correlated significantly with other drug use history and cognitive dysfunctions, e.g., non-planning impulsivity. We further confirmed the prognostic potential of the identified discriminative FCs for rTMS treatment response in CUD patients and found that the treatment-predictive FCs mainly involved the frontoparietal control and default mode networks. Our findings provide new insights into the neurobiological mechanisms of CUD and the association between CUD phenotypes and rTMS treatment response, offering promising targets for future therapeutic development.