Groq Code CLI is a lightweight, open source command line programming tool that utilizes Groq's API to provide rapid AI code generation and interaction capabilities. The core idea of this project is not to be a huge application with heavy functionality that is difficult to maintain, but rather to serve as a base blueprint on which developers can easily modify, extend, and customize to create their own command line tool entirely. Developers can easily add new commands, integrate external tools, and even modify the visual elements of the interface. By simplifying the code base and reducing complexity, it encourages developers to dive in and customize the development according to their own workflow. For example, users can add advanced features such as code complexity analysis, automated testing, knowledge graph building, etc. on their own.
Function List
- Fast Interaction: Powered by Groq, enabling fast code generation and response.
- Command Line Chat:: In the terminal via the
groq
command starts an interactive chat session with the AI. - Height can be customized: Allows developers to easily add new slash commands and tools, providing detailed customization guidelines.
- API Key Management:: Support for the adoption of
/login
command or set environment variablesGROQ_API_KEY
to manage and authenticate users. - Model Selection: Users can use the
/model
command to view and select the different language models available on the Groq platform. - Session Management: Provided
/clear
command, you can clear the current chat history and context at any time. - parameterization: Support for adjusting the behavior of AI models through command line options, such as using the
-t
maybe--temperature
to set the diversity of generated content. - System message customization: Users can access the
-s
maybe--system
option provides customized system-level instructions to the AI at startup.
Using Help
Groq Code CLI is a command line tool for developers designed to provide a highly customizable and rapidly iterative AI programming environment. Here are detailed installation and usage instructions to help you get started quickly.
mounting
You can choose between two types of installation depending on your needs:
1. Quick trial (npx)
If you just want a quick taste of the tool and don't want to clone the entire codebase locally, you can use thenpx
command. This command will pull the latest stable version from the npm repository and run it directly without installing any files on your computer.
Open your terminal and enter the following command:
npx groq-code-cli@latest
Once executed, the Groq Code CLI will start and you can start using it straight away.
2. Local development and customization (recommended)
If you wish to modify this tool, add new features, or use it for a long period of time, the local development and installation mode is recommended. This mode will clone the project's source code in its entirety to your computer and allow you to make any changes to the code.
Step 1: Clone the code base
First, use thegit
Clone the project source code locally from GitHub.
git clone https://github.com/build-with-groq/groq-code-cli.git
Step 2: Enter the project catalog
utilizationcd
command into the folder you just cloned down.
cd groq-code-cli
Step 3: Install project dependencies
The project uses Node.js and you need to use thenpm install
command to install all required dependencies.
npm install
Step 4: Compile the project
Since the project is written in TypeScript, you will need to compile it to JavaScript to run it.
npm run build
Step 5: Link to the global command
In order to be able to pass any path in the computer'sgroq
command to invoke this tool, you need to use thenpm link
Command.
npm link
After executing this command, thegroq
command then becomes a globally available command.
Step 6 (optional): Enable automatic compilation
If you plan to make changes to the source code, you can run the development mode command. This command will monitor the file for changes and automatically recompile the file after you save it, saving you from having to manually execute thenpm run build
The
npm run dev
It is recommended to keep this command running in a separate terminal window.
First Time Users: Configuring API Keys
Whichever way you install it, you will need to configure your Groq API key the first time you run it.
- Start the tool in the terminal:
groq
- In the chat screen that launches, type
/login
command and press Enter. - The program will prompt you for your API key. You can get your free API key from the Groq Console.
- After entering the key, the program creates a file in your user home directory named
.groq
The hidden folder that holds the keys and other configuration information.
You can also provide the API key temporarily by setting an environment variable, which is useful in a continuous integration (CI) environment or for testing.
export GROQ_API_KEY=your_api_key_here
Main Functions
1. Starting a chat session
In any directory, simply type in the terminalgroq
You can start a conversation with the AI.
You can ask questions directly, or have it help you write code, explain concepts, etc.
2. Use of Slash Commands
In the chat screen, you can enter a name by typing in a name that starts with/
commands at the beginning to perform specific operations.
/help
: Displays all available commands and their descriptions./login
: Used to log in and set the API key./model
: Lists the currently available AI models and allows you to switch models./clear
: Clear the chat history of the current window and start a brand new conversation./reasoning
: Toggle whether or not to show the AI's thought process in its responses.
3. Use of command-line options
You can start thegroq
Add some options to control the behavior of the AI when commanding.
-t, --temperature <temp>
: Set the "temperature" of the generated content, which is a number between 0 and 2. Higher values (e.g. 1.2) will make the output more creative and random, while lower values (e.g. 0.5) will make the output more deterministic and consistent. The default value is 1.groq -t 0.7
-s, --system <message>
: Set a system message. This message will serve as the highest instruction to guide the AI's behavior throughout the session. For example, you can have it play a specific role.groq -s "你是一个资深的Go语言程序员,请只用Go语言回答问题。"
-d, --debug
: Enabling debug mode will output detailed log messages to the current directory of thedebug-agent.log
Documentation.-h, --help
: Displays a help message listing all available command line options.-V, --version
: Displays the currently installedgroq-code-cli
The version number of the
application scenario
- Daily coding assistance
At any time while writing code, developers can open a terminal and ask the Groq Code CLI questions such as, "How do I implement a quick sort algorithm in Python?" or "Write me a Node.js code snippet that connects to a Redis database". Thanks to its fast response time, you can significantly reduce the time spent looking for information in search engines and documentation. - Code Debugging and Interpretation
When encountering a piece of code that you don't understand or an error that is difficult to troubleshoot, you can paste the code or error message directly into the CLI and let the AI explain the logic of the code or provide possible causes of the error and suggestions for fixing it. - Learning new technologies
Beginners or developers looking to expand their technology stack can utilize it as an interactive learning tool. Questions can be asked about basic concepts and core usage of new frameworks and languages, and AI will provide structured explanations and code examples. - Automation scripting
For O&M staff or developers who need to write some simple scripts (e.g. Shell, Python) to automate daily tasks, they can directly use natural language to describe the requirements, for example, "Write a script to delete all the .log files in the current directory that are older than 30 days", and AI can quickly generate usable scripts. - Building Personalized Development Tools
Premium users and developer teams can perform secondary development based on the Groq Code CLI, integrating information such as the team's internal knowledge base, API documentation, and code specifications, or adding functionality to interact with internal systems (e.g., CI/CD, project management tools) to create a proprietary CLI tool that matches the team's specific workflow.
QA
- Is this tool free?
Groq Code CLI itself is open source and free, and you can get its full source code on GitHub. However, it relies on the AI modeling services provided by the Groq Cloud Platform, and you need to get the API key from the official Groq website. Usually Groq provides a certain amount of free usage for new users, beyond which you need to pay. - Do I need to know programming to use it?
No programming knowledge is required for basic use, you can talk to it like a chat tool to get information and code. However, its core value lies in its customizability, and if you want to modify or extend its functionality, then some knowledge of Node.js and TypeScript programming is required. - How is it different from other AI programming tools?
The biggest difference is its design philosophy. While many AI programming tools aim to be big and full-featured, the code is complex and difficult to modify, the Groq Code CLI goes in the opposite direction, deliberately keeping it light and simple, positioning itself as a "blueprint" or "framework" that encourages the user to do the customization and extensions on their own. Its core strengths are high customizability and low latency. - How to add a new command like
/test
?
You'll need to set up thesrc/commands/definitions/
directory to create atest.ts
file, in which the behavior of the command is defined, and then in thesrc/commands/index.ts
file to register this new command. Detailed development documentation is provided in the project's README file, and the guidelines are very clear.