Hey, sorry for late reply,
I have only played Single player so I can only speak about that,
I think that normally around turn 75-100 we will be attacked anyway from the lack of fear and respect of some other colony, so there has to be a minimal defence force to stop potential invaders, especially for water or coastal start that is more exposed to a landlocked start.
Do you use ranged units to soften up the city first, then attack with melee/armor (as players often do in Civ5 or Civ6)?
I think that naval units are very efficient and strong, and in maps with water I try to focus on them, especially on the ranged ones, with a few melee ones to act as front unit and city capturers.
For landlocked war, I wouldn't really attack using units that are not very strong because it is so hard to soften cities that have Defense Perimeters or Rocket Battery, but in some cases, for example when we can create Sky Chitin early game, I think the air units can be pretty effective, especially if they can be helped by a Tacnet Hub. With Sky Chitin, focusing on air units and capturing the map seems like a solid option. When I am building land units I try to focus on Combat Rover unit type because they are so efficient late game with their hovering even over water, canyons.
Do you lose some units in the assault, or when the AI counter-attacks?
I usually try to avoid having to sacrifice units, I try to conserve them as much as possible, that's also because losses will be deducted from the Spoils of War screen after the war ends..
What are your tech paths?
I find myself going to Computing as fast as possible in all situations before doing anything else, either by Engineering or Ecology route, followed up by Communications for access to the Command Center and Feedsite Hub, which give 1 extra spy each with the quest decision. (This works because Naval units can be built right from the start and they are so efficient all the game) I do this Computing rush because I find that Spies are so borderline OP.... I believe that both Steal Science and Steal Energy operations should have been lower in efficiency compared to how they are.
However for a landlocked situation where naval units can't be built, and with a close neighbor, I think that a detour to something is needed to not risk getting overrun. Access to Phisics or / and Robotics seems like a more reasonable way to ensure survival before going to Computing. If theland area has many canyons, mountains, or is easily defended with only Combat Rovers, I would skip these too just to not delay the Spy Agency. They will be very useful later anyway.
How much affinity do you have before declaring war?
I think it's hard to say, just that it should be enough for the affinity levels to allow a similar power of units compared to the enemy.
For naval combat, as long as they are in good enough numbers, (6-7 ranged ones, 3-4 melee ones at least), I think they can be good enough to attack even superior forces sometimes.
For land armies, it's best to not get behind in affinity otherwise making progress will be too difficult.
Affinity 6 for Needlejet seems like an important point to achieve, and it comes with having very good tanks in the Soldier unit type as well...
Do you build any buildings in your cities, or just units and more units?
After the Trade Depot which seems mandatory in all cities, I try to build things that increase Food and Production with priority. Other buildings can wait. Energy will come from Steal Energy opperations if there is something that needs to be bought, Science isn't important either if you get it from Steal Science, and Culture / Diplomatic Capital are good but I wouldn't prioritize them in my cities. Health only needs to not go lower than -20 because then there are production deficits, so Health buildings I will build only to stay above that.
In the case of water or coastal start, just building Trade depot, and then units and more units is also good to me, considering how powerful Spoils of War mechanic is after you conquer somebody with those units.
As for unit type, for Naval I prefer lots of Ranged and a few Melee,
and for land army, Combat Rovers and Air units... Melee, Ranged, Siege, and special affinity units simply don't feel like they are needed when Rovers and Air are so efficient. Unless they just happen to exist because they were needed at some point, and survived to the endgame. In that case they can of course be used and contribute to the war effort, but I wouldn't build more of them.