We describe an algorithm for optimising the mesh in the least-squares finite element discretisation of first-order systems of partial differential equations. The key feature of the method is that the optimisation process is based entirely on the solution of local PDE problems. We apply the algorithm to the Stokes equations for the flow of a viscous incompressible fluid, and to a convection diffusion equation where convection dominates.