# grok-cli **Repository Path**: mirrors_trending/grok-cli ## Basic Information - **Project Name**: grok-cli - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-23 - **Last Updated**: 2025-07-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Grok CLI A conversational AI CLI tool powered by Grok with intelligent text editor capabilities and tool usage. Screenshot 2025-07-21 at 13 35 41 ## Features - **🤖 Conversational AI**: Natural language interface powered by Grok-3 - **📝 Smart File Operations**: AI automatically uses tools to view, create, and edit files - **⚡ Bash Integration**: Execute shell commands through natural conversation - **🔧 Automatic Tool Selection**: AI intelligently chooses the right tools for your requests - **💬 Interactive UI**: Beautiful terminal interface built with Ink - **🌍 Global Installation**: Install and use anywhere with `npm i -g @vibe-kit/grok-cli` ## Installation ### Prerequisites - Node.js 16+ - Grok API key from X.AI ### Global Installation (Recommended) ```bash npm install -g @vibe-kit/grok-cli ``` ### Local Development ```bash git clone cd grok-cli npm install npm run build npm link ``` ## Setup 1. Get your Grok API key from [X.AI](https://x.ai) 2. Set up your API key (choose one method): **Method 1: Environment Variable** ```bash export GROK_API_KEY=your_api_key_here ``` **Method 2: .env File** ```bash cp .env.example .env # Edit .env and add your API key ``` **Method 3: Command Line Flag** ```bash grok --api-key your_api_key_here ``` **Method 4: User Settings File** Create `~/.grok/user-settings.json`: ```json { "apiKey": "your_api_key_here" } ``` ### Custom Base URL (Optional) You can configure a custom Grok API endpoint (choose one method): **Method 1: Environment Variable** ```bash export GROK_BASE_URL=https://your-custom-endpoint.com/v1 ``` **Method 2: Command Line Flag** ```bash grok --api-key your_api_key_here --baseurl https://your-custom-endpoint.com/v1 ``` **Method 3: User Settings File** Add to `~/.grok/user-settings.json`: ```json { "apiKey": "your_api_key_here", "baseURL": "https://your-custom-endpoint.com/v1" } ``` ## Usage ### Interactive Mode Start the conversational AI assistant: ```bash grok ``` Or specify a working directory: ```bash grok -d /path/to/project ``` ### Headless Mode Process a single prompt and exit (useful for scripting and automation): ```bash grok --prompt "show me the package.json file" grok -p "create a new file called example.js with a hello world function" grok --prompt "run npm test and show me the results" --directory /path/to/project ``` This mode is particularly useful for: - **CI/CD pipelines**: Automate code analysis and file operations - **Scripting**: Integrate AI assistance into shell scripts - **Terminal benchmarks**: Perfect for tools like Terminal Bench that need non-interactive execution - **Batch processing**: Process multiple prompts programmatically ### Model Selection You can specify which AI model to use with the `--model` parameter: ```bash # Use Grok models grok --model grok-4-latest grok --model grok-3-latest grok --model grok-3-fast # Use other models (with appropriate API endpoint) grok --model gemini-2.5-pro --base-url https://api-endpoint.com/v1 grok --model claude-sonnet-4-20250514 --base-url https://api-endpoint.com/v1 ``` ### Command Line Options ```bash grok [options] Options: -V, --version output the version number -d, --directory set working directory -k, --api-key Grok API key (or set GROK_API_KEY env var) -u, --base-url Grok API base URL (or set GROK_BASE_URL env var) -m, --model AI model to use (e.g., grok-4-latest, grok-3-latest) -p, --prompt process a single prompt and exit (headless mode) -h, --help display help for command ``` ### Custom Instructions You can provide custom instructions to tailor Grok's behavior to your project by creating a `.grok/GROK.md` file in your project directory: ```bash mkdir .grok ``` Create `.grok/GROK.md` with your custom instructions: ```markdown # Custom Instructions for Grok CLI Always use TypeScript for any new code files. When creating React components, use functional components with hooks. Prefer const assertions and explicit typing over inference where it improves clarity. Always add JSDoc comments for public functions and interfaces. Follow the existing code style and patterns in this project. ``` Grok will automatically load and follow these instructions when working in your project directory. The custom instructions are added to Grok's system prompt and take priority over default behavior. ## Example Conversations Instead of typing commands, just tell Grok what you want to do: ``` 💬 "Show me the contents of package.json" 💬 "Create a new file called hello.js with a simple console.log" 💬 "Find all TypeScript files in the src directory" 💬 "Replace 'oldFunction' with 'newFunction' in all JS files" 💬 "Run the tests and show me the results" 💬 "What's the current directory structure?" ``` ## Development ```bash # Install dependencies npm install # Development mode npm run dev # Build project npm run build # Run linter npm run lint # Type check npm run typecheck ``` ## Architecture - **Agent**: Core command processing and execution logic - **Tools**: Text editor and bash tool implementations - **UI**: Ink-based terminal interface components - **Types**: TypeScript definitions for the entire system ## License MIT