Blend the shallots, garlic, large red chilies, bird's eye chilies, ginger, and tomato into a coarse paste with a splash of water. Pulse rather than puree, you want a little texture.
Heat the oil in a wide pan over medium. Add the chili paste, lemongrass, and kaffir lime leaves. Fry, stirring often, for 6 to 7 minutes, until the paste darkens and oil separates at the edges.
Add the chicken chunks, salt, and sugar. Stir to coat, then cover and cook 5 minutes.
Uncover and simmer another 6 to 8 minutes, stirring now and then, until the chicken reaches 165F (74C) and the sauce clings to the pieces.
Turn off the heat. Stir in the lime juice and basil, then taste for salt and lime. Rest 2 minutes and serve over rice.