The goal of the paper is to study the angle between two curves in the framework of metric (and metric measure) spaces. More precisely, we give a new notion of angle between two curves in a metric space. Such a notion has a natural interplay with optimal transportation and is particularly well suited for metric measure spaces satisfying the curvature-dimension condition. Indeed one of the main results is the validity of the cosine formula on RCD*(K, N) metric measure spaces. As a consequence, the new introduced notions are compatible with the corresponding classical ones for Riemannian manifolds, Ricci limit spaces and Alexandrov spaces.