From 116f116109a6cd75b719087a21a5a5db97836bce Mon Sep 17 00:00:00 2001 From: Aaron Weisberg Date: Sun, 15 Feb 2026 19:35:00 -0800 Subject: [PATCH] reduce default diff context lines for cleaner prompts --- README.md | 8 ++++++-- doc/ai-commit-msg.nvim.txt | 8 ++++++-- lua/ai_commit_msg/config.lua | 2 +- lua/ai_commit_msg/prompts.lua | 10 +++++++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 554ed14..928c3d8 100644 --- a/README.md +++ b/README.md @@ -133,8 +133,8 @@ require("ai_commit_msg").setup({ -- Show notifications notifications = true, - -- Number of surrounding lines to include in git diff (default: 10) - context_lines = 10, + -- Number of surrounding lines to include in git diff (default: 5) + context_lines = 5, -- Cost display format ("compact", "verbose", or false to disable) cost_display = "compact", @@ -361,6 +361,10 @@ git config --global core.editor nvim - If you don't specify `max_tokens`, the model will use its default limit - For Anthropic models, `max_tokens` is required by the API (defaults to 1000 if not specified) +- For more predictable messages, keep `context_lines` modest (default `5`; + usually `3-10`) to reduce noisy, unchanged context in large diffs +- If outputs are too verbose, prefer single-line defaults with a custom + `system_prompt` that only allows a body for complex or breaking changes ## License diff --git a/doc/ai-commit-msg.nvim.txt b/doc/ai-commit-msg.nvim.txt index 77a4c1d..caa567e 100644 --- a/doc/ai-commit-msg.nvim.txt +++ b/doc/ai-commit-msg.nvim.txt @@ -162,8 +162,8 @@ CONFIGURATION *ai-commit-msg.nvim-ai-commit-msg.nvim-configuration* -- Show notifications notifications = true, - -- Number of surrounding lines to include in git diff (default: 10) - context_lines = 10, + -- Number of surrounding lines to include in git diff (default: 5) + context_lines = 5, -- Cost display format ("compact", "verbose", or false to disable) cost_display = "compact", @@ -421,6 +421,10 @@ TIPS *ai-commit-msg.nvim-ai-commit-msg.nvim-tips* - If you don’t specify `max_tokens`, the model will use its default limit - For Anthropic models, `max_tokens` is required by the API (defaults to 1000 if not specified) +- For more predictable messages, keep `context_lines` modest (default `5`; + usually `3-10`) to reduce noisy, unchanged context in large diffs +- If outputs are too verbose, prefer single-line defaults with a custom + `system_prompt` that only allows a body for complex or breaking changes LICENSE *ai-commit-msg.nvim-ai-commit-msg.nvim-license* diff --git a/lua/ai_commit_msg/config.lua b/lua/ai_commit_msg/config.lua index d826031..7cb59f7 100644 --- a/lua/ai_commit_msg/config.lua +++ b/lua/ai_commit_msg/config.lua @@ -42,7 +42,7 @@ M.default = { }, spinner = true, notifications = true, - context_lines = 10, + context_lines = 5, keymaps = { quit = "q", -- Set to false to disable }, diff --git a/lua/ai_commit_msg/prompts.lua b/lua/ai_commit_msg/prompts.lua index 95e40b0..93db4d7 100644 --- a/lua/ai_commit_msg/prompts.lua +++ b/lua/ai_commit_msg/prompts.lua @@ -1,7 +1,7 @@ local M = {} M.DEFAULT_SYSTEM_PROMPT = [[ -# System Prompt: Conventional Commits Auto-Commit Generator (Bullet-Style Bodies) +# System Prompt: Conventional Commit Generator (Concise-First) You are to produce a single Conventional Commit message that strictly adheres to Conventional Commits 1.0.0. Multi-line bodies should use plain ASCII bullet @@ -92,12 +92,19 @@ Validation rules: - No emojis. - Keep to ASCII where possible. +Default style preference (important): +- Prefer a single-line header by default. +- Only add a body when it materially improves clarity (complex/multi-area work, + important rationale, notable behavior change, or migration steps). +- If you add a body, keep it compact (usually 2-4 bullets). + When to use multi-line commits (with bullet-style body and/or footers): - Use a bullet-style body when: - The change is non-trivial and benefits from concise highlights - There are user-visible behavior or UX changes - Complex refactors, performance work, or architectural changes need rationale - You modified multiple areas and want to call out secondary impacts + - The commit would be ambiguous as a single-line header - Use footers when: - There is a breaking change (mandatory: add "!" in header and a BREAKING CHANGE footer) - You need to reference actual issues, tickets, PRs, or include co-authors (only if specific numbers/names exist) @@ -117,6 +124,7 @@ Task: 5) Group similar or related changes together - don't list every minor modification separately. 6) If multiple independent changes are present, summarize the primary one; do NOT emit multiple commits. 7) The final output must contain exactly one commit (one header). No prefaces, no postfaces, no explanations. +8) Default to a single-line header unless body/footer information is genuinely useful. Return ONLY the commit message. Do NOT include multiple commits. Do NOT include any other text.