Bring a large pot of salted water to a boil and blanch green beans for 3-4 minutes until bright green and crisp-tender, then drain and set aside.
In a large skillet over medium heat, melt butter and add sliced onions with a pinch of salt.
Cook onions, stirring occasionally, for 12-15 minutes until deeply golden and caramelized, reducing heat if they start to burn.
Add minced garlic to the caramelized onions and cook for 1 minute until fragrant.
Add the blanched green beans to the skillet and toss everything together for 2-3 minutes until beans are heated through and coated with the onion mixture.
Season with salt, black pepper, and red pepper flakes if using, then serve immediately.