AI Git Assistant is a VS Code extension that can turn a selected git diff, or the staged diff from the current workspace, into conventional commit message suggestions and can also create or update a README.md by scanning the repository code.
- Uses the active text selection when it looks like a diff
- Falls back to
git diff --stagedfrom the workspace root - Supports both OpenAI and Ollama backends
- Generates one primary conventional commit message
- Generates three alternative messages
- Explains why the primary type was chosen
- Shows results in a focused webview panel
- Supports copying any message
- Supports inserting a message into the active editor when possible
- Scans the workspace and creates or updates
README.md
- Install dependencies:
npm install- Compile the extension:
npm run compile-
Open this folder in VS Code.
-
Press
F5to launch an Extension Development Host. -
In the Extension Development Host, open the Command Palette and run:
AI Git Assistant: Generate Commit Message
To create or refresh project documentation from the current workspace, run:
AI Git Assistant: Create or Update README
Open VS Code settings and set:
aiCommitMessageGenerator.provideraiCommitMessageGenerator.useSelectionFirstif you want to prefer staged diff lookup over editor selection
Default provider is ollama.
- Install Ollama
- Start the local Ollama service
- Pull a model, for example:
ollama pull qwen2.5-coder:7b- In VS Code settings, confirm:
aiCommitMessageGenerator.provider = ollamaaiCommitMessageGenerator.ollamaModel = qwen2.5-coder:7baiCommitMessageGenerator.ollamaBaseUrl = http://127.0.0.1:11434
If you want to use OpenAI instead:
aiCommitMessageGenerator.provider = openaiaiCommitMessageGenerator.apiKey = <your key>aiCommitMessageGenerator.model = gpt-5-mini
- Stage a set of changes in a git repository.
- Run
AI Git Assistant: Generate Commit Message. - The primary message is copied to the clipboard automatically.
- Review the primary suggestion, alternatives, and reasoning in the webview.
- Click
Insertto place a message in the active editor when available, orCopyto place it on the clipboard.
{
"primary": "feat(prompt): add structured commit message instructions",
"alternatives": [
"refactor: tighten commit message prompt rules",
"fix: return valid JSON commit suggestions",
"chore: improve AI commit generation flow"
],
"reasoning": "The diff introduces new user-facing commit generation behavior, so feat best matches the main impact."
}src/extension.ts: command registration and orchestrationsrc/git.ts: staged diff lookup viagit diff --stagedsrc/project.ts: repository scanning and README context collectionsrc/ai.ts: OpenAI/Ollama requests, validation, and safe parsingsrc/prompt.ts: reusable commit and README prompt builderssrc/webview.ts: webview rendering and message actionssrc/types.ts: shared types and constants
- Use a real git repository in the Extension Development Host.
- Test with selected diff text first.
- Test again with no selection and staged changes present.
- Test README generation in a small and medium project to confirm the produced markdown matches the codebase.
- Test Ollama with the local service running.
- Test missing API key, no workspace, Ollama not running, and no staged changes to verify friendly error handling.