Jp Grouped Commit
ASecurityGroup outstanding uncommitted (and optionally unpushed) Git changes by the nature or reason of each change, check and confirm the active Git user before any Git action, write a concise Japanese commit message for each group (with an option to switch commit messages to English when instructed), present the active Git user and grouping plan for confirmation, create one atomic local commit per group back-to-back, and push all created commits together in a single batch. Prevents unrelated changes...
- 2 stars
- 0 votes
- 0 copies
- 1 view
- Added November 25, 2026
Works with
Security analysis
100/100Pro scans all 2 files and shows the line behind each finding
npx -y skills add henryhyunwookim/agent-skills-and-policies --skill jp-grouped-commit --agent claude-codeAre you the author of Jp Grouped Commit?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/henryhyunwookim-jp-grouped-commit-d632b62d)---
name: jp-grouped-commit
description: Group outstanding uncommitted (and optionally unpushed) Git changes by the nature or reason of each change, check and confirm the active Git user before any Git action, write a concise Japanese commit message for each group (with an option to switch commit messages to English when instructed), present the active Git user and grouping plan for confirmation, create one atomic local commit per group back-to-back, and push all created commits together in a single batch. Prevents unrelated changes from being bundled into a single commit while keeping remote push history clean and cohesive. Use whenever the user asks to group changes by reason/nature, split uncommitted edits into separate commits, or commit grouped changes with Japanese (or explicitly English) messages before a single batch push.
---
# Grouped Git Commit Skill (`jp-grouped-commit`)
Use this skill whenever the user wants to organize outstanding Git changes into **separate, atomic local commits grouped by the nature or reason of each change**, with a **concise Japanese commit message per group** by default (or **English when explicitly instructed**), and then **push all grouped commits together in a single batch** so remote history remains clean and clearly shows the commits belong to the same timing.
---
## Core Policies & Guardrails
> [!IMPORTANT]
> **MANDATORY ACTIVE GIT USER CONFIRMATION & STRICT PER-TURN SCOPE**:
> - Staging, committing, and pushing are authorized **only** when the user explicitly invokes this skill or gives an unambiguous Git commit directive in the **current prompt** (e.g., `/jp-grouped-commit`, "変更を理由ごとにグループ化してコミットして", "group uncommitted changes and commit").
> - This authorization applies **exclusively to the current turn** and never carries over to subsequent follow-up edits.
> - **Mandatory Active Git User Confirmation Gate**: Before executing **any mutating or remote Git action** (`git rm --cached`, `git reset`, `git add`, `git commit`, `git pull --rebase`, `git push`), ALWAYS inspect and display the active Git user (`user.name`, `user.email`, config origin, target remote, and active `gh` CLI account if installed) and **halt to obtain explicit user confirmation**. Even if the user requests skipping the grouping-plan review (e.g., `"確認なしで実行"`, `"auto"`, `"skip confirmation"`), NEVER skip confirming the active Git user before executing Git actions.
> - **Default Confirmation Gate**: Present both the **active Git user** and the **proposed grouping table with commit messages** first, and wait for explicit user approval before executing any mutating Git actions.
> [!IMPORTANT]
> **SEPARATE LOCAL COMMITS, SINGLE-BATCH PUSH (NEVER PUSH PER GROUP)**:
> - **NEVER run `git push` inside the per-group commit loop.**
> - Create all approved group commits **locally and back-to-back** first, so every commit stays atomic while sharing tight, consecutive timestamps that reflect the same work session.
> - Only after **every** group commit has succeeded and been verified locally, execute **one single `git push`** to upload the entire batch together. This keeps the remote Git history clean, makes it clear all grouped changes were committed around the same timing, and avoids partial pushes or redundant CI runs.
> [!CAUTION]
> **NEVER BLINDLY STAGE LOCAL-ONLY ASSETS OR REWRITE PUSHED HISTORY.**
> - Never run `git add .` or `git add -A` blindly.
> - Local-only artifacts (secrets, caches, build artifacts, scratch scripts, and unrequested local test files) must be protected in `.gitignore` before any group is staged.
> - Never rewrite commits that are already pushed to a remote branch.
> - Existing **unpushed local commits (`@{u}..HEAD`)** are preserved untouched by default (and reported to the user). Only regroup/rewrite unpushed local commits (`git reset --soft @{u}`) if the user explicitly requests reorganizing them (and only after confirming the active Git user).
### Commit Message Language Option
- **Default Language (`ja`)**: Concise **Japanese** commit messages (`<type>(<optional scope>): <簡潔な日本語の要約>`).
- **English Override (`en`)**: If the user explicitly instructs English in their prompt (e.g., `"in English"`, `"英語で"`, `"English commit messages"`), switch all group summaries and optional bullet bodies to concise **English** (`<type>(<optional scope>): <concise imperative summary>`).
---
## Execution Workflow
```mermaid
flowchart TD
A["Step 1: Inspect Active Git User, Working Tree & Upstream\n(git_group_helper.ps1 -Action Inspect)"] --> B{"Uncommitted Changes\nPresent?"}
B -->|No| Z["Report Active Git User, Clean Tree & Unpushed Commits\n(Confirm Active Git User before any push/regroup)"]
B -->|Yes| C{"Blacklisted Local-Only Files?\n(secrets, caches, scratch, unrequested tests)"}
C -->|Yes| D["Step 2: Plan .gitignore Updates & Untracking\n(Reserve Group 1; defer git rm --cached until after confirmation)"]
C -->|No| E["Step 3: Inspect Full Diffs & Untracked Files\n(Detect File-Level & Mixed-File Hunks)"]
D --> E
E --> F["Group Changes by Nature / Reason\n(Order: chore/config -> refactor -> fix -> feat -> docs/style)"]
F --> G["Step 4: Draft Concise Commit Message per Group\n(Japanese default; English if instructed)"]
G --> H["Step 5: Mandatory Confirmation Gate\nPresent Active Git User + Grouping Plan & Await Approval"]
H -->|Switch User| U["Update Local Git User / gh Account\n& Re-Verify Identity"]
U --> H
H -->|Confirmed| J["Step 6: Loop Over Approved Groups Back-to-Back (Local Only)"]
J --> K["Apply Untrack / Stage ONLY Group N Files or Hunks\n(Verify git diff --cached matches Group N)"]
K --> L["Commit Group N Locally via UTF-8 Helper\n(DO NOT push yet)"]
L --> M{"More Groups Remaining?"}
M -->|Yes| J
M -->|No| N["Step 7: Verify Complete Commit Series\nRebase if Needed & Push ALL N Commits in a Single Batch"]
```
---
## Helper Script Reference
This skill includes a zero-dependency PowerShell 7 helper script that ensures **UTF-8 (no BOM) Japanese commit encoding on Windows**, **non-interactive hunk-level staging** for mixed-concern files, and **safe Japanese path output (`core.quotepath=false`)**:
```text
$HOME/.agents/skills/jp-grouped-commit/scripts/git_group_helper.ps1
```
Available actions:
- `-Action Inspect`: Audits active Git user (`user.name`, `user.email` with config origin), configured remotes, active `gh` CLI account (if installed, without exposing tokens), branch, upstream tracking, unpushed commits (`@{u}..HEAD`), staged/unstaged/untracked files, unmerged conflicts, and local-only blacklist hits.
- `-Action ListHunks -FilePath <path>`: Displays numbered hunks (`[1]`, `[2]`, ...) from a modified file's unstaged diff.
- `-Action StageHunks -FilePath <path> -Hunks <int[]>`: Stages only the specified hunk numbers into the index via `git apply --cached` (temp patch stored strictly in system temp dir and auto-deleted).
- `-Action Commit -Message <string>` (or `-MessageFile <path>`): Commits staged changes using `git -c i18n.commitEncoding=utf-8 -c core.quotepath=false commit -F <tempFile>` (UTF-8 no BOM in system temp dir, auto-deleted) and echoes the verified commit hash and subject.
*(On POSIX shells without `pwsh`, use equivalent `git -c core.quotepath=false` commands, inspect `git config --show-origin --get user.name`, `git config --show-origin --get user.email`, `git remote -v`, and `command -v gh >/dev/null && gh auth status`, and pipe UTF-8 commit messages into `git -c i18n.commitEncoding=utf-8 commit -F -`.)*
---
## Step-by-Step Procedure
### Step 1: Audit Active Git User, Outstanding Changes & Upstream State
1. Run the read-only inspection helper using `run_in_terminal`:
```powershell
pwsh -NoProfile -File "$HOME/.agents/skills/jp-grouped-commit/scripts/git_group_helper.ps1" -Action Inspect
```
2. Check active Git identity and blocking conditions before proceeding:
- **Active Git user (`user.name`, `user.email`, remotes, `gh` account)**: Record the reported values and flag prominently if `user.name` or `user.email` is unset, or if the active `gh` CLI account / Git email appears mismatched with the repository remote owner/organization.
- **Merge/rebase conflicts (`UU`, `AA`, `DD`)**: Stop immediately and report the conflicted files to the user.
- **Detached HEAD**: Warn the user and ask which branch to commit/push to before making commits.
- **No uncommitted changes**: Report the active Git user and that the working tree is clean. If there are unpushed local commits (`@{u}..HEAD`), list them and ask whether the user wants to push them as-is or regroup them — confirming the active Git user before running `git push` or `git reset`.
3. Inspect the actual contents of all changes so grouping is based on **real semantics**, not file names alone:
- Run `git -c core.quotepath=false diff` (unstaged changes) and `git -c core.quotepath=false diff --cached` (pre-staged changes).
- Read untracked non-blacklisted files using `read_file` to understand their purpose.
4. **Pre-existing staged changes**: If some changes are already staged when the skill begins, note them carefully. Do NOT run `git reset` until after Step 5 confirmation; then unstage (`git reset`) at the start of Step 6 so each group starts from a clean index.
---
### Step 2: `.gitignore` Hygiene & Local-Only Artifact Protection
Before grouping production changes, check every flagged file from Step 1 against the **Local-Only Artifact Blacklist**:
1. **Secrets & Credentials**: `.env`, `.env.local`, `.env.*.local`, `*.pem`, `*.key`, `*.token`, `credentials.json`, `token.json`, `service_account*.json`
2. **Caches & Build Outputs**: `__pycache__/`, `*.py[cod]`, `.pytest_cache/`, `.mypy_cache/`, `.ruff_cache/`, `.coverage`, `htmlcov/`, `dist/`, `build/`, `out/`, `.next/`, `.nuxt/`, `.turbo/`, `*.tsbuildinfo`, `.cache/`, `*.log`, `tmp/`, `temp/`
3. **Dependencies & Virtual Environments**: `.venv/`, `venv/`, `node_modules/`, `target/`, `vendor/`, `Pods/`
4. **OS & IDE Files**: `Thumbs.db`, `Desktop.ini`, `.DS_Store`, `.vscode/`, `.idea/`, `*.swp`
5. **Scratch & Ad-Hoc Local Tests**: `scratch/`, `tmp_*.py`, `debug_*.py`, and local test files/directories (`tests/`, `test/`, `__tests__/`, `spec/`, `*.test.*`, `*.spec.*`, `test_*.py`, `*_test.py`, `conftest.py`) **unless** the user explicitly requested committing tests or the files are already part of a tracked repository test suite.
If blacklisted files exist:
1. Read `.gitignore` using `read_file` (or plan to create it if missing) and identify the missing ignore patterns to append under clean section comments.
2. Note any blacklisted files that are already tracked by Git and will need untracking (`git rm --cached -r <path>`). **Defer executing `git rm --cached` until after Step 5's active Git user confirmation.**
3. Assign the `.gitignore` update (and any untracking) to **Group 1 (`chore`)** so hygiene is committed cleanly before any application changes.
---
### Step 3: Semantic Grouping by Nature or Reason
Partition all remaining committable changes into cohesive, atomic groups based on **why** the change was made:
#### Grouping Principles
- **Group by intent, not by file extension or directory**:
- Changes across multiple layers that implement a single feature (e.g., API route + service logic + schema for Feature X) belong in the **same group**.
- Two unrelated features (Feature X and Feature Y) or two unrelated bug fixes (Fix A and Fix B) MUST be placed in **separate groups**.
- Pure refactoring MUST NOT be mixed with behavior changes (`feat` or `fix`).
- Standalone documentation updates (`README.md`, `docs/`) belong in a dedicated `docs` group (keep docs together with a feature only when they are strictly inseparable inline API/config docs for that feature).
- **Standard Categories (Conventional Commit Types)**:
- `chore`: `.gitignore` hygiene, tooling, repo maintenance, dependency housekeeping
- `build` / `ci`: Build system, packaging manifests, CI/CD workflows
- `refactor`: Structural code improvements, renaming, helper extraction with no behavior change
- `fix`: Bug fixes, crash/error handling fixes, edge-case corrections
- `feat`: New features, endpoints, UI enhancements, new skills/capabilities
- `perf`: Performance optimizations
- `docs`: Documentation, README, guides, explanatory comments
- `style`: Formatting, whitespace, lint-only adjustments
- `test`: Permanent repository tests (only when explicitly tracked/requested)
- **Logical Commit Ordering**:
Order groups so every individual commit leaves the repository in a coherent state:
1. `.gitignore` hygiene / foundational config & dependencies (`chore`, `build`, `ci`)
2. Shared refactors & utilities (`refactor`)
3. Bug fixes (`fix`)
4. New features — one group per distinct feature (`feat`)
5. Performance improvements (`perf`)
6. Documentation & formatting (`docs`, `style`)
#### Handling Mixed-Concern Files (Hunk-Level Splitting)
If a single modified file contains two or more unrelated changes (e.g., a bug fix at lines 20–30 and an unrelated refactor at lines 120–160):
1. Run `ListHunks` using `run_in_terminal`:
```powershell
pwsh -NoProfile -File "$HOME/.agents/skills/jp-grouped-commit/scripts/git_group_helper.ps1" -Action ListHunks -FilePath "<relative/path>"
```
2. Record exact hunk indices (e.g., `src/app.py [hunks 1]` in Group 2, `src/app.py [hunks 2, 3]` in Group 3) in the grouping plan.
3. **Important**: When committing sequential groups that split hunks from the same file, **re-run `ListHunks` before staging the next group's hunks from that file**, because committing earlier hunks renumbers the remaining unstaged hunks starting from `[1]` again!
---
### Step 4: Draft Concise Commit Messages (Japanese Default / English Option)
Write one commit message per group explaining the **nature and reason** of that group's changes concisely:
#### Default Format — Japanese (`ja`)
```text
<type>(<optional scope>): <簡潔な日本語の要約>
- <補足が必要な場合のみ:変更理由や要点を1〜3行の簡潔な箇条書きで記載>
```
- Keep the subject concise (aim for ~30–50 Japanese characters), clear, and action-oriented (`〜を追加`, `〜を修正`, `〜へ整理`, `〜を更新`).
- Avoid vague messages like `fix: 修正` or `chore: ファイル更新`.
- Omit the bullet body when the subject alone completely explains a small, single-purpose group; include 1–3 brief bullets when multiple files or non-obvious rationale ("なぜ") benefit from context.
- **Examples**:
- `chore: キャッシュと認証情報を.gitignoreに追加`
- `refactor(parser): 日付パース処理を共通ユーティリティへ抽出`
- `fix(api): 空ペイロード受信時の例外処理を修正`
- `feat(auth): OAuthトークン自動リフレッシュ処理を追加`
- `docs: インストール手順と設定例をREADMEに追記`
#### English Override Format (`en` — Only When Explicitly Instructed)
```text
<type>(<optional scope>): <concise imperative English summary>
- <Optional 1-3 concise bullets explaining why/what changed when helpful>
```
- **Examples**:
- `chore: ignore cache and credential files in .gitignore`
- `refactor(parser): extract shared date parsing helper`
- `fix(api): handle empty request payload without throwing`
- `feat(auth): add automatic OAuth token refresh`
- `docs: document installation steps in README`
---
### Step 5: Present Active Git User, Grouping Plan & Confirmation Gate
**ALWAYS stop here to confirm the active Git user** before running any mutating or remote Git action (even if the user asked to skip reviewing the grouping plan via `"auto"` or `"確認なしで実行"`, still present the active Git user and wait for explicit confirmation of the Git user).
Display the **Active Git User & Remote** summary followed by the grouping plan:
```markdown
### 現在のアクティブな Git ユーザー / リモート
- **Git `user.name`**: `<name>` (`<config origin>`)
- **Git `user.email`**: `<email>` (`<config origin>`)
- **対象ブランチ / リモート**: `<branch>` -> `<remote url>`
- **アクティブな `gh` アカウント**: `<account>` *(インストール済みの場合のみ;リポジトリ所有者と異なる場合は警告)*
### 提案するコミットグループ一覧
| # | 種別・理由 | 対象ファイル / Hunk | コミットメッセージ |
| :--- | :--- | :--- | :--- |
| 1 | `.gitignore` 保護(ローカル資産除外) | `.gitignore` | `chore: キャッシュと秘密鍵を.gitignoreに追加` |
| 2 | 空入力バグ修正 | `src/validator.py` (hunk 1) | `fix(validator): 空文字入力時のNull参照エラーを修正` |
| 3 | バリデーション整理 | `src/validator.py` (hunk 2), `src/utils.py` | `refactor(validator): 共通入力チェック関数を抽出` |
| 4 | README更新 | `README.md` | `docs: 起動オプションの説明をREADMEに追記` |
```
Also clearly report:
- Any **excluded/ignored local-only files** kept out of all commits.
- Any **existing unpushed local commits (`@{u}..HEAD`)** (noting they will remain untouched unless the user explicitly asks to regroup them).
- Ask the user explicitly to confirm **both** the active Git user and the grouping plan:
*"上記のアクティブな Git ユーザーとグループ分け・コミットメッセージで順次ローカルコミットを作成し、最後に1回でまとめてプッシュしてよろしいですか?ユーザー切り替えや変更したい点があればお知らせください。"* (or in English if the user is communicating in English).
If the user asks to switch the Git user or GitHub account first, apply the requested local config (`git config --local user.name "<name>"`, `git config --local user.email "<email>"`) and/or `gh auth switch --user <account>`, re-verify the active identity, and wait for confirmation before running Step 6.
---
### Step 6: Back-to-Back Atomic Local Staging & UTF-8 Safe Commits
> [!WARNING]
> **LOCAL COMMITS ONLY IN THIS STEP — DO NOT PUSH PER GROUP.**
> Complete all `N` local commits sequentially back-to-back without pausing between groups and without calling `git push`. Keeping all group commits consecutive ensures tight timestamps showing they were committed together at the same timing, and guarantees no partial state reaches the remote repository.
Once the active Git user and grouping plan are explicitly confirmed:
1. **Apply any deferred `.gitignore` hygiene & untracking** (if Group 1 was reserved in Step 2):
- Update `.gitignore` with missing blacklist patterns.
- Untrack any previously tracked blacklisted files without deleting them locally (`git rm --cached -r <path>`).
- Verify via `git status --ignored` that blacklisted artifacts are now ignored.
2. **Reset any mixed pre-staged index** (only if pre-staged changes spanned multiple groups):
```powershell
git reset
```
3. **Execute one loop iteration per group (in planned order, back-to-back)**:
- **Stage file-level targets explicitly** (never `git add .`):
```powershell
git add -- "<file1>" "<file2>"
```
*(For deleted tracked files, `git add -- "<deleted-file>"` stages the deletion cleanly.)*
- **Stage hunk-level targets** (for mixed-concern files):
- If earlier groups already committed hunks from the same file, run `-Action ListHunks -FilePath "<file>"` first to verify current hunk numbers!
- Stage exact hunk numbers:
```powershell
pwsh -NoProfile -File "$HOME/.agents/skills/jp-grouped-commit/scripts/git_group_helper.ps1" -Action StageHunks -FilePath "<file>" -Hunks 1,3
```
- **Verify strict index isolation**:
```powershell
git -c core.quotepath=false diff --cached --name-status
```
Confirm that **ONLY** Group N's intended files/hunks are staged and zero files from other groups or blacklisted paths are present.
- **Commit Group N locally and safely in UTF-8**:
```powershell
pwsh -NoProfile -File "$HOME/.agents/skills/jp-grouped-commit/scripts/git_group_helper.ps1" -Action Commit -Message "<commit message>"
```
For multi-line commit messages (subject + bullet body), pass a PowerShell here-string (`@" ... "@`) to `-Message` so newlines and UTF-8 Japanese characters are preserved cleanly without shell-escaping corruption.
- Confirm the helper prints the new commit hash and readable Japanese (or English) subject, then immediately proceed to Group N+1 (never push mid-loop).
---
### Step 7: Final Verification & Single-Batch Upstream Push
1. **Verify the complete local commit series & working tree BEFORE pushing**:
```powershell
git -c core.quotepath=false log -n <N> --stat
git -c core.quotepath=false status --short
```
Confirm:
- Exactly `N` distinct, consecutive commits were created locally (1 per group) under the confirmed author with close timestamps.
- Every commit message renders cleanly with zero encoding corruption.
- No unintended unstaged or untracked production changes remain.
2. **Push all `N` commits together in ONE single batch** (unless the user explicitly requested local-only commits without pushing):
- Check branch and upstream tracking:
```powershell
git branch -vv
```
- If the remote branch is ahead, rebase cleanly before pushing:
```powershell
git pull --rebase origin <current-branch>
```
*(If rebase conflicts occur, stop immediately and report to the user — never force-push automatically.)*
- Push the entire commit series in a single `git push`:
```powershell
git push origin <current-branch>
```
*(If no upstream is set yet, use `git push -u origin <current-branch>` after confirming the target remote name with `git remote -v`.)*
3. **Final Report**:
Present a concise summary table to the user containing:
- Confirmed active Git author (`user.name <user.email>`).
- Each commit's short hash, category/reason, commit message, and committed files.
- Confirmation that all `N` commits were pushed together in a single batch (or kept local if requested) and confirmation of any local-only files protected in `.gitignore`.
Files in this skill
- SKILL.md
- scripts/git_group_helper.ps1
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.