Skip to content

How to add contributors using the All Contributors Command Line Interface (CLI)

You can use the add command to add a contributor and their contribution types to your .all-contributorsrc file. This will also regenerate your contributor table.

You can run add in two ways:

  • With arguments: pass the username and contribution types directly after the command. This approach supports using the CLI in scripts and if you prefer a direct CLI command to quickly add contributors to your project.
  • With prompts: leave out some or all of the details in the command, and the CLI prompts you or walks you through the rest. If you use the prompts, you don’t need to remember the syntax or contribution-type keywords.

To add a contributor using a command only, pass the username and a comma-separated list of contributions. The keywords options are listed in the emoji key, and the username comes from the users GitHub or GitLab account. The call will look something like this:

all-contributors add jfmengels doc,code

The CLI needs internet access to add a new contributor because it fetches their name, avatar, and profile link from the host (GitHub or GitLab). If a keyword you pass isn’t valid, the CLI ignores it. If none of the keywords are valid, the command fails with a message that lists the invalid ones.

If you only call all-contributors add and leave out the username, the contributions, or both, then the CLI will for the missing username and contribution keywords:

? What is the contributor's GitHub username? lwasser
? What are the contribution types? 💻 Code, 📖 Documentation

The contribution types are a list that you move through with the arrow keys and select with the space bar. When you run all-contributors without any command, a menu lets you choose between adding a contributor, regenerating the list and checking for missing contributors.

Adding someone who is already in the list updates their entry, and the match on the username ignores capitalization. There are two cases:

  • If you list a contribution they don’t have yet, the CLI adds it and keeps the others.
  • If you list fewer contributions than they have and at least one of them is already theirs, the CLI replaces their contributions with the ones you listed. This is how you remove a contribution: for someone credited for code and doc, add jane code leaves only code.

In the interactive prompt, the contributions the person already has are selected from the start. Deselect one to remove it. The prompt refuses a selection that matches what the person already has and asks you to change something.

Pass --url to make the contributions you add link to a specific page, such as the pull request or the blog post. The emoji in the table then points to that address instead of the default:

all-contributors add jfmengels blog --url https://example.org/posts/hello

After the entry is saved, the CLI regenerates the table and the badge in every file listed under files, the same as the generate command. If commit is set to true in your configuration, it also commits the result.