Tissue repair after spinal cord injury requires the mobilization of immune and glial cells to form a protective barrier that seals the wound and facilitates debris clearing, inflammatory containment and matrix compaction. This process involves corralling, wherein phagocytic immune cells become confined to the necrotic core, which is surrounded by an astrocytic border. Here we elucidate a temporally distinct gene signature in injury-activated microglia and macrophages (IAMs) that engages axon guidance pathways. Plexin-B2 is upregulated in IAMs and is required for motor sensory recovery after spinal cord injury. Plexin-B2 deletion in myeloid cells impairs corralling, leading to diffuse tissue damage, inflammatory spillover and hampered axon regeneration. Corralling begins early and requires Plexin-B2 in both microglia and macrophages. Mechanistically, Plexin-B2 promotes microglia motility, steers IAMs away from colliding cells and facilitates matrix compaction. Our data therefore establish Plexin-B2 as an important link that integrates biochemical cues and physical interactions of IAMs with the injury microenvironment during wound healing.