  PSR J1023+0038 is a rapidly-spinning neutron star with a low-mass-binary
companion that switches between a radio pulsar and low-luminosity disk state.
In 2013, it transitioned to its current disk state accompanied by brightening
at all observed wavelengths. In this state, PSR J1023+0038 now shows optical
and X-ray pulsations and abrupt X-ray luminosity switches between discrete
'low' and 'high' modes. Continuum radio emission, denoting an outflow, is also
present and brightens during the X-ray low modes. Here, we present a
simultaneous optical, ultraviolet (UV) and X-ray campaign comprising Kepler
($400-800$ nm), Hubble Space Telescope ($180-280$ nm), XMM-Newton ($0.3-10$
keV) and NuSTAR ($3 - 79$ keV). We demonstrate that low and high luminosity
modes in the UV band are strictly simultaneous with the X-ray modes and change
the UV brightness by a factor of $\sim25$\% on top of a much brighter
persistent UV component. We find strong evidence for UV pulsations (pulse
fraction of $0.82\pm0.19$\%) in the high-mode, with a similar waveform as the
X-ray pulsations making it the first known UV millisecond pulsar. Lastly, we
find that the optical mode changes occur synchronously with the UV/X-ray mode
changes, but optical modes are inverted compared to the higher frequencies.
There appear to be two broad-band emission components: one from radio to
near-infrared/optical that is brighter when the second component from optical
to hard X-rays is dimmer (and vice-versa). We suggest that these components
trace switches between accretion into the neutron star magnetosphere
(high-energy high-mode) versus ejection of material (low-energy high-mode).
Lastly, we propose that optical/UV/X-ray pulsations can arise from a shocked
accretion flow channeled by the neutron star's magnetic field.
