July 29, 2017 | 9 min Read
A README file is the first thing that someone encounters when he finds your project. It’s a public-facing measure of your work, so it’s definitely a good idea to spend some time reading articles and guidelines about how to write it well. Other developers and your future self will thank you for a well-crafted README.
For every hour of code you write, spend an hour writing your README.
There are many great resources about how to write a good README. Here I will summarize what I learned and add my perspective.
I think that most articles miss the point that for different project types you need to structure the README in a different way, and to include different type of information.
I can think about the following project types:
I will try to describe, including some examples for each category, how a good README looks like.
Stephen Whitmore, author of The Art of README, and Ken Williams, a PERL developer, say that a README is an abstraction for your project:
Your documentation is complete when someone can use your module without ever having to look at its code. This is very important. This makes it possible for you to separate your module’s documented interface from its internal implementation (guts). This is good because it means that you are free to change the module’s internals as long as the interface remains the same.
Remember: the documentation, not the code, defines what a module does.
— Ken Williams
Tom Preston Warner even suggests to writing the README first. I have never tried, but Tom’s reasons are very well sound: writing a README first gives you clarity about what you actually want to build, and lets you avoid some pitfalls when you start writing code.
A developer who reads your README should be able to answer these questions:
Let’s see how you can answer each one of these.
Ideally, your project name should be self-explanatory, and your project description should be a one-liner. You have to showing what your project is all about. Answer this question first, so if a developer discovers that your project is not what he needs, he can quickly move on. Write an Introduction and a Usage section to answer this question.
[The Introduction] should be a few sentences that explain exactly what the purpose of the code is, why someone would want to use it, and how it works. Answer the what, why, and the how.
Have a look at the README of Pipenv. In half a page you can see a short description, an animated GIF, a list of features and user testimonials. In a few seconds you can understand if this is something that you may want to use or not.
Everyone loves animated GIFs, and I think they are far superior to screenshots when it comes to show your project in action. If it’s applicable to your project, include an animated GIF. There are several tools for creating a GIF from a screen capture. I use
Some big projects heavily rely on nice screenshots and GIFs. For example, Superset includes a ton of screenshots to make you want to try it out, and add a link to the extensive documentation for installation and configuration.
I don’t think that a list of user testimonials is that important, but you should definitely include a list of features to give other developers a clear picture of what your project does.
You should include a section for the installation/configuration of your project and a section for some common usage. Be clear about your project requirements and dependencies. Does your project work only on Ubuntu? Have you tried on Windows or on a Mac?
You should write which license your project is using. You can also omit this information in the README and include a LICENSE file instead, but adding the license type (not the entire text!) to the README doesn’t hurt. If you have a non-permissive license, stick it at the very top.
The first thing I look when I find a new project is the date of the last commit. This gives me an idea whether the project is still maintained or not.
Build badges and Continuous Integration can help you if you want to gain more trust from other developers. If your project becomes popular, you can also add a badge that shows the number of downloads per month. This could give you some social validation and persuade other developers to adopt your project. Badges look cool and you might overdo here. For each badge, consider: “what real value is this badge providing to the typical viewer of this README?”
A developer might have additional questions about your project. Don’t forget to include some contact details (email, Twitter).
If you are aware of similar projects you can list them and maybe add a brief comparison with your project. For example, have a look at Cookiecutter. I don’t think it makes sense to add a very detailed comparison with other projects. Maybe you can write an article on your blog and link it in the README.
If your project grows, you could add a FAQ section and a How to Contribute section.
What about the changelog? I think that the information in the changelog is too detailed and not of much use for someone who sees your project for the first time. If we accept a README as an abstraction, it doesn’t really make sense to include a changelog in it. I think it’s better to have the changelog in a different file. Also, keep in mind that if your project grows the changelog will take too much space in the README.
The README for a project starter is very similar to the one of a library.
When I find a project starter I look for these things:
A good example of a project starter is Cookiecutter Django, even if it lacks a screenshot of the web app. I also like Cookiecutter Flask, which is a lot less verbose and shows a nice screenshot of the project.
In a project clone, a screenshot / GIF is even more important. Have a look at a Hacker News clone website built with Vue.js. See the difference between the boring, older version, and the shiny, more recent version. The older version has a brief set of instructions how to install it, run it, and includes a link to the Live demo. The newer version adds a nice screenshot, a list of features and an architecture overview.
With “Cookbook repository” I mean a repository where you have a set of small, standalone modules. You can call them recipes. Each recipe is independent of the other ones and performs a specific task, solves a particular problem or shows how to use a particular library across different scenarios.
A good example of cookbook repository is Search-Script-Scrape: 101 webscraping and research tasks for the data journalist. Each script focuses on a single task and can be used independently: you run it and it prints the answer you are looking for.
Another good example is Machine Learning From Scratch, which contains bare bones Python implementations of some of the fundamental Machine Learning models and algorithms.
The most important things in a cookbook repository are:
Keep in mind that on GitHub you can define a README in each directory, so you can include the necessary information where it is more relevant.
├── README.md ├── sectionA │ ├── README.md │ ├── recipeA1.py │ ├── recipeA2.py │ └── recipeA3.py ├── sectionB │ ├── README.md │ ├── recipeB1.py │ └── recipeB2.py └── requirements.txt
Sometimes a repository is just a curated list of resources: a list of links and short descriptions, and basically no code. With this category, I’m referring to all the repositories created with Awesome. Using a repository for a curated list of resources is a great idea, because this way if you care about a topic, you can easily share your knowledge with other developers. Everyone can contribute by adding links to the articles that he finds interesting.
In this kind of repository, the README is the repository, and most of what is valid for the other types of repositories is just not applicable. However, here is what I would like to find:
I wrote this article after reading several articles on how to write a great README. Here are the ones that you have to read: