We show that one can define and effectively compute Stallings graphs for quasi-convex subgroups of automatic groups (textit{e.g.} hyperbolic groups or right-angled Artin groups). These Stallings graphs are finite labeled graphs, which are canonically associated with the corresponding subgroups. We show that this notion of Stallings graphs allows a unified approach to many algorithmic problems: some which had already been solved like the generalized membership problem or the computation of a quasi-convexity constant (Kapovich, 1996); and others such as the computation of intersections, the conjugacy or the almost malnormality problems. Our results extend earlier algorithmic results for the more restricted class of virtually free groups. We also extend our construction to relatively quasi-convex subgroups of relatively hyperbolic groups, under certain additional conditions.