  Direct laser acceleration has proven to be an efficient source of high-charge
electron bunches and high brilliance X-rays. However, an analytical description
of the acceleration in the interaction with varying plasma density targets is
still missing. Here, we provide an analytical estimate of the maximum energies
that electrons can achieve in such a case. We demonstrate that the maximum
energy depends on the local electron properties at the moment when the electron
fulfills the resonant condition at the beginning of the acceleration. This
knowledge enables density shaping for various purposes. One application is to
decrease the required acceleration distance which has important implications
for multi-petawatt laser experiments, where strong laser depletion could play a
crucial role. Another use for density tailoring is to achieve acceleration
beyond the radiation reaction limit. We derive the energy scaling law that is
valid for arbitrary density profile that varies slowly compared with the
betatron period. Our results can be applied to electron heating in exponential
preplasma of thin foils, ablating plasma plumes, or gas jets with long-scale
ramp-up.
