Why do I need a code of conduct?
A code of conduct is a document that establishes expectations for behavior for your project’s participants. Adopting, and enforcing, a code of conduct can help create a positive social atmosphere for your community.
Codes of conduct help protect not just your participants, but yourself. If you maintain a project, you may find that unproductive attitudes from other participants can make you feel drained or unhappy about your work over time.
A code of conduct empowers you to facilitate healthy, constructive community behavior. Being proactive reduces the likelihood that you, or others, will become fatigued with your project, and helps you take action when someone does something you don’t agree with.
Establishing a code of conduct
Try to establish a code of conduct as early as possible: ideally, when you first create your project.
In addition to communicating your expectations, a code of conduct describes the following:
- Where the code of conduct takes effect (only on issues and pull requests, or community activities like events?)
- Whom the code of conduct applies to (community members and maintainers, but what about sponsors?)
- What happens if someone violates the code of conduct
- How someone can report violations
Wherever you can, use prior art. The Contributor Covenant is a drop-in code of conduct that is used by over 40,000 open source projects, including Kubernetes, Rails, and Swift.
Place a CODE_OF_CONDUCT file in your project’s root directory, and link to it from your README, so it’s visible to your community.
Deciding how you’ll enforce your code of conduct
You should explain how your code of conduct will be enforced before a violation occurs. There are several reasons to do so:
It demonstrates that you are serious about taking action when it’s needed.
Your community will feel more reassured that complaints actually get reviewed.
You’ll reassure your community that the review process is fair and transparent, should they ever find themselves investigated for a violation.
You should give people a private way (such as an email address) to report a code of conduct violation and explain who receives that report. It could be a maintainer, a group of maintainers, or a code of conduct working group.
Don’t forget that someone might want to report a violation about a person who receives those reports. In this case, give them an option to report violations to someone else. For example, @ctb and @mr-c explain on their project, khmer:
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by emailing email@example.com which only goes to C. Titus Brown and Michael R. Crusoe. To report an issue involving either of them please email Judi Brown Clarke, Ph.D. the Diversity Director at the BEACON Center for the Study of Evolution in Action, an NSF Center for Science and Technology.*
For inspiration, check out Django’s enforcement manual (though you may not need something this comprehensive, depending on the size of your project).
Enforcing your code of conduct
Sometimes, despite your best efforts, somebody will do something that violates this code. There are several ways to address negative or harmful behavior when it comes up.
Gather information about the situation
Treat each community member’s voice as important as your own. If you receive a report that someone violated the code of conduct, take it seriously and investigate the matter, even if it does not match your own experience with that person. Doing so signals to your community that you value their perspective and trust their judgment.
The community member in question may be a repeat offender who consistently makes others feel uncomfortable, or they may have only said or done something once. Both can be grounds for taking action, depending on context.
Before you respond, give yourself time to understand what happened. Read through the person’s past comments and conversations to better understand who they are and why they might have acted in such a way. Try to gather perspectives other than your own about this person and their behavior.
Take appropriate action
After gathering and processing sufficient information, you’ll need to decide what to do. As you consider your next steps, remember that your goal as a moderator is to foster a safe, respectful, and collaborative environment. Consider not only how to deal with the situation in question, but how your response will affect the rest of your community’s behavior and expectations moving forward.
When somebody reports a code of conduct violation, it is your, not their, job to handle it. Sometimes, the reporter is disclosing information at great risk to their career, reputation, or physical safety. Forcing them to confront their harasser could put the reporter in a compromising position. You should handle direct communication with the person in question, unless the reporter explicitly requests otherwise.
There are a few ways you might respond to a code of conduct violation:
Give the person in question a public warning and explain how their behavior negatively impacted others, preferably in the channel where it occurred. Where possible, public communication conveys to the rest of the community that you take the code of conduct seriously. Be kind, but firm in your communication.
Privately reach out to the person in question to explain how their behavior negatively impacted others. You may want to use a private communication channel if the situation involves sensitive personal information. If you communicate with someone privately, it’s a good idea to CC those who first reported the situation, so they know you took action. Ask the reporting person for consent before CCing them.
Sometimes, a resolution cannot be reached. The person in question may become aggressive or hostile when confronted or does not change their behavior. In this situation, you may want to consider taking stronger action. For example:
Suspend the person in question from the project, enforced through a temporary ban on participating in any aspect of the project
Permanently ban the person from the project
Banning members should not be taken lightly and represents a permanent and irreconcilable difference of perspectives. You should only take these measures when it is clear that a resolution cannot be reached.
Your responsibilities as a maintainer
A code of conduct is not a law that is enforced arbitrarily. You are the enforcer of the code of conduct and it’s your responsibility to follow the rules that the code of conduct establishes.
As a maintainer you establish the guidelines for your community and enforce those guidelines according to the rules set forth in your code of conduct. This means taking any report of a code of conduct violation seriously. The reporter is owed a thorough and fair review of their complaint. If you determine that the behavior that they reported is not a violation, communicate that clearly to them and explain why you’re not going to take action on it. What they do with that is up to them: tolerate the behavior that they had an issue with, or stop participating in the community.
A report of behavior that doesn’t technically violate the code of conduct may still indicate that there is a problem in your community, and you should investigate this potential problem and act accordingly. This may include revising your code of conduct to clarify acceptable behavior and/or talking to the person whose behavior was reported and telling them that while they did not violate the code of conduct, they are skirting the edge of what is expected and are making certain participants feel uncomfortable.
In the end, as a maintainer, you set and enforce the standards for acceptable behavior. You have the ability to shape the community values of the project, and participants expect you to enforce those values in a fair and even-handed way.
Encourage the behavior you want to see in the world 🌎
When a project seems hostile or unwelcoming, even if it’s just one person whose behavior is tolerated by others, you risk losing many more contributors, some of whom you may never even meet. It’s not always easy to adopt or enforce a code of conduct, but fostering a welcoming environment will help your community grow.