Heat the oil in a large skillet over medium heat. Add the onion and cook, stirring, until soft, about 5 minutes.
Stir in the garlic and cook for 30 seconds, until fragrant. Add the drained beans, water, and salt. Bring to a gentle simmer and cook for 5 minutes.
Mash the beans in the skillet to your preferred texture. Simmer for another 3 to 5 minutes, stirring and adding a little water if needed; the beans will thicken as they cool.
Stir in the lime juice, taste for salt, and finish with cilantro if using. Serve warm.