  Using density functional theory within the local density approximation we
report a study of the electron-phonon coupling in NbC$_{1-x}$N$_x$ and NbN
crystals in the rocksalt structure. The Fermi surface of these systems exhibits
important nesting. The associated Kohn anomaly greatly increases the
electron-phonon coupling and induces a structural instability when the
electronic density of states reaches a critical value. Our results reproduce
the observed rise in $T_{c}$ from 11.2 K to 17.3 K as the nitrogen doping is
increased in NbC$_{1-x}$N$_x$. To further understand the contribution of the
structural instability to the rise of the superconducting temperature, we
develop a model for the Eliashberg spectral function in which the effect of the
unstable phonons is set apart. We show that this model together with the
McMillan formula can reproduce the increase of $T_{c}$ near the structural
phase transition.
