Skip to content

mine ai

Use AI to assist with code review, commit messages, and quick questions. Supports Claude, OpenAI, Gemini, and OpenRouter.

Terminal window
mine ai config --provider claude --key sk-ant-...
mine ai config --provider openai --key sk-...
mine ai config --provider gemini --key AIza...
mine ai config --provider openrouter --key sk-or-v1-...

API keys are stored encrypted in the vault (~/.local/share/mine/vault.age). See mine vault for details.

Terminal window
mine ai config --provider claude --default-model claude-opus-4-6
Terminal window
mine ai config --list

Set a standard environment variable and mine detects it automatically:

Terminal window
export ANTHROPIC_API_KEY=sk-ant-...
export OPENAI_API_KEY=sk-...
export GEMINI_API_KEY=AIza...
export OPENROUTER_API_KEY=sk-or-v1-...

Environment variables take precedence over vault-stored keys.

Terminal window
mine ai ask "What is the difference between defer and panic in Go?"
mine ai ask "Explain the repository pattern" --model claude-opus-4-6
mine ai ask "What does this code do?" --system "You are a Go expert. Be concise."

In interactive terminals (TTY), responses are automatically rendered as styled markdown — headings, code blocks, lists, and emphasis are all formatted for readability.

Use --raw to force plain markdown output (no terminal rendering). Useful for piping into other tools or saving to a file:

Terminal window
mine ai ask "Explain goroutines" --raw
mine ai ask "Explain goroutines" --raw > answer.md
mine ai ask "Explain goroutines" | cat # non-TTY also outputs raw automatically
Terminal window
git add .
mine ai review
mine ai review --system "Focus only on security issues."
mine ai review --system "" # disable system instructions for this review

Sends your staged git diff to the configured AI provider for code review. Output is rendered as styled markdown in interactive terminals.

Terminal window
mine ai review --raw # force plain markdown
mine ai review --raw > review.md # pipe to file
Terminal window
git add .
mine ai commit
mine ai commit --system "Use Angular commit convention."

Analyzes staged changes, suggests a conventional commit message, and optionally runs git commit.

Control what behavior the AI uses for each command via the --system flag or config defaults.

FlagDescription
--system "<text>"Override system instructions for this invocation
--system ""Disable system instructions for this invocation

Set persistent defaults using mine config set:

Terminal window
# Global default applied to all AI subcommands
mine config set ai.system_instructions "Always respond in English."
# Per-subcommand defaults (override the global default)
mine config set ai.ask_system_instructions "You are a Go expert."
mine config set ai.review_system_instructions "Focus on security and performance."
mine config set ai.commit_system_instructions "Use Angular commit convention."

Or edit the TOML file directly (mine config edit):

[ai]
system_instructions = "Always respond in English."
ask_system_instructions = "You are a Go expert."
review_system_instructions = "Focus on security and performance."
commit_system_instructions = "Use Angular commit convention."

System instructions are resolved in this order (first match wins):

  1. --system flag (including empty string, which disables system instructions)
  2. Per-subcommand config key (ask_system_instructions, etc.)
  3. Global config key (system_instructions)
  4. Built-in default (for review and commit only)

When no custom value is configured or provided, review and commit use their built-in system prompts. ask has no built-in default.

Terminal window
mine ai models

Shows all available providers with their suggested models and configuration status.

API keys configured via mine ai config --key are stored in the encrypted vault:

ProviderVault key
claudeai.claude.api_key
openaiai.openai.api_key
geminiai.gemini.api_key
openrouterai.openrouter.api_key

You can also manage these keys directly with mine vault:

Terminal window
mine vault set ai.claude.api_key sk-ant-...
mine vault get ai.claude.api_key
mine vault rm ai.claude.api_key
ProviderEnv VarNotes
claudeANTHROPIC_API_KEYGet key
openaiOPENAI_API_KEYGet key
geminiGEMINI_API_KEYGet key
openrouterOPENROUTER_API_KEYFree models available. Get key