blog > setting-up-and-using-the-ai-commits-npm-package

Using the AI Commits NPM Package

by Yashlin Naidoo
Published on: 5/19/2023

Introduction

Artificial Intelligence (AI) is a technology that’s increasingly being integrated into various aspects of our daily lives. One area where AI has made significant progress is in the field of software development. The AI Commits NPM package is a tool that leverages AI to improve the software development process by suggesting commit messages based on code changes. In this blog post, we’ll discuss how to use the AI Commits NPM package and the benefits it provides for developers.

Pre-requisites

To utilize AI commits, you will need to set up an OpenAI API Key. If you have not already done so, you can register for an account and set up a key at https://platform.openai.com/account/api-keys.

Important:

While this is a paid service, it is usage-based and in my personal experience, it has not yet reached the $1 mark. However, your usage may vary, so it is recommended to set up usage limits on your OpenAI billing page to ensure that you do not incur unexpected charges.

Installation and Usage

To use the AI Commits NPM package, you will need to have Node.js installed on your computer. Once you have Node.js, you can install the package using the following command:

npm install -g ai-commits

Once you’ve installed the package you can then configure your OPENAI Api Key

aicommits config set OPENAI_KEY=<your token>

This will create a .aicommits file in your home directory.

You can then confirm your installation by calling the version command

aicommits --version


After installation, using the package is as simple as navigating to your project’s directory and running the following command:

ai-commits

The package will then analyze your staged code changes and suggest commit messages based on its findings. You can then choose to accept the suggested message or modify it to better fit your needs.

If you want to use aicommits to automatically stage changes for you as well as suggest commit messages based on those changes you can pass additional flags to your aicommits command

aicommits --all # or -a

Conclusion

The AI Commits NPM package is a powerful tool that can help developers streamline the software development process. By automating the task of coming up with descriptive commit messages, the package can save time and improve project organization. Additionally, by using AI to analyze code changes, the package can suggest more accurate and relevant commit messages than a human might be able to come up with on their own. If you’re a developer looking to improve your workflow, the AI Commits NPM package is definitely worth checking out.

https://www.npmjs.com/package/aicommits?activeTab=readme

WRITTEN BY

Yashlin Naidoo