Charli XCX isn't taking any chances with an allegedly obsessed fan ... she just got court-ordered protection from the guy she says broke into her home and then got naked ... all over the place.
The "Boom Clap" singer claims the man tried to visit her at her L.A. area home twice last week -- and the second visit ended with him stripping down, jumping in her hot tub, and also strolling in and out of her bedroom.
Charli beelined it to court, filing for and getting a temporary restraining order against the suspect, who's from Wisconsin. She claims he's sent her hundreds of manic, obsessive and disturbing messages on social media -- but took it to the next level when he showed up at her pad on Aug. 24 and 25. The latter is when he bared all ... and Charli has that all on security footage.
According to the docs, obtained by TMZ, she wasn't at home when the man allegedly broke in, but she's not taking any chances going forward. The order requires him to stay at least 100 yards away from her, her car, her job and her home.