What is a code of conduct?

In short
A code of conduct is a written set of rules that describes how people should behave in a community, such as an open source project. It sets clear expectations, explains how to report problems, and says what happens when someone breaks the rules. Contributor Covenant is a widely used template for writing one.
What a code of conduct does
A code of conduct is a short document that explains how people should treat each other when they take part in a shared space. In software, that space is often an open source project, a forum, a chat channel, or a team's issue tracker. The document does not write code. It writes down the values that the community already holds, so that newcomers know what is expected and experienced members have something to point to when a conflict starts.
Most codes of conduct cover a few common points. They describe the behavior the community wants to see, such as respectful feedback and patience with beginners. They list the behavior that is not acceptable, such as harassment, personal attacks, or publishing private information without permission. They also explain where to report a problem and who will read the report. Good documents add a short note on enforcement, which means what the maintainers will do after a report: a warning, a temporary ban, or a permanent removal.
Why teams use a template
Writing a code of conduct from scratch takes time, and it is easy to miss important details. For this reason, many projects start from a template. The Contributor Covenant is the most widely adopted open source code of conduct in the world. Its documentation says it helps a community express its core values while setting clear expectations for how people should treat one another.
The project offers an interactive builder. You choose a language from a list of more than 40 translations, add details about how to report an issue, and decide on your enforcement policy. You can use the project's recommended wording or change it to fit your group. When you finish, you download the text and place it in your website or repository. The documentation says the text is meant to be shared this way, so the same wording can appear across many projects.
A template does not replace thought. The people who run the project still need to decide who receives reports, how quickly they respond, and what they do in serious cases. A template gives you the structure. You still provide the details.
A simple example
Imagine a small library that a few volunteers maintain on a public code host. A newcomer opens an issue with a question, and a regular contributor replies with an unkind joke about the question. The newcomer feels unwelcome and stops posting. With a code of conduct in place, the newcomer can read the document, see that personal jokes at someone's expense are not allowed, and report the reply to a named contact. A maintainer can then read the report, talk to the contributor, and apply the enforcement steps written in the document.
The example shows the main value of the document. It turns an unclear feeling ("this does not seem right") into a shared standard that everyone can read before a problem happens. It also gives maintainers a fair, consistent way to respond, so they do not have to invent rules under pressure.
Common mistakes
The first mistake is adopting a code of conduct and never explaining how to report a problem. A document without a contact point is hard to use when someone is upset. Always include a working channel, and make sure more than one person can read reports if the team is small.
The second mistake is writing rules that nobody enforces. If the document promises action and the maintainers ignore violations, people lose trust in the whole project. Only write enforcement steps you are willing to carry out. The third mistake is treating the document as finished once it is published. Communities change, and so do the people in them. Review the text from time to time and update contact details when volunteers leave.
A fourth point is less obvious. A code of conduct is not a substitute for good communication. Most everyday friction is solved by a clear question or a short reply. The document is there for the cases where that does not work.
Related ideas
A code of conduct sits beside other team practices that shape how people work together. Contributing to open source often starts with a pull request, and maintainers may point newcomers to the code of conduct before they review the first change. If you want to learn that workflow, our guide on what is a pull request? explains the basic steps. The way a community handles disagreement also appears in how it reviews and merges code. Our article on how to contribute to open source? shows how newcomers can join a project in a respectful way.
For the official text, template options and translations, read the documentation at contributor-covenant.org. It is the best place to start if you plan to write your own document.
FAQ
Is a code of conduct the same as a license?
No. A license describes who may use, copy or change the code. A code of conduct describes how people should behave when they take part in the community around the code.
Do small projects need a code of conduct?
Not every project needs one, but a short document helps any group where strangers talk to each other. It gives newcomers clear expectations and gives maintainers a fixed reference when problems appear.
Can I change the Contributor Covenant text?
Yes. The project provides an interactive builder so you can choose a language, add your reporting details and set your enforcement policy. You can also adapt the wording to fit your community.
Who should receive reports under a code of conduct?
Name one or more people who are willing to read reports and act on them. Make sure the contact method works and that someone is responsible for it if the main maintainer is unavailable.
Sources
This page is based on the official documentation below. Read it for full detail.
Code of conduct — official documentation ↗