It just so happens that this is the exact topic I wrote my doctoral thesis on. Sources aplenty in the link.
Pirate companies of the 'golden age' generally did have codes, which they referred to as their 'articles'. There are several surviving sets: George Cusack's, Nicholas Clough's, Richard Taylor's, Bartholomew Roberts', Thomas Anstis', George Lowther's, Edward Low's, John Philips', and John Gow's. Fragments of Howell Davis' articles have survived. Anecdotal evidence from a variety of contemporary sources shows that the practice of creating articles extended well beyond the surviving examples.
Pirate articles were not a new invention by any means. In the early-modern period many groups created rules for the good governance of their community, and the pirates' articles were just an extension of that practice. Trade guilds and church groups created their own sets of rules, and even criminal fraternities like seventeenth-century highwaymen and eighteenth-century smugglers and poachers needed codes of conduct to regulate behaviour and establish things like hierarchy and division of spoil. Later, in the Revolutionary War and War of 1812, American PoWs in British prisons created 'articles' for the better management of their community. Of all these groups who created their own codes of law, the most relevant are privateers, who created codes at least as early as the sixteenth century and continued to do so well into the eighteenth. Some pirates began their careers as privateers, and in the case of some of these their privateering articles have survived, such as Thomas Tew and William Kidd. Evidence presented at Kidd's trial shows that the privateering articles with which his crew began their voyage remained in force even after they turned to piracy.
The most common clauses in the surviving pirate articles (in 7 out of the 10 complete surviving sets) dealt with the crime of robbery and theft within the company, and prescribed stern punishments for transgressors. The next most common clauses (6/10) covered the division of spoil, who got how much of the profit, and limitations on gambling. Cowardice in battle and fighting among the company were each covered in 5 of the 10 surviving sets, and trying to leave the company and the provision of extra shares or perks for specific acts were covered in 4 sets. Other clauses included relate to things like obedience to superior officers, working hours, drunkenness, provision of compensation for the wounded, rape, and not killing or striking prisoners.
George Lowther and Edward Low sailed in consort together for a while, and their surviving articles are more or less the same. Low's set of articles contains two clauses not found in Lowther's, but the remaining eight clauses of Low's articles correspond exactly to the eight clauses which made up Lowther's code. Low separated from Lowther and went off on is own account before his articles were recorded, so the most reasonable supposition is that Low's company added the extra two clauses themselves to an agreed set of eight articles which they had shared with Lowther's company. Additionally, Low's article were recorded in almost identical terms after the capture of another of Low's consorts, Charles Harris. It's reasonable to assume therefore that the pirates in the Lowther/Low 'family', which included other pirates companies led by Francis Spriggs and Philip Lyne, shared a set of common articles.
Other pirates, however, seem to have drawn up their own articles which were specific to their own company. Anstis and Roberts, whose articles are quoted below, both began their careers under Howell Davis: Roberts took over command after Davis' death, and Anstis rose to command after he and his men deserted from Roberts' company in April 1721. However, looking at their articles, they are different in some crucial aspect, like their views on women, pardons and leaving the company, and the nature of their hierarchy - under Roberts every made had a vote (a much quoted but totally unique clause, by the way), while under Anstis everyone had to obey civil command. Richard Taylor also began his career under Howell Davis, and his articles are different again. John Philips became a pirate under Anstis and later rose to his own command: his articles are clearly inspired by Anstis', but are not identical.
How it all worked in a shared community like Nassau is an interesting question. There is no known set of rules that applied to all the pirates who made their base there and, to my knowledge, no mention or hint that such a code might have existed. On the one hand we know that the pirates there did consider themselves a homogeneous community, much as Black Sails depicts it: collectively they called themselves The Flying Gang, and there are examples of them working together and taking revenge for each others' misfortunes . We know that pirates were not averse to creating rules and understood their importance in the maintenance of their community, so it's possible that there was a shared code of some kind. However, we also know that the Nassau pirates fell out from time to time, disagreed on a regular basis, and it's difficult to see how a shared code would have been enforced in Nassau, so I think it more likely that they simply agreed to 'get along' when they were in port there.