For the crab: Heat a wok over high heat. Add the oil, garlic, shallots and onions and stir-fry until fragrant, 30 seconds. Add the peppercorns and crabs and toss for 7 minutes. Stir in the tamarind sauce and cook until the crab is cooked through, about 1 minute more.
Add the basil and chiles, toss once more, and serve garnished with more basil and chiles if desired.