Can spanning tree and UDLD be run together, and if so, is this a good idea?
UDLD is generally run on fibre media, it is not required on UTP due to the use of Fast Link Pulse which is already monitoring link status.
This page has a very good explanation of the various L2 protections available. Here is an excerpt specifically regarding UDLD:
UDLD is used to detect if a link is only available in one direction, for example half the fibre is disconnected. UDLD performs this check faster than STP will bring the port in to a fowarding state. That means if you have UDLD and STP enabled then UDLD will prevent STP from bringing a port in to a state where it will forward traffic to nowhere.
A unidirectional link occurs when traffic is transmitted between neighbors in one direction only. Unidirectional Link Detection is a Layer 2 protocol. UDLD performs tasks that Layer 1 mechanisms, such as auto negotiation, cannot perform. When UDLD and auto-negotiation are enabled, both Layer 1 and Layer 2 detections work together to prevent physical and logical unidirectional connections and the malfunctioning of other protocols. Unidirectional links can cause spanning-tree topology loops. UDLD enables devices to detect when a unidirectional link exists and also to shut down the affected interface. UDLD is useful on a fiber ports to prevent network issues resulting in miswiring at the patch panel causing the link to be in up/up status but the BPDUs are lost.
With UDLD enabled, the switch periodically sends UDLD protocol packets to its neighbor and expects the packets to be echoed back before a predetermined timer expires. If the timer expires, the switch determines the link to be unidirectional and shuts down the port. If messages are not received within the timeout interval (45 seconds), the port is disabled. The messages are sent out every default interval, which is 15 seconds.
The 45 seconds it takes to detect a unidirectional link and errdisable the port is less than the 50 seconds it would take for STP to transition the port to a Forwarding state, which is based on 20 seconds for Max Age + 30 seconds for Listening and Learning. This prevents a loop that would otherwise be caused if STP transitioned the port into the Forwarding state because of a lack of received BPDUs.
So in summary, yes they can be run together and on fibre links they should be run together.
Yes, it's a good idea to run both as they protect you from different failures. If UDLD is not supported on both sides you can use LACP as a poor man's UDLD (between Cisco and Juniper for example) or you could even use Ethernet OAM LFM.
Absolutely. There are many failure modes in spanning tree related to uni directional traffic that UDLD is able to detect and make sure the network continues operating correctly.
Agreed, UDLD is very important, especially on fiber links.
I would recommend both sides of the link be configured using 'udld aggressive' mode if your devices support it.
I only use it on copper ports where there is another L1 media between endpoints, the usual culprit of this is a fibre media converter.