The laws of thermodynamics, powerful for countless purposes, are not exact: both their phenomenological and their statistical-mechanical versions are valid only at ‘macroscopic scales’, which are never defined. Here I propose a new, exact and scale-independent formulation of the first and second laws of thermodynamics, using the principles and tools of the recently proposed constructor theory. Specifically, I improve upon the axiomatic formulations of thermodynamics (Carathéodory, 1909; Lieb & Yngvason, 1999) by proposing an exact and more general formulation of ‘adiabatic accessibility’. This work provides an exact distinction between work and heat; it reveals an unexpected connection between information theory and the first law of thermodynamics (not just the second); it resolves the clash between the irreversibility of the ‘cycle’-based second law and time-reversal symmetric dynamical laws. It also achieves the long-sought unification of the axiomatic version of the second law with Kelvin’s.