$npx -y skills add PaulRBerg/agent-skills --skill commitCommit staged or intended changes: craft a Conventional Prefix or Natural Language message, then commit — with --all, --staged, --close, or --push.
| 1 | # Git Commit |
| 2 | |
| 3 | Create atomic commits by staging the right files, analyzing the staged diff, composing a commit message, and optionally |
| 4 | pushing. |
| 5 | |
| 6 | ## Workflow |
| 7 | |
| 8 | ### 1) Parse arguments |
| 9 | |
| 10 | Arguments: `$ARGUMENTS` |
| 11 | |
| 12 | - Flags: |
| 13 | - `--all` commit all changes |
| 14 | - `--staged` commit exactly the current index; do not auto-stage or unstage (conflicts with `--all`) |
| 15 | - `--natural` force Natural Language Format |
| 16 | - `--push` push after commit |
| 17 | - `--close <issue_numbers>` append `Closes #N` trailers for listed issues (comma/space-separated) |
| 18 | - Value arguments: |
| 19 | - Conventional Prefix Format: type keyword overrides inferred type |
| 20 | - Natural Language Format: leading verb/category keyword overrides inferred verb |
| 21 | - Quoted text overrides inferred description or subject |
| 22 | |
| 23 | Pass `--natural` through to the prepare helper when requested. The helper resolves the message format from the target |
| 24 | repository cwd. |
| 25 | |
| 26 | ### 2) Prepare staged diff |
| 27 | |
| 28 | Run the portable helper from the target repository cwd. Never `cd` into the skill directory, and never use dynamic `!` |
| 29 | shell injection. |
| 30 | |
| 31 | Resolve `<skill-dir>` from the loaded `SKILL.md` path: |
| 32 | |
| 33 | ```bash |
| 34 | bash "<skill-dir>/scripts/prepare-commit.sh" [--all] [--staged] [--natural] [--diff summary|full] -- [session_modified_paths...] |
| 35 | ``` |
| 36 | |
| 37 | Use `--diff summary` by default. Use `--diff full` only when the intent is ambiguous. |
| 38 | |
| 39 | The helper performs Git preflight checks, rejects empty change sets, and prints the message format, branch, name-status, |
| 40 | shortstat, and optional full diff. It is safe to run alongside other agents committing in the same working tree: `--all` |
| 41 | and `--staged` stage or read the index directly (index-trusting by design); the default mode never stages, unstages, or |
| 42 | otherwise touches the index — it marks new session files with `git add -N` (intent-to-add, no content staged) so diffs |
| 43 | can see them, then diffs the session paths against `HEAD` in the working tree. If it fails, stop with its error and a |
| 44 | concise suggested fix. |
| 45 | |
| 46 | - If `--all`: |
| 47 | - Include all tracked, untracked, modified, deleted, and already staged changes — this also sweeps in any other |
| 48 | agent's in-flight work by design; see the step 4 output contract for the resulting flag. |
| 49 | - If `--staged`: |
| 50 | - Commit exactly what is already staged; pass no session paths. The helper neither stages nor unstages. Conflicts with |
| 51 | `--all`. The index may hold another agent's staged files; committing it verbatim is the user's explicit choice. |
| 52 | - Otherwise (atomic commits): |
| 53 | - Session-modified files = files edited in this session |
| 54 | - Pass every session-modified path after `--` |
| 55 | - The helper never stages, unstages, or touches paths another agent has staged; it prints a `## commit pathspec` list |
| 56 | of the resolved session paths to commit with in step 4 |
| 57 | - **Renames**: pass both the old and new path of a renamed file as session paths, so the pathspec commit in step 4 |
| 58 | captures both sides |
| 59 | - **Unrelated changes**: session-modified files may contain pre-existing uncommitted changes (hunks not from this |
| 60 | session). Include the entire file—partial staging is impractical. Never revert, discard, or `git checkout` unrelated |
| 61 | changes. |
| 62 | |
| 63 | ### 3) Analyze + compose message |
| 64 | |
| 65 | Read the helper output and produce the commit message in a single pass. |
| 66 | |
| 67 | **Message format** — use the `## message format` value from the helper output. |
| 68 | |
| 69 | - If `conventional`: read [references/conventional-prefix-format.md](references/conventional-prefix-format.md). |
| 70 | - If `natural`: read [references/natural-language-format.md](references/natural-language-format.md). |
| 71 | |
| 72 | Read only the selected format reference before composing the message. |
| 73 | |
| 74 | **Unrelated hunks** — ignore pre-existing changes when determining type/scope/description. If unrelated changes are in |
| 75 | the same file as session changes, they are included in the commit scope but should not influence the message. |
| 76 | |
| 77 | **Issue linking** — scan the chat transcript for GitHub issue references (e.g. `#123`, `owner/repo#123`, issue URLs) |
| 78 | that the current changes resolve. For each match, append a `Closes #N` trailer. Skip issues merely mentioned in passing; |
| 79 | include only ones the commit actually closes. |
| 80 | |
| 81 | **Analysis** — perform semantic analysis of the staged diff: |
| 82 | |
| 83 | - Detect breaking changes |
| 84 | - Infer Conventional Prefix Format scope or Natural Language context from code structure even when the path isn't clear |
| 85 | - Follow the selected reference's body and breaking-change rules |
| 86 | |
| 87 | **If `--close`:** |
| 88 | |
| 89 | - Append a `Closes #N` line for each issue number provided |
| 90 | - Multiple issues: one `Closes #N` per line in the body/trailer |
| 91 | - Merge with transcript-scanned issues; de-duplicate |
| 92 | |
| 93 | ### 4) Commit |
| 94 | |
| 95 | - Default mode (no `--all`/`--staged`): commit w |