@m4ss/pi-skills 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +17 -2
- package/package.json +40 -3
- package/skills/commit/SKILL.md +383 -0
- package/skills/repo-maintenance/SKILL.md +251 -0
- package/skills/repo-maintenance/references/changelogs.md +164 -0
- package/skills/repo-maintenance/references/ci-audit.md +329 -0
- package/skills/repo-maintenance/references/containers.md +287 -0
- package/skills/repo-maintenance/references/forgejo.md +162 -0
- package/skills/repo-maintenance/references/node.md +376 -0
- package/skills/repo-maintenance/references/rust.md +567 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 M4SS Srl
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @m4ss/pi-skills
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Open-source Pi skills for our own way of working with Pi.
|
|
4
|
+
|
|
5
|
+
## Skills
|
|
6
|
+
|
|
7
|
+
- [`commit`](skills/commit/) — Creates safe, atomic Git commits with deliberate staging, focused verification, and clear English Conventional Commit messages.
|
|
8
|
+
- [`repo-maintenance`](skills/repo-maintenance/) — Maintains a repository's dependencies and CI: Rust (Cargo) and Node.js (pnpm) upgrades reviewed against changelogs and release diffs, MSRV handling, security advisories, and GitHub Actions and Forgejo Actions audits.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pi install npm:@m4ss/pi-skills
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## License
|
|
17
|
+
|
|
18
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4ss/pi-skills",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Open-source Pi skills: a commit skill for safe, atomic Git commits with deliberate staging, focused verification, and English Conventional Commit messages, and a repo-maintenance skill for Rust and Node.js dependency upgrades and CI audits",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Paolo Barbolini <paolo.barbolini@m4ss.net>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/M4SS-Code/pi-packages.git",
|
|
10
|
+
"directory": "packages/pi-skills"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/M4SS-Code/pi-packages/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/M4SS-Code/pi-packages/tree/main/packages/pi-skills#readme",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"pi",
|
|
18
|
+
"pi-package",
|
|
19
|
+
"pi-skill",
|
|
20
|
+
"skills",
|
|
21
|
+
"git",
|
|
22
|
+
"commit",
|
|
23
|
+
"conventional-commits",
|
|
24
|
+
"dependencies"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"skills"
|
|
34
|
+
],
|
|
35
|
+
"pi": {
|
|
36
|
+
"skills": [
|
|
37
|
+
"./skills"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=22"
|
|
42
|
+
}
|
|
6
43
|
}
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: commit
|
|
3
|
+
license: MIT
|
|
4
|
+
description: >
|
|
5
|
+
Create safe, well-scoped Git commits from working-tree and staged changes.
|
|
6
|
+
Use when the user asks to commit, amend, fold a fix into an earlier commit,
|
|
7
|
+
review what should be committed, or draft a commit message. Inspects every
|
|
8
|
+
candidate change, preserves unrelated work, follows the repository's explicit
|
|
9
|
+
and implicit conventions, groups each change type into its own commit, runs
|
|
10
|
+
focused checks, and writes English Conventional Commit messages.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Commit changes safely
|
|
14
|
+
|
|
15
|
+
Treat the working tree and index as user-owned state. Preserve unrelated work
|
|
16
|
+
and create commits that are easy to review, revert, and understand later.
|
|
17
|
+
|
|
18
|
+
## Choose the operating mode
|
|
19
|
+
|
|
20
|
+
The user's request determines what may be changed:
|
|
21
|
+
|
|
22
|
+
| Mode | Index changes | Commit/history changes |
|
|
23
|
+
| ------------------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
24
|
+
| Review what should be committed | Forbidden | Forbidden |
|
|
25
|
+
| Draft a commit message | Forbidden | Forbidden |
|
|
26
|
+
| Create a commit | Allowed for the approved scope | Create new commits; may fold corrections into local, unshared commits created earlier in this session |
|
|
27
|
+
| Amend the latest commit | Allowed after amend-safety checks | Amend `HEAD` only |
|
|
28
|
+
| Fold corrections into earlier commits | Allowed after amend-safety checks | Amend (when target is `HEAD`) or fixup commit plus scoped `--autosquash` rebase of local, unshared commits |
|
|
29
|
+
|
|
30
|
+
Do not stage or commit during review-only or message-only work. When the user
|
|
31
|
+
asks to commit or amend, carry the workflow through without routine
|
|
32
|
+
confirmation. Stop and ask only when scope is ambiguous, suspicious content may
|
|
33
|
+
be intentional, verification fails, or history rewriting is not clearly safe.
|
|
34
|
+
|
|
35
|
+
## Non-negotiable rules
|
|
36
|
+
|
|
37
|
+
1. Inspect every staged, unstaged, and untracked candidate before acting. Prior
|
|
38
|
+
staging is evidence of intent, not proof that a change belongs.
|
|
39
|
+
2. Include only changes covered by the user's request. Preserve unrelated,
|
|
40
|
+
pre-existing, and uncertain work exactly as it is.
|
|
41
|
+
3. Follow the repository's conventions — both explicit policy and the implicit
|
|
42
|
+
style sustained across its commit history — before falling back to this
|
|
43
|
+
skill's defaults for commit granularity, grouping, message format, and
|
|
44
|
+
verification.
|
|
45
|
+
4. Keep one commit per type of change: do not mix distinct types (`feat`,
|
|
46
|
+
`fix`, `refactor`, `perf`, `test`, `docs`, `build`, `ci`, `style`, `chore`)
|
|
47
|
+
in a single commit. Keep directly related tests, closely related
|
|
48
|
+
documentation, generated output, and lockfiles in the commit that makes the
|
|
49
|
+
change; give standalone test, documentation, or build/chore work its own
|
|
50
|
+
commit.
|
|
51
|
+
5. Never commit credentials, secrets, dumps, logs, temporary files, or agent
|
|
52
|
+
scratch artifacts.
|
|
53
|
+
6. Never add AI attribution, model names, generated-by text, or an AI
|
|
54
|
+
`Co-authored-by` trailer.
|
|
55
|
+
7. Never bypass hooks, force-add ignored files, create an empty commit, rewrite
|
|
56
|
+
public history, or force-push unless the user explicitly requests the exact
|
|
57
|
+
action and understands its consequence.
|
|
58
|
+
8. Do not discard, restore, delete, or silently unstage user changes.
|
|
59
|
+
9. Never push to a remote unless the user explicitly authorizes that push in
|
|
60
|
+
the current request. Committing, amending, or verifying does not authorize
|
|
61
|
+
pushing, and a request to commit is not a request to push.
|
|
62
|
+
|
|
63
|
+
## Establish policy, state, and intent
|
|
64
|
+
|
|
65
|
+
Confirm the repository and inspect its state and commit history:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
git rev-parse --show-toplevel
|
|
69
|
+
git branch --show-current
|
|
70
|
+
git status --short --branch
|
|
71
|
+
git diff --stat
|
|
72
|
+
git diff --cached --stat
|
|
73
|
+
git log --no-merges -n 50 --date=short --pretty=format:'%h %ad %s'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Stop if this is not a Git repository. If a merge, rebase, cherry-pick, or revert
|
|
77
|
+
is active, understand that operation before creating an ordinary commit.
|
|
78
|
+
|
|
79
|
+
Determine the conventions to follow by this precedence:
|
|
80
|
+
|
|
81
|
+
1. the user's instructions in the current request;
|
|
82
|
+
2. explicit repository policy (`AGENTS.md`, `CONTRIBUTING.md`, commit templates,
|
|
83
|
+
hook or linter configuration, and package guidance);
|
|
84
|
+
3. the repository's implicit style — the dominant pattern sustained over time in
|
|
85
|
+
commit history (also check `git log --no-merges -n 20 -- path/to/area` for
|
|
86
|
+
the touched area and `git log --no-merges -n 15 --format=medium` when
|
|
87
|
+
subjects alone are not enough), covering message format, language, casing,
|
|
88
|
+
scope/subsystem prefixes, trailers, and how commits group or split tests,
|
|
89
|
+
docs, and generated files; judge across a broad span of time rather than a
|
|
90
|
+
short recent sample that a single PR, contributor burst, or bot batch can
|
|
91
|
+
skew, and when the project's style clearly evolved, follow the current
|
|
92
|
+
sustained norm;
|
|
93
|
+
4. this skill's defaults below.
|
|
94
|
+
|
|
95
|
+
When contributing to an existing or open-source project, matching its explicit
|
|
96
|
+
and implicit norms takes priority over this skill's defaults. Use the
|
|
97
|
+
conversation to define intent; never assume the whole dirty tree belongs to the
|
|
98
|
+
current task.
|
|
99
|
+
|
|
100
|
+
## Inspect every candidate
|
|
101
|
+
|
|
102
|
+
Inspect in two stages so large unrelated files do not consume context merely
|
|
103
|
+
because the tree is dirty.
|
|
104
|
+
|
|
105
|
+
First inventory every candidate and classify its state:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
git diff --cached --name-status
|
|
109
|
+
git diff --name-status
|
|
110
|
+
git ls-files --others --exclude-standard
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Then read the full patch for every change intended for the commit and every
|
|
114
|
+
candidate that is suspicious, mixed, or needed to determine scope:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
git diff --cached -- path/to/candidate
|
|
118
|
+
git diff -- path/to/candidate
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Read relevant untracked files individually. Do not skip a candidate merely
|
|
122
|
+
because it is unrelated; record its state and confirm it will remain untouched.
|
|
123
|
+
Do not load a huge unrelated file in full when its metadata and focused
|
|
124
|
+
inspection are enough to establish that it must be excluded.
|
|
125
|
+
|
|
126
|
+
For each candidate, determine:
|
|
127
|
+
|
|
128
|
+
- what changed and whether it belongs;
|
|
129
|
+
- whether it is staged, unstaged, untracked, or partially staged (or ignored, if
|
|
130
|
+
the user explicitly named the path);
|
|
131
|
+
- whether it is generated, renamed, deleted, executable, a symlink, submodule,
|
|
132
|
+
or binary;
|
|
133
|
+
- whether it introduces a breaking change to a public API, CLI, configuration,
|
|
134
|
+
schema, or wire format;
|
|
135
|
+
- whether it contains credentials or accidental local data; and
|
|
136
|
+
- which logical commit, if any, it belongs to.
|
|
137
|
+
|
|
138
|
+
Treat unexpected binaries, archives, vendored trees, mass deletions, `.env`
|
|
139
|
+
files, keys, tokens, logs, dumps, coverage, editor metadata, debug output, and
|
|
140
|
+
agent artifacts as blockers unless their inclusion is clearly intentional.
|
|
141
|
+
Generated files and lockfiles are valid only when expected, tracked by project
|
|
142
|
+
policy, and reviewed.
|
|
143
|
+
|
|
144
|
+
Do not echo a discovered credential into the response or commit message. Use the
|
|
145
|
+
repository's secret scanner when available.
|
|
146
|
+
|
|
147
|
+
## Plan one commit per change type
|
|
148
|
+
|
|
149
|
+
Group by type of change first, then by logical purpose within a type, not by
|
|
150
|
+
file type or directory. Give each type of standalone work its own commit: a
|
|
151
|
+
feature, a fix, a refactor, standalone documentation, and standalone test,
|
|
152
|
+
build, CI, or chore work do not share a commit. Keep directly related tests,
|
|
153
|
+
closely related documentation, required generated output, and corresponding
|
|
154
|
+
lockfile or schema changes in the commit that makes the change. Order the
|
|
155
|
+
commits so each leaves the repository coherent — for example, a preparatory
|
|
156
|
+
refactor before the feature that depends on it, and standalone documentation
|
|
157
|
+
after.
|
|
158
|
+
|
|
159
|
+
Split independent behaviors, unrelated refactors, or changes that should be
|
|
160
|
+
reviewed, reverted, or bisected separately. Each commit should leave the
|
|
161
|
+
repository coherent and pass relevant checks when practical. If safe separation
|
|
162
|
+
requires guessing about ownership or manipulating uncertain partial staging,
|
|
163
|
+
ask the user.
|
|
164
|
+
|
|
165
|
+
In review-only mode, stop after reporting the proposed groups, exclusions,
|
|
166
|
+
risks, and suggested messages.
|
|
167
|
+
|
|
168
|
+
If the index already contains unrelated or uncertain staged changes, do not
|
|
169
|
+
create the requested commit and do not unstage them automatically. Ask whether
|
|
170
|
+
to include them, temporarily alter the index, or postpone the commit. Preserve
|
|
171
|
+
the index exactly while waiting for that decision.
|
|
172
|
+
|
|
173
|
+
## Stage deliberately
|
|
174
|
+
|
|
175
|
+
This section applies only to commit, amend, and fold-corrections modes.
|
|
176
|
+
|
|
177
|
+
Preserve the existing index. If the user already staged multiple in-scope
|
|
178
|
+
changes that must be split across planned commits, you may unstage and re-stage
|
|
179
|
+
them per commit group provided every pre-staged change is committed by the end
|
|
180
|
+
of the cycle. Prefer explicit paths or intentional hunk staging:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
git add -- path/to/file path/to/other-file
|
|
184
|
+
git add -p -- path/to/mixed-file
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Use `git add -A` only after reviewing the complete tree and confirming every
|
|
188
|
+
change belongs to one planned commit. Do not use `git add .` as a shortcut. Do
|
|
189
|
+
not use destructive commands to simplify staging.
|
|
190
|
+
|
|
191
|
+
Before every commit, run and inspect:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
git diff --cached --stat
|
|
195
|
+
git diff --cached --check
|
|
196
|
+
git diff --cached
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The cached patch must contain the complete logical change and nothing else. If
|
|
200
|
+
it is empty, do not create a commit unless the user explicitly requested an
|
|
201
|
+
empty commit.
|
|
202
|
+
|
|
203
|
+
## Verify the staged change
|
|
204
|
+
|
|
205
|
+
Run the smallest meaningful repository checks for the staged scope: focused
|
|
206
|
+
tests, formatting checks, linting, type checking, documentation checks, or a
|
|
207
|
+
targeted build. Follow documented commands when available.
|
|
208
|
+
|
|
209
|
+
Prefer check-only commands. Before running a formatter, generator, or other
|
|
210
|
+
mutating check, ensure its write scope cannot overwrite unrelated dirty work. If
|
|
211
|
+
that cannot be guaranteed, ask first. Inspect and stage any generated changes
|
|
212
|
+
deliberately.
|
|
213
|
+
|
|
214
|
+
If a relevant check or hook fails, keep the failure visible and ask how to
|
|
215
|
+
proceed. Never bypass it without explicit permission. After checks, re-run
|
|
216
|
+
`git status --short` and review the cached patch because tools and hooks may
|
|
217
|
+
change the tree.
|
|
218
|
+
|
|
219
|
+
## Write the message
|
|
220
|
+
|
|
221
|
+
Follow the repository convention established earlier. When using this skill's
|
|
222
|
+
English Conventional Commit default, format the message as:
|
|
223
|
+
|
|
224
|
+
```text
|
|
225
|
+
<type>(<scope>)[!]: <imperative summary>
|
|
226
|
+
|
|
227
|
+
<optional body>
|
|
228
|
+
|
|
229
|
+
<optional footer(s)>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Use the narrowest useful stable scope, or omit it when none is honest. Common
|
|
233
|
+
types are `feat`, `fix`, `refactor`, `perf`, `docs`, `test`, `build`, `ci`,
|
|
234
|
+
`chore`, `style`, and `revert`. Choose the type from purpose, not file extension;
|
|
235
|
+
avoid `chore` when a more precise type applies.
|
|
236
|
+
|
|
237
|
+
The subject must:
|
|
238
|
+
|
|
239
|
+
- use imperative mood;
|
|
240
|
+
- mark any breaking change with `!` immediately before the colon
|
|
241
|
+
(for example `feat(api)!: ...` or `refactor!: ...`);
|
|
242
|
+
- begin with a lowercase word after the colon (unless it is a proper noun,
|
|
243
|
+
acronym, or identifier);
|
|
244
|
+
- omit the final period;
|
|
245
|
+
- stay at or below 72 characters; and
|
|
246
|
+
- state a concrete outcome rather than "update," "changes," or filenames.
|
|
247
|
+
|
|
248
|
+
Add a body only when it explains motivation, user-visible impact, trade-offs,
|
|
249
|
+
compatibility, migration, or durable rationale that the subject cannot. Do not
|
|
250
|
+
narrate the diff. Separate it with a blank line and wrap prose at 72 characters.
|
|
251
|
+
When a commit introduces a breaking change, always include `!` before the colon
|
|
252
|
+
in the subject and explain what broke and how to migrate in the body or a
|
|
253
|
+
`BREAKING CHANGE:` footer.
|
|
254
|
+
|
|
255
|
+
In message-only mode, base suggestions only on the inspected diff and stop after
|
|
256
|
+
returning the proposed message; do not stage or commit. Use the staged diff when
|
|
257
|
+
the index is non-empty. If staged and unstaged changes represent different
|
|
258
|
+
purposes and the user did not identify one, ask which patch the message should
|
|
259
|
+
describe.
|
|
260
|
+
|
|
261
|
+
## Commit and verify
|
|
262
|
+
|
|
263
|
+
For each logical group, commit only after its cached patch and checks pass. Then
|
|
264
|
+
verify what Git recorded:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
git show --format=fuller --stat --patch --no-ext-diff HEAD
|
|
268
|
+
git status --short
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Read the recorded message and patch. Hooks may alter files or messages. Repeat
|
|
272
|
+
the stage, review, verification, commit, and post-commit inspection cycle for
|
|
273
|
+
each additional group. If a later group or check reveals that a change belongs
|
|
274
|
+
to an earlier commit made in this session, fold it in as described in "Fold
|
|
275
|
+
corrections into earlier commits" instead of leaving a separate cleanup
|
|
276
|
+
commit.
|
|
277
|
+
|
|
278
|
+
Report each commit with its short hash, exact subject, and one sentence
|
|
279
|
+
summarizing its contents. Mention remaining changes only when they need the
|
|
280
|
+
user's attention, especially intentional exclusions or suspicious files. Do not
|
|
281
|
+
push afterward; pushing is a separate action that requires explicit
|
|
282
|
+
authorization.
|
|
283
|
+
|
|
284
|
+
## Amend only when history safety is established
|
|
285
|
+
|
|
286
|
+
Amend only when requested or when a correction clearly belongs to a commit just
|
|
287
|
+
created in this session. Confirm that `HEAD` is local and unshared:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
git branch --show-current
|
|
291
|
+
git status --short --branch
|
|
292
|
+
git rev-parse --abbrev-ref --symbolic-full-name '@{upstream}' 2>/dev/null
|
|
293
|
+
git log --oneline '@{upstream}..HEAD' 2>/dev/null
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Do not infer safety from a missing upstream. Avoid amending `main`, `master`, a
|
|
297
|
+
protected branch, or any branch that may be shared. Ask when uncertain.
|
|
298
|
+
|
|
299
|
+
Before `git commit --amend`, review the complete result: existing `HEAD` plus the
|
|
300
|
+
staged patch. Preserve the message with `--no-edit` only when it still describes
|
|
301
|
+
the whole amended commit; otherwise rewrite it. Do not rebase, reset, or
|
|
302
|
+
force-push as an incidental part of amending; the only other history rewrite
|
|
303
|
+
this skill performs is the scoped `--autosquash` rebase described in "Fold
|
|
304
|
+
corrections into earlier commits".
|
|
305
|
+
|
|
306
|
+
## Fold corrections into earlier commits
|
|
307
|
+
|
|
308
|
+
You may discover mid-session that a change belongs to a commit already made in
|
|
309
|
+
this session: a missed hunk of a fix, a test, a closely related documentation
|
|
310
|
+
tweak. Fold it into that commit instead of leaving a separate cleanup commit.
|
|
311
|
+
|
|
312
|
+
First confirm the target commit is local, unshared, and created in this session
|
|
313
|
+
(or explicitly identified by the user) using the amend-safety checks above. Stop
|
|
314
|
+
and ask when the target may be shared. Then choose the mechanism by where the
|
|
315
|
+
target sits:
|
|
316
|
+
|
|
317
|
+
- **The target is still `HEAD`:** stage the correction and `git commit --amend`
|
|
318
|
+
it.
|
|
319
|
+
- **The target is earlier than `HEAD`:** stage the correction and create a
|
|
320
|
+
fixup commit:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
git commit --fixup=<target-hash>
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Then fold it into the target with a scoped autosquash rebase once the tracked
|
|
327
|
+
working tree and index are clean:
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash <base>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
`<base>` is the parent of the earliest commit being rewritten — typically the
|
|
334
|
+
upstream tip or the ref where this session's work began.
|
|
335
|
+
`GIT_SEQUENCE_EDITOR=:` accepts the pre-ordered todo list without opening an
|
|
336
|
+
editor. The rebase still stops on conflicts; resolve them and
|
|
337
|
+
`git rebase --continue`, or `git rebase --abort` to restore the pre-rebase
|
|
338
|
+
state when the fold is not worth the trouble.
|
|
339
|
+
|
|
340
|
+
`git rebase` requires a clean tracked working tree and index. If other planned
|
|
341
|
+
commit groups remain in this session, leave the `fixup!` commit in place and
|
|
342
|
+
run one autosquash rebase after the remaining groups are committed. If
|
|
343
|
+
unrelated tracked changes are dirty in the working tree or index, do not stash
|
|
344
|
+
or alter them silently; leave the `fixup!` commit in place and ask the user how
|
|
345
|
+
to proceed. Never push or share a history that still contains `fixup!` or
|
|
346
|
+
`squash!` commits, and never force-push a rebased branch without explicit
|
|
347
|
+
authorization.
|
|
348
|
+
|
|
349
|
+
After a rebase, re-verify with `git status --short`, `git show` on the
|
|
350
|
+
rewritten commits, and the checks that apply to the folded change.
|
|
351
|
+
|
|
352
|
+
## Adversarial staging example
|
|
353
|
+
|
|
354
|
+
Suppose the tree contains:
|
|
355
|
+
|
|
356
|
+
- staged `src/cache.rs` from unrelated prior work;
|
|
357
|
+
- unstaged `src/auth.rs` and `tests/auth.rs` for the requested fix; and
|
|
358
|
+
- untracked `.env` containing local configuration.
|
|
359
|
+
|
|
360
|
+
Do not commit. The existing staged file is outside the requested scope and must
|
|
361
|
+
not be silently unstaged, while `.env` is suspicious and must never be staged
|
|
362
|
+
without clear intentional handling. Preserve the index, report both blockers,
|
|
363
|
+
and ask how the user wants to handle the unrelated staged change. Do not echo
|
|
364
|
+
any `.env` values.
|
|
365
|
+
|
|
366
|
+
## Stop conditions
|
|
367
|
+
|
|
368
|
+
Stop and ask rather than guessing when:
|
|
369
|
+
|
|
370
|
+
- ownership or scope is unclear;
|
|
371
|
+
- staged work is unrelated or cannot be separated safely;
|
|
372
|
+
- a likely secret, suspicious artifact, unexpected binary, or mass deletion is
|
|
373
|
+
present;
|
|
374
|
+
- relevant checks or hooks fail;
|
|
375
|
+
- repository guidance conflicts or grouping is materially ambiguous;
|
|
376
|
+
- amending may rewrite shared history;
|
|
377
|
+
- a correction would have to be folded into a commit that is shared or cannot
|
|
378
|
+
be identified as this session's work, or rebasing is blocked by unrelated
|
|
379
|
+
dirty tracked files;
|
|
380
|
+
- a request implies publishing or updating a remote without explicitly
|
|
381
|
+
authorizing `git push`; or
|
|
382
|
+
- the requested action would require discarding work, force-adding ignored
|
|
383
|
+
files, bypassing safeguards, or creating an unrequested empty commit.
|