The formation of protein patterns inside cells is generically described by reaction-diffusion models. The study of such systems goes back to Turing, who showed how patterns can emerge from a homogenous steady state when two reactive components have different diffusivities (e.g. membrane-bound and cytosolic states). However, in nature, systems typically develop in a heterogeneous environment, where upstream protein patterns affect the formation of protein patterns downstream. Examples for this are the polarization of Cdc42 adjacent to the previous bud-site in budding yeast, and the formation of an actin-recruiter ring that forms around a PIP3 domain in macropinocytosis. This suggests that previously established protein patterns can serve as a template for downstream proteins and that these downstream proteins can 'sense' the edge of the template. A mechanism for how this edge sensing may work remains elusive. Here we demonstrate and analyze a generic and robust edge-sensing mechanism, based on a two-component mass-conserving reaction-diffusion (McRD) model. Our analysis is rooted in a recently developed theoretical framework for McRD systems, termed local equilibria theory. We extend this framework to capture the spatially heterogeneous reaction kinetics due to the template. This enables us to graphically construct the stationary patterns in the phase space of the reaction kinetics. Furthermore, we show that the protein template can trigger a regional mass-redistribution instability near the template edge, leading to the accumulation of protein mass, which eventually results in a stationary peak at the template edge. We show that simple geometric criteria on the reactive nullcline's shape predict when this edge-sensing mechanism is operational. Thus, our results provide guidance for future studies of biological systems, and for the design of synthetic pattern forming systems.