Microbial communities in soil or the mammalian gut are constantly changing, as they first assemble and as species adapt to each other and to their environment. Being able to predict how these dynamics play out is crucial, as these communities greatly affect us and our environment. But since studying co-evolutionary dynamics in natural systems is extremely challenging, in my lab we study small bacterial communities as model systems. First, I will show how the interactions between four bacterial species depend on their environment: the harsher the environment, the more positively species interact. These positive interactions meant that community function - degradation of a pollutant - was greater when the species were together. We then allowed the community to evolve over almost a year and found that as our community stabilised, interactions between its members tended to become weaker, as did their degradation ability, but the community became more resistant to invasion by additional species. The final part of my talk will explore whether one can build new communities from scratch using artificial selection that have a greater and more evolutionarily stable function. We show that selection for increased community function is indeed possible, although complicated in practice. These results provide an intuition on how microbial species adapt to one another over ecological and evolutionary time-scales when left to co-evolve naturally, or if we strive to drive their selection toward a desired target.