Heat a large heavy-bottom skillet over medium heat and add the olive oil, then the onion, garlic, and chili flakes once the oil is hot.
Saute the onions in the pan until they're soft and just barely translucent.
Add the salt and pepper, tomato paste and canned tomatoes to the pan and use the liquid to scrape all the caramelized bits off the bottom of the pan left from the onions and garlic.
Add the beans, pasta and the stock and stir to combine.
Add the lid to the pan and cook for about 7-10 minutes, stirring a few times, until the pasta has absorbed the liquid and is cooked to al dente.
Once the pasta has cooked through, add the kale and basil (if using dried basil instead of fresh, add it at the beginning with the chili flakes). Toss well so the greens wilt a little bit.
Give the pasta a taste and add a little more salt and pepper, only if necessary.
Top with some freshly shaved Parmesan cheese and serve!
Notes
Feel free to substitute the ditalini with any other variety of pasta you wish, although smaller varieties of pasta work best as they're a similar size to the beans.