Introducing the Cloving CLI

Updated on July 22, 2024

AI Tools
Lucas Carlson Cloved by Lucas Carlson and ChatGPT 4o
Introducing the Cloving CLI

When I first heard about Generative Pre-training Transformers (GPTs), I thought, “I wonder if it can write code!!!”

But as soon as tried, I was quickly disappointed.

My main issues with GPT-generated code are:

  1. Accuracy and Correctness: The generated code might contain logical errors that aren’t immediately obvious.
  2. Context and Specificity: They miss important context about the specific requirements, existing codebase, or project constraints.
  3. Best Practices and Security: Outdated practices, code that doesn’t adhere to the latest best practices or use the most modern syntax.

These problems were a complete show-stopper for me for anything other than a code snippet auto-complete function.

So, I thought GPTs were cool for the first year of using them, but the promise didn’t match the hype.

Light bulb 💡

Finally, as the GPT context windows started to grow—first thousands of tokens, then tens of thousands of tokens, and now millions of tokens—I realized I could enhance my prompts with more details until I could generate code that finally worked.

I started building sophisticated projects with AI’s help. Projects that used to take 3 weeks could now take 2 days. It felt like 1996 all over again; all the promises of possibilities were opening up in front of my eyes.

I was building Terraform scripts and implementing i18n faster and easier than I had ever done it before.

But building working prompts was hard work. There was a lot of copying and pasting, a lot of context, a lot of files, a lot of showing the AI example outputs, and constant reminders of the coding practices I wanted to maintain in my project.

Code that can help me code

I got so fed up with copying and pasting that one day, I finally realized that I could build a CLI tool to help me create these complex prompts.

After all, isn’t that what code is best at? Automating repetitive tasks like copy-pasting and generating large text programmatically.

What is the Cloving CLI?

The cloving cli is a command line utility that delivers on the promise of generating code with AI.

It is built in Typescript and supports local and remote LLM providers (at the time of this writing: ollama, openai, gemini, and mistral but more coming quickly).

It can do really amazing things like this:

$ cloving generate shell --prompt "Create a Next.js app called todolist"
$ cd todolist
$ cloving init
$ cloving generate code --prompt "Build me a dynamic todo list web app with tailwind styled with a green theme"
? Enter the relative path of a file or directory you would like to include as context (or press enter to continue):
? Do you want to review the ~762 token prompt before sending it to https://api.openai.com/v1/chat/completions? yes
? Do you want to continue? yes
Certainly! Here's the code for the requested functionality:

1. **src/app/layout.tsx**

```tsx
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import './globals.css'

const inter = Inter({ subsets: ['latin'] })

export const metadata: Metadata = {
  title: 'Green Todo List',
  description: 'A dynamic todo list with a green theme',
}
...

? What would you like to do? Save All Source Code Files
src/app/layout.tsx has been saved.
All files have been saved.

How does it work?

When you initialize the cloving cli in a project with cloving init it will generate a cloving.json file (you can look at cloving’s own cloving.json file on github). This analyzes your project to figure out all the context of what you are trying to accomplish and summarizes it in a JSON file that can be referenced for building more and more complex contexts for generated prompts.

Try it out

You can install cloving globally by running npm install cloving -g or if you just want to try it without installing it, you can run npx cloving and be off to the races.

You can read the docs to figure out all the different ways you can use cloving. You can currently:

  • Generate code (cloving generate code)
  • Generate commit messages (cloving commit) you can see generated commit messages on github
  • Generate code reviews (cloving generate review)
  • Generate shell commands (cloving generate shell)
  • Generate unit tests (cloving generate unit-tests -f path/to/file/that/needs/tests.ts)

And I plan to write tutorials and examples of incorporating the cloving tool on this blog.

Subscribe to our Newsletter

This is a weekly email newsletter that sends you the latest tutorials posted on Cloving.ai, we won't share your email address with anybody else.