Similarly to rakes and other similar agents from previous games, spies damage other factions by sabotaging their buildings and armies, assassinating their agents, and providing information by scouting on the world map.
Spies have a wider range of functions than rakes from Empire: Total War, and can impact games in crucial ways. Aside from moving, spies may only execute one action per turn.
Spies can infiltrate enemy armies. Successful infiltrations reveal the number and type of regiments in an army and also their regiment sizes. It also removes the army's ability to lay ambushes: they cannot hide from the spy's controlling player on the world map. Chances of infiltration are generally high, and depend on the skill of the army's general as well as that of the spy.
Spies can assassinate other factions' generals, gentlemen, and other spies (the last of which is only available if they were caught in the act of sabotage, assassination, or were found out through counter-spying). The base chance for this (where both the spy and the target have three stars) is about 31%, though the chance may drop to as low as 4% if a particularly bad spy targets a particularly skilled target. A very skilled spy attempting to assassinate an average target can have as high as an 81% chance of success. Assassinating generals weaken enemy armies in battle, reduces their odds of autoresolving in their favor, removes their ability to replenish in some cases, and can force the target faction to recruit new generals, wasting money.
Spies may also sabotage buildings. Generally, the more expensive a building is, the more difficult it is to sabotage. Buildings in region capitals are also more difficult to sabotage. Sabotaged buildings are damaged as if they were sacked by an army, and lose the ability to properly function. In Napoleon: Total War, sabotaged buildings take multiple turns to restore, making this ability much more powerful than previous Total War iterations where sabotaged buildings only take one turn to rebuild. Good targets for sabotage include schools, which can slow down technological progress significantly, and military buildings, preventing new armies from being built.
For the first time in the Total War series, spies in Napoleon: Total War have the ability to sabotage armies. While this inflicts no direct damage, successfully sabotaging an army prevents it from moving the following turn. This is useful both offensively and defensively: an invading army can theoretically be prevented from moving indefinitely by a spy (or a team of spies) until friendly armies can move in position to stop them, while a retreating army can be stopped in its tracks and prevented from escaping. The chance of sabotaging an army depends on the skill of the spy, the stars of the general leading the target army (if a general is present), and the size of the army. The larger the army and the more skilled its general is, the less likely it is to successfully sabotage it. With a sufficient number of spies, it is possible to assassinate the general first, raising the chance of a subsequent successful sabotage.
Also new to the Total War series is the ability for spies to establish spy networks in regions. To do this, a spy needs to enter any building in a region and then wait there for several turns. After sufficient time passes, the region becomes viewable as if it belonged to the player controlling the spy: all fog of war is lifted from the region, and troop numbers and unit types are listed as though they belong to the player. The one exception to this is armies hiding in forests or other places where they can lay an ambush. These remain invisible unless a spy was attached to them in the first place.
Spies automatically attempt to prevent enemy spies from accomplishing any of the above actions by being placed in the building/army/path. The higher their counter-spying subterfuge (and subterfuge in general), the more likely they are to thwart spies.
Whereas generals have "command" stars and gentlemen have "research" stars, spies have "subertfuge" stars. The more skill in subterfuge they have, the more likely they are to accomplish missions. Spies spawn with a chance of having some subterfuge stars by default. They can gain far more stars through repeated usage of their skills. Spies that assassinate a large number of targets, for example, gain subterfuge not just in assassination missions, but also overall subterfuge. Seeking out relatively safe targets, such as low-level buildings or inexperienced gentlemen, improve spies' skills so that they may more successfully target difficult targets in the future.
The most consistent way to train spies is to sabotage buildings (which generally have a high chance of success if the building is not in the region capital) until they attain the highest sabotage-based subterfuge bonus, before transitioning to infiltration missions, the finally assassination missions. However, by loading and trying again whenever a spy fails, any method can create consistently high-performing spies.