So, early and late in his career, Shakespeare worked with other playwrights. In the middle, other playwrights seem to have worked with him, or at least worked on his scripts. The playwright Thomas Middleton had a hand in Macbeth, probably in Timon of Athens, and likely in both Measure for Measure and All’s Well That Ends Well.
No doubt there are other collaborations in the Shakespeare canon. That’s the way plays were composed. The plays of the Elizabethan theater were not written like Lord Byron’s poems or Virginia Woolf’s novels in a room of his or her own. They were more like our movie or TV scripts, which might combine several ideas from a writers’ room or get reworked by one or more “script doctors.” In the account book of the theater manager Philip Henslowe—the most important surviving document testifying to how plays were written in Shakespeare’s time—nearly two-thirds of the plays mentioned are in some sense collaborative. A team of playwrights might have completed a script by writing one act each, as was the case for a play Henslowe commissioned in 1602 from Anthony Munday, Michael Drayton, John Webster, Thomas Dekker, and Middleton. And old plays were regularly updated, as when Henslowe paid two playwrights, Samuel Bird and William Rowley, for “additions” to Marlowe’s Doctor Faustus.
From David Scott Kastan, Shakespeare Didn't Write Alone, The Atlantic, June 8, 2019: