Cwai
AI-powered conventional commit message generator from staged git changes
Install / Use
/learn @nikmd1306/CwaiREADME
What is cwai?
cwai is a command-line tool that writes git commit messages for you. It looks at your staged changes (git add), sends them to an AI model, and generates a clear, well-formatted Conventional Commits message. You can accept it, edit it, or ask for a new one. All you need is an API key from any OpenAI-compatible provider.
Features
- Generates Conventional Commits messages from
git diff - Works with any OpenAI-compatible API (OpenAI, Anthropic, local models)
- Two modes: interactive standalone or silent
prepare-commit-msghook - Structured output support for consistent formatting
- Smart diff truncation to fit model token limits
Prerequisites
-
Git installed and available in your terminal
-
API key from one of these providers (or any OpenAI-compatible API):
| Provider | Get your key | |----------|-------------| | OpenAI | https://platform.openai.com/api-keys | | OpenRouter | https://openrouter.ai/keys | | DeepSeek | https://platform.deepseek.com/api_keys |
You can also use local models via Ollama or LM Studio — no API key needed, just point
CWAI_API_URLto your local server.
Installation
Quick install (Linux / macOS)
curl -fsSL https://raw.githubusercontent.com/nikmd1306/cwai/main/install.sh | bash
To install to a custom directory:
curl -fsSL https://raw.githubusercontent.com/nikmd1306/cwai/main/install.sh | bash -s -- -b ~/.local/bin
Note: The default install path
/usr/local/binrequiressudo. If you prefer to install withoutsudo, use~/.local/binand make sure it's in yourPATH:echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc source ~/.bashrcFor zsh, replace
~/.bashrcwith~/.zshrc.
go install
Requires Go 1.23+.
go install github.com/nikmd1306/cwai@latest
Note: Ensure
$(go env GOPATH)/binis in yourPATH:export PATH="$PATH:$(go env GOPATH)/bin"
Windows
Download the Windows zip from Releases, extract cwai.exe, and add its folder to your PATH. Or, if you have Go installed:
go install github.com/nikmd1306/cwai@latest
Binary releases
Download pre-built binaries from Releases.
From source
git clone https://github.com/nikmd1306/cwai.git
cd cwai
make install
Quick Start
-
Set up your API key (one-time):
cwai setupThe wizard will ask for your API key, provider URL, model, and language. See Prerequisites for where to get an API key.
-
Stage your changes:
git add . -
Generate a commit message:
cwaicwai will show the staged files, generate a message, and let you accept, edit, regenerate, or cancel.
Tip: Use
cwai -yto auto-accept the generated message (useful in CI/scripts).
Standalone mode
$ cwai
Staged files (3):
internal/ai/client.go
internal/prompt/prompt.go
cmd/root.go
Generated commit message:
feat(ai): add structured output support for commit generation
[y]es / [e]dit / [r]egenerate / [n]o:
Hook mode
cwai hook set # Install prepare-commit-msg hook
cwai hook unset # Remove hook
Configuration
Config file: ~/.cwai (INI format). Use cwai config set KEY VALUE or cwai setup.
Essential settings
| Key | Description | Default |
|-----|-------------|---------|
| CWAI_API_KEY | API key from your provider (required) | not set |
| CWAI_API_URL | Base URL of the AI API | https://api.openai.com/v1 |
| CWAI_MODEL | Model to use for generation | gpt-5-mini |
| CWAI_LANGUAGE | Commit message language (ISO 639-1: en, de, fr, es, ...) | en |
Advanced settings
| Key | Description | Default |
|-----|-------------|---------|
| CWAI_MAX_TOKENS_INPUT | Max input tokens for diff (higher = more context, more cost) | 4096 |
| CWAI_MAX_TOKENS_OUTPUT | Max output tokens for response | 500 |
| CWAI_TEMPERATURE | Sampling temperature (0.0 = deterministic, 1.0 = creative) | not set |
| CWAI_REASONING_EFFORT | Reasoning effort for reasoning models (low, medium, high) | not set |
| CWAI_VERBOSITY | Output verbosity level | not set |
| CWAI_STRUCTURED_OUTPUT | Enable structured JSON output (true/false) | not set |
Troubleshooting
| Error | Cause | Solution |
|-------|-------|----------|
| CWAI_API_KEY is not set | No API key configured | Run cwai setup or cwai config set CWAI_API_KEY <your-key> |
| API error (HTTP 401) | Invalid or expired API key | Regenerate your key at your provider's dashboard |
| API error (HTTP 429) | Rate limit exceeded | Wait a moment and try again, or upgrade your API plan |
| no staged changes | Nothing added to git staging area | Run git add <files> before running cwai |
| not a git repository | cwai was run outside a git repo | Navigate to a git repository first (cd your-project) |
| cwai: command not found | Binary not in PATH | See Installation for PATH setup instructions |
Contributing
See CONTRIBUTING.md for development setup and guidelines.
License
Related Skills
apple-reminders
354.0kManage Apple Reminders via remindctl CLI (list, add, edit, complete, delete). Supports lists, date filters, and JSON/plain output.
gh-issues
354.0kFetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5] [--notify-channel -1002381931352]
healthcheck
354.0kHost security hardening and risk-tolerance configuration for OpenClaw deployments
node-connect
354.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
