Overseas access: www.kdjingpai.com
Ctrl + D Favorites

Grok CLI is an open source terminal AI assistant developed based on xAI's Grok-3 model. It allows users to complete file manipulation, code editing and task automation from the command line through natural language interaction. Users do not need to enter complex commands , just use everyday language to describe the needs , Grok CLI will be able to intelligently select tools and perform tasks . The project is maintained by the superagent-ai team, hosted on GitHub, and supports global installations and custom configurations for developers, operations staff, and users who need an efficient terminal. The code follows the MIT license and is freely contributed to by the community.

 

Function List

  • Natural Language Interaction: By interacting with the terminal through everyday conversations, the Grok CLI understands the user's intent and performs actions accordingly.
  • Intelligent file operations: automatically view, create, and edit files, support batch processing and complex file operations.
  • Bash Command Integration: Simplify terminal operations by executing shell commands directly in the dialog.
  • Automatic Tool Selection: According to the user's needs, AI intelligently selects the appropriate tool to complete the task.
  • Interactive Interface: Build a beautiful terminal interface based on Ink to enhance user experience.
  • Customized configuration: support through .grok/GROK.md The file sets project-specific behavior rules.
  • Code generation and editing: automatically generate code files (e.g. TypeScript) and follow the project code style.
  • Project Management: Supports development tasks such as viewing directory structure, running tests, and executing lint.

Using Help

Installation process

The Grok CLI is easy to install and supports global installation via npm. Here are the detailed steps:

  1. Ensuring the environment
    Make sure you have Node.js (recommended version 16 or higher) and npm installed on your system. this can be checked with the following command:

    node -v
    npm -v
    
  2. Install Grok CLI globally
    Open a terminal and run the following command:

    npm i -g @vibe-kit/grok-cli
    

    Once installed, the Grok CLI is ready to use in any directory.

  3. Verify Installation
    Enter the following command to check if the installation was successful:

    grok --version
    

    If the version number is returned, the installation was successful.

  4. Configuring the API key (optional)
    Some features may require an API key for xAI. After getting the key, run it:

    grok config set api-key <你的密钥>
    

    The key is stored locally for the Grok CLI to call the Grok-3 model.

Usage

The core of Grok CLI is to interact with the terminal through natural language. Once launched, you can directly enter commands similar to everyday conversations, and the AI will parse and execute them. Below is a detailed flow of the main functions:

1. Natural language interaction

Start the Grok CLI and run it:

grok

When you enter the interactive mode, you enter the requirement directly. Example:

  • Type "Show the contents of package.json" and the Grok CLI will execute something like this cat package.json command and returns the result.
  • Type "Create a hello.js file, write to console.log('Hello World')" and the Grok CLI will automatically create the file and write the code.

2. Intelligent file manipulation

The Grok CLI supports a variety of file operations suitable for quickly managing project files. For example:

  • View Document: Enter "View the contents of src/index.ts" and the Grok CLI will display the contents of the file.
  • Creating Documents: Type "Create a new utils.ts file containing an addition function" and the Grok CLI will generate the file and write the code, for example:
    /** Add two numbers */
    export function add(a: number, b: number): number {
    return a + b;
    }
    
  • Batch Replacement: Enter "Replace oldFunction with newFunction in all JS files" and the Grok CLI will traverse the directory and complete the replacement.

3. Bash command integration

The Grok CLI supports direct execution of shell commands. For example:

  • Type "run npm install" and the Grok CLI will execute the npm install and display the results.
  • Type "show current directory structure" and the Grok CLI will run something like this tree maybe ls -R command that returns the directory tree.

4. Automatic tool selection

The Grok CLI intelligently selects tools based on the task. For example, type "run tests and show results" and it will automatically recognize the test frameworks in your project (e.g. Jest or Mocha) and run them! npm testThe

5. Customized configuration

The Grok CLI supports custom rules at the project level. Creating a .grok/GROK.md file, writing instructions, for example:

# Custom Instructions for Grok CLI
- Always use TypeScript for new code files.
- Use functional components with hooks for React.
- Add JSDoc comments for public functions.

The Grok CLI automatically loads these rules in the project directory. For example, when generating React components, function components are used in preference to class components.

6. Development of mission support

The Grok CLI is suitable for developers to perform common tasks. For example:

  • Run linter: By typing "run lint check", the Grok CLI will execute the npm run lintThe
  • Type checking: Enter "Check TypeScript type" and the Grok CLI will run npm run typecheckThe
  • Project construction: Enter "build project" and the Grok CLI will run the npm run buildThe

caveat

  • network requirement: Some functions require networking to call Grok-3 models.
  • Competence issues: Ensure that you have read and write permissions to files and directories, otherwise the operation may fail.
  • Debug Log: If you encounter problems, you can run grok --debug View detailed logs.

By doing the above, users can quickly get started with Grok CLI and utilize natural language to accomplish terminal tasks efficiently. [](https://github.com/superagent-ai/grok-cli)

application scenario

  1. Daily coding for developers
    Developers can quickly create and edit code files, run tests, or build projects in natural language from the terminal. For example, when developing a React project, type in "Create a new React component in TypeScript" and the Grok CLI will generate a code file that conforms to the project's rules.
  2. O&M task automation
    System administrators can use the Grok CLI to perform bulk file operations or run shell scripts. For example, enter "Find all log files and delete files older than 30 days" and the Grok CLI will automatically generate and execute the appropriate commands.
  3. Learning and experimentation
    Beginners can learn terminal commands through the Grok CLI. For example, if you type "Explain the ls command", Grok CLI will return the command description and show you how to use it.
  4. Open Source Project Contribution
    Contributors can use Grok CLI to quickly navigate and modify open source project code. For example, type "Find all TODO comments" and Grok CLI will scan the code and list the relevant locations.

QA

  1. Does the Grok CLI require an xAI API key?
    Some features require an API key to call Grok-3 models, but the base functionality can be run locally. Keys can be obtained and configured via the xAI website.
  2. How can I customize Grok CLI behavior in my project?
    In the project root directory, create the .grok/GROK.md file, and write rules such as "Always use TypeScript"; the Grok CLI loads these rules automatically.
  3. Which operating systems does Grok CLI support?
    The Grok CLI is supported on Windows, macOS, and Linux, and is ready to run with Node.js installed.
  4. Is it possible to use Grok CLI offline?
    Some features (such as file operations and local commands) are supported offline, but AI-driven features require an Internet connection.
0Bookmarked
0kudos

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

inbox

Contact Us

Top

en_USEnglish