I develop an intra-firm theory of group design and teamwork in the presence of peer effects. The purpose is to understand the interlinkages between intra-firm group formation and the extent of wage dispersion within the firm. Given a set of heterogeneous workers, the manager faces the challenge of allocating workers into endogenous groups (or teams) to maximize total profits. The optimal allocation features locational proximity between workers with similar productivity levels. I discuss the implications of this allocation on intra-firm wage outcomes. The main idea is that the wage paid to a single worker is determined by the productivity levels of the teammates as well as the worker's own productivity. This means that team composition is critical to understanding the within-firm productivity and wage differentials. I show that intra-firm wage dispersion is more pronounced when workers are more alike within each team and more different across the teams. I provide numerical exercises designed to illustrate how the model's predictions change as the key parameters are varied. One striking result is that a rise in the correlation between education and productivity (this can be interpreted as hiring workers with vocational education) leads to a decline in wage inequality within the firm. I also show that changes in the dispersion of worker efficiency lead to non-monotonic effects on within-firm wage inequality.