From c3684ee3202b53759afb823ae42fb2b7c0ffabd2 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 10 Mar 2026 02:07:27 -0400 Subject: [PATCH] [IMP] conf: simplify Claude commit template The previous template used a piped shell command to detect the active model, which caused permission errors in sandboxed environments. Replace with a simple Python script approach and add disable-model-invocation for reliability. Generated by Claude Code 2.1.72 model claude-opus-4-6 Co-Authored-By: Mathieu Benoit --- conf/template_claude_commands_commit.md | 108 +++++++++++------------- 1 file changed, 50 insertions(+), 58 deletions(-) diff --git a/conf/template_claude_commands_commit.md b/conf/template_claude_commands_commit.md index ce46431..9ac2030 100644 --- a/conf/template_claude_commands_commit.md +++ b/conf/template_claude_commands_commit.md @@ -1,58 +1,60 @@ --- -description: "OCA/Odoo conventional commit in English with dynamic Claude Code attribution" +name: commit +description: "OCA/Odoo conventional commit in English with dynamic Claude Code attribution." +disable-model-invocation: true allowed-tools: - - "Bash(git add:*)" - - "Bash(git status:*)" - - "Bash(git commit:*)" - - "Bash(git diff:*)" - - "Bash(git log:*)" - - "Bash(claude --version)" - - "Bash(cat ~/.claude/settings.json)" + - Bash(git add:*) + - Bash(git status:*) + - Bash(git commit:*) + - Bash(git diff:*) + - Bash(git log:*) + - Bash(claude --version) + - Bash(cat:*) + - Bash(python3:*) --- ## Context -- Current git status: !`git status` -- Staged & unstaged diff: !`git diff HEAD` +- Git status: !`git status` +- Full diff: !`git diff HEAD` - Current branch: !`git branch --show-current` -- Recent commits (for style reference): !`git log --oneline -5` +- Last 5 commits (for style reference): !`git log --oneline -5` - Claude Code version: !`claude --version 2>/dev/null | head -1` -- Active model: !`cat ~/.claude/settings.json 2>/dev/null | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('model', d.get('env', {}).get('ANTHROPIC_MODEL', 'claude-sonnet-4-6')))" 2>/dev/null || echo "claude-sonnet-4-6"` ## Task -Analyze the changes and create an OCA/Odoo-compliant git commit. +Before committing, retrieve the active model with: +```bash +python3 -c " +import json, os +path = os.path.expanduser('~/.claude/settings.json') +try: + d = json.load(open(path)) + print(d.get('model', 'claude-sonnet-4-6')) +except: + print('claude-sonnet-4-6') +" +``` -### Step 1 – Determine the TAG +Then create an OCA/Odoo-compliant commit. -Choose ONE tag based on the nature of the change: +### OCA Tags -| Tag | Use when | -|-----|----------| -| `[IMP]` | Improvement, new feature, enhancement | +| Tag | Usage | +|-----|-------| +| `[IMP]` | Improvement / new feature | | `[FIX]` | Bug fix | -| `[REF]` | Refactoring (no behavior change) | -| `[ADD]` | Adding a new module or major component | -| `[REM]` | Removing code or a module | -| `[MOV]` | Moving/renaming files or modules | -| `[I18N]` | Translation updates | -| `[MRG]` | Merge commit | +| `[REF]` | Refactoring | +| `[ADD]` | New module | +| `[REM]` | Remove code/module | +| `[MOV]` | Move/rename | +| `[I18N]` | Translations | -### Step 2 – Identify the module name - -Use the Odoo technical module name (e.g., `sale_order`, `account`, `stock_picking`). -If the change spans multiple modules, pick the primary one or use the repo name. - -### Step 3 – Build the commit message - -Format: +### Format ``` [TAG] module_name: short description in imperative mood -WHY this change was made (focus on the reason, not what was done). -The diff already shows what changed. - -If there were technical choices involved, explain them here. +Explain WHY the change was made (not what — the diff already shows that). Keep lines under 80 characters. Generated by Claude Code {VERSION} model {MODEL} @@ -60,29 +62,19 @@ Generated by Claude Code {VERSION} model {MODEL} Co-Authored-By: Your Name ``` -Rules: -- **English only** — no French, no other language -- Subject line (first line): under 50 characters, imperative mood -- Body: explain the *WHY*, not the *what* -- One module per commit when possible +### Rules -### Step 4 – Execute +- **English only**, imperative mood, subject line under 50 chars +- Use the Odoo technical module name (e.g. `sale_order`, `account`, `stock`) +- If multiple modules are impacted, suggest splitting into separate commits -Stage all relevant changes, then run: +### Execute ```bash -git commit \ - --author="Your Name " \ - -m "$(cat < -COMMITMSG -)" +git add -A && git commit --author="Your Name " -m "[TAG] module: description + +Explain WHY here. + +Generated by Claude Code {VERSION} model {MODEL} + +Co-Authored-By: Your Name " ``` - -Replace `{VERSION}` and `{MODEL}` with the actual values retrieved in the Context section above. - -## Constraints - -- NEVER write the commit message in French -- ALWAYS use the `[TAG]` prefix — never use `feat:`, `fix:` or other conventional commit formats -- ALWAYS include the `Generated by Claude Code ...` line with real version and model values -- ALWAYS use `--author` with the specified identity -- If changes span multiple modules, suggest splitting into separate commits