  Quantum sensors are an established technology that has created new
opportunities for precision sensing across the breadth of science. Using
entanglement for quantum-enhancement will allow us to construct the next
generation of sensors that can approach the fundamental limits of precision
allowed by quantum physics. However, determining how state-of-the-art sensing
platforms may be used to converge to these ultimate limits is an outstanding
challenge. In this work we merge concepts from the field of quantum information
processing with metrology, and successfully implement experimentally a
*programmable quantum sensor* operating close to the fundamental limits imposed
by the laws of quantum mechanics. We achieve this by using low-depth,
parametrized quantum circuits implementing optimal input states and measurement
operators for a sensing task on a trapped ion experiment. With 26 ions, we
approach the fundamental sensing limit up to a factor of 1.45(1), outperforming
conventional spin-squeezing with a factor of 1.87(3). Our approach reduces the
number of averages to reach a given Allan deviation by a factor of 1.59(6)
compared to traditional methods not employing entanglement-enabled protocols.
We further perform on-device quantum-classical feedback optimization to
`self-calibrate' the programmable quantum sensor with comparable performance.
This ability illustrates that this next generation of quantum sensor can be
employed without prior knowledge of the device or its noise environment.
