My guess is:
- send out small counterattacks (primarily seige frigates) to multiple low-hp enemy outposts (preferably asteroids) in an attempt to knock them out or at least force the enemy to divert forces
- if you can split your defense fleet and still repel the enemy, do so, if not try to shore up the tactical building defense there (repair towers to keep your fleet alive longer, hangars to hit any attacker in the grav well, well placed gauss cannons - lots of them!). If you're worried about planet bombing, upgrade the crisis infrastructure on the planet to raise hp.
- if you're getting surprised, make sure to research PSIDAR if you can to get more intel of enemy phase jumps; also plant scouts in neighboring systems so you can see what side of the jump point they're jumping from so your fleet can be all over them (or at least on the right side of the planet) when they jump in.
- if you can't inflict enough losses on a retreating enemy, make sure you've got Phase Jump Inhibitors to extend the time they need to jump out. If you have an Akkan with Ion Bolt (or something else with a similar ability) you can keep reseting a specific ship's jump timer so you could at least take out one cap ship each time.
Hold your ground, cost them more resources than they cost you, force them to choose between continuing their offensive and losing asteroids.
Never surrender, maul the AI