commit-now-myfriend
v0.1.4
Published
AI-assisted Git commit workflow CLI.
Readme
commit-now-myfriend
AI-assisted Git commit workflow from your terminal.
cnm inspects your staged diff, generates a commit message with your AI provider, then lets you confirm, edit, regenerate, or cancel.
Quick Start · Configuration · CLI Reference · Troubleshooting
Why use it?
Writing good commit messages is valuable, but it can interrupt the flow. commit-now-myfriend keeps the workflow in Git: stage your changes, run cnm, review the generated message, and commit only when you approve it.
Key features:
- Generates commit messages from staged Git diffs and changed file metadata.
- Learns repository style from recent commits when
promptStyleisauto. - Supports OpenAI Responses, Anthropic Messages, Google Gemini, and OpenAI-compatible APIs.
- Warns about likely secrets, detached HEAD, unstaged files, untracked files, and interrupted Git operations.
- Offers human-friendly prompts plus JSON output for scripts.
[!IMPORTANT] Your staged diff is sent to the configured AI provider. Review the provider's data handling policy before using
cnmon sensitive code.
Quick start
Prerequisites
- Node.js 20 or newer
- Git available on
PATH - An API key for one supported AI provider
Install
npm install -g commit-now-myfriendOr run it without a global install:
npx commit-now-myfriend[!NOTE] The package installs the
cnmbinary. If another tool already uses that name, runnpx commit-now-myfriendornpm exec --package commit-now-myfriend cnm.
First commit
cnm init
git add <files>
cnmThe default flow is:
- Inspect the repository and staged changes.
- Generate a commit message with the configured provider.
- Show a preview with warnings, files, and the proposed message.
- Let you confirm, edit, regenerate, or cancel.
- Run
git commitonly after confirmation.
If no files are staged and you are in an interactive terminal, cnm can ask whether to stage all current changes. In JSON or non-interactive mode, stage files manually first.
Providers
Configure a provider interactively:
cnm initOr set it directly:
cnm init \
--provider openai-responses \
--model gpt-5.4-mini \
--api-key <api-key>Supported provider IDs:
| Provider | Use for | Required config | Default model |
| --- | --- | --- | --- |
| openai-responses | OpenAI Responses API | apiKey | gpt-5.4-mini |
| anthropic-messages | Anthropic Messages API | apiKey | claude-haiku-4-5-20251001 |
| google-gemini | Google Gemini API | apiKey | gemini-3-flash-preview |
| openai-compatible | OpenAI-compatible or local gateways | apiKey, baseURL | gpt-5.4-mini |
For OpenAI-compatible providers, include a base URL:
cnm init \
--provider openai-compatible \
--base-url <base-url> \
--model <model> \
--api-key <api-key>Configuration
cnm merges configuration in this order, with later sources taking precedence:
- User config:
~/.cnm/config.json - Project config:
.cnmrc.json - Environment variables
- CLI flags
Project config is useful for shared defaults, but apiKey is ignored there by design.
{
"provider": "anthropic-messages",
"model": "claude-haiku-4-5-20251001",
"promptStyle": "conventional"
}Environment variables
Prefer environment variables for API keys:
export CNM_PROVIDER="openai-responses"
export CNM_MODEL="gpt-5.4-mini"
export CNM_API_KEY="<api-key>"Available variables:
| Variable | Maps to |
| --- | --- |
| CNM_PROVIDER | provider |
| CNM_MODEL | model |
| CNM_BASE_URL | baseURL |
| CNM_PROMPT_STYLE | promptStyle |
| CNM_CUSTOM_PROMPT | customPrompt |
| CNM_API_KEY | apiKey |
| CNM_HOME | user config directory, default ~/.cnm |
[!WARNING] API keys set with
cnm init --api-keyorcnm config set apiKeyare stored in plaintext in the user config file.cnmattempts to set0600permissions on Unix-like systems, but environment variables are still the safer default.
Manage config
# Interactive config panel in a TTY
cnm config
# Print effective config
cnm config list
cnm config list --json
# Read or update one key
cnm config get provider
cnm config set promptStyle conventional
cnm config unset baseURLConfig keys: provider, model, baseURL, promptStyle, customPrompt, apiKey.
Commit message styles
| Style | Behavior |
| --- | --- |
| auto | Infer style from recent non-merge commits; falls back to Conventional Commits. |
| conventional | Use type(scope)?: subject with an optional body. |
| angular | Use Angular-style commit subjects. |
| google | Use a short imperative subject and an optional explanatory body. |
| atom | Use a concise imperative subject, with a body only when useful. |
| plain | Use a concise natural-language message without strict prefixes. |
| custom | Use your customPrompt instructions. |
Examples:
cnm --prompt-style conventional
cnm --prompt-style custom --custom-prompt "Write concise Chinese commit messages"CLI reference
cnm
Generate a commit message for staged changes and optionally create the commit.
cnm [options]| Option | Description |
| --- | --- |
| --dry-run | Generate a preview without creating a commit. |
| --json | Emit machine-readable output; the root workflow returns a preview instead of committing. |
| --provider <provider> | Override the provider for this run. |
| --model <model> | Override the model for this run. |
| --base-url <baseUrl> | Override baseURL for this run. |
| --prompt-style <promptStyle> | Override the commit message style. |
| --custom-prompt <customPrompt> | Add custom instructions for this run. |
cnm init
Create or update user configuration.
cnm init [options]Options: --provider, --model, --base-url, --prompt-style, --custom-prompt, --api-key, --dry-run, --json.
cnm config
Inspect and edit configuration.
cnm config
cnm config get [key] [--json]
cnm config list [--json]
cnm config set <key> <value>
cnm config unset <key>cnm doctor
Diagnose Node.js, Git, repository state, config files, permissions, and effective provider setup.
cnm doctor
cnm doctor --jsonSafety and privacy
cnmnever runsgit push.cnmdoes not amend, rebase, or modify code.- Commits are created with
git commit -Fonly after interactive confirmation. - Large staged diffs are truncated before being sent to the provider.
- Potential secrets in staged diffs are reported as warnings before generation.
- Project-level
apiKeyvalues are ignored to avoid committing shared secrets.
Troubleshooting
cnm is not configured yet
Run the setup wizard or provide configuration through environment variables:
cnm init
cnm doctorNo staged changes found
Stage files first, especially in JSON or non-interactive mode:
git add <files>
cnmOpenAI-compatible provider requires baseURL
Set it in config, env, or a one-off command:
cnm config set provider openai-compatible
cnm config set baseURL <base-url>Git identity is missing
Configure Git before committing:
git config user.name "Your Name"
git config user.email "[email protected]"cnm launches a different command
Use the package name explicitly:
npx commit-now-myfriend
npm exec --package commit-now-myfriend cnmDevelopment
pnpm install
pnpm dev -- --help
pnpm test
pnpm typecheck
pnpm build
npm pack --dry-run