We study the performance of quantum Stirling machines based on two Heisenberg-coupled spins as the working system near quantum critical point (QCP). During the heat cycle, the spins perform either as a heat engine or a refrigerator, with changing magnetic field to the critical point. At the QCP, the efficiency of the engine and the coefficient of performance of the refrigerator attain the corresponding values of their Carnot counterparts, along with maximum work output. We analyze how such enhancement can be attributed to the nonanalytic behaviour of spin-spin correlation and the entanglement near the QCP. Further, we explore how two spins perform as a thermal machine in presence of a third spin, when all the three spins are in thermodynamic equilibrium and exhibit quantum Stirling cycle. • The Stirling cycle with a few spins working system can function as a heat engine or as a refrigerator. • The quantum phase transition in a few-spin system is characterized by the discontinuity in thermal correlation and entanglement. • Quantum Stirling heat machines can attain the Carnot limits of performance at the quantum critical point.