Honestly, we might be better off abolishing the civil service and going back to the spoils system. At least then there’s no pretense of fairness, and you know who to blame.Civil Service professionals overwhelmingly donate to the Democrats (HT Instapundit). When the system has been captured by a single party, the rationale for a nonpartisan, permanent Civil Service has disappeared. In fact, we might be better off with election-induced turnover.
Term limits for senior civil servants? If they're so competent, they will have ample opportunities in the private sector.
There's no good solution because high-level expertise truly is necessary. However, when the system gets partisan enough, the question arises of how much expertise there actually is.