agentleFS
2ykwang2ykwang/cview/.agents/skills/commit-fixup/SKILL.md

commit-fixup

Skill19 starsChanged 3 months agoMITView on GitHub

Absorb uncommitted working tree edits into the existing commits on the current branch where each change belongs (fixup commits + autosquash rebase). Use on requests like 'fold this into the original commit', 'clean up the commit history', 'squash the review fixes into their commits', 'fixup', 'amend into an existing commit', or when review feedback and polishing edits need to land in the right commit. Not for reordering commits already in history, and not for splitting a commit apart.

  • Deletes or force-pushes

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Unmapped: no commit touched it (new file, or a change to a file from outside the branch)

    line 51
  2. Distinctive:

    If the rebase conflicts, run git rebase --abort immediately and report.

    line 89
  3. Distinctive:

    Run the project's test suite once at the end if it has one.

    line 92
  4. Distinctive:

    Don't delete the backup branch on your own.

    line 93
  5. Distinctive:

    Always report with this template.

    line 97
  6. Distinctive:

    When you stop instead (unmappable, pushed branch, merge commits, conflict abort), skip this template and report what stopped you, what …

    line 124

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

commit-fixup

Absorb uncommitted changes into the existing commit each one should have been part of, leaving clean history. Four stages: safety checks → mapping → scope confirmation → execution and verification. This rewrites history, so don't skip any stage's checks.

1. Safety checks

git status --short                       # uncommitted changes
git merge-base HEAD origin/<default-branch>  # establish base (use the repo's default branch)
git log --oneline <base>..HEAD           # commits in scope
git branch -vv                           # upstream and push state
git log --merges --oneline <base>..HEAD  # merge commits in range
git --version

Tell the user before proceeding if any of these hit:

  • Branch already pushed → stop and ask. Rebasing means a force-push afterwards, and only the user makes that call. Never run a force-push on your own.
  • Merge commits in range → stop. The rebase flattens the merge structure.
  • git older than 2.44 → don't proceed. That version lacks the non-interactive git rebase --autosquash this skill relies on. Say the git version is too old to automate this safely and point at an upgrade (macOS: brew upgrade git, Ubuntu: apt upgrade git).
  • Untracked files are not absorption targets. Leave them alone.

2. Mapping: find the target commit for each changed file

For each modified file, find the commit in branch range that touched it last:

git log --oneline <base>..HEAD -- <file> | head -1

Why last-toucher: even when an earlier commit is the semantic owner, if a later commit also touched the file, fixing up into the earlier one makes the rebase conflict. The last-toucher rule guarantees a conflict-free, fully automatic rebase. It trades a little history aesthetics for safety — call out the affected files in the mapping table.

Mapping results fall into three buckets:

  • Mapped: a commit in the branch touched that file
  • Unmapped: no commit touched it (new file, or a change to a file from outside the branch)
  • One file's changes needing to split across several commits → references/edge-cases.md

3. Confirm scope (user confirmation required)

Identify the situation, show the mapping table first, then confirm via AskUserQuestion:

SituationAction
Everything mappedShow the table, confirm you should proceed
Mixed (only some mapped)Ask how to handle unmapped files: new separate commit / leave in working tree / stop
Nothing mapped, or 0–1 commits on the branchNothing for this skill to do. Say so and suggest a normal commit or a plain amend

Absorption is history rewriting. Never execute without the table — the user's chance to review the placement is what makes this workflow trustworthy. In an automated environment with no way to ask, print the table and proceed only in the "everything mapped" case. Stop and report on mixed and unmapped cases.

4. Execute and verify

# Files heading for the same target commit go into one fixup commit
git add <files...> && git commit --fixup=<target-sha>
# ... repeat per target commit

# Recovery point: snapshot the current state, fixup commits included, as a backup branch.
# This is what lets the user find a recovery point with plain `git branch` long after the session ends.
git branch <branch>-fixup-backup   # append -2, -3 if the name is taken

git rebase --autosquash <base>

# Lossless check: output must be empty. Proof that content is unchanged and only placement moved.
git diff <branch>-fixup-backup HEAD

# Residue check: any leftover fixup! commit means it failed
git log --oneline <base>..HEAD
git status --short   # must be clean
  • If the rebase conflicts, run git rebase --abort immediately and report. A conflict signals a mapping error, not something to resolve on the spot. Aborting returns to a safe state with the fixup commits sitting at the tip, so nothing is lost.
  • Run the project's test suite once at the end if it has one.
  • Don't delete the backup branch on your own. That call belongs to the user who reviewed the result.

5. Report

Always report with this template. Same information in the same place every time, so the user can spot trouble by skimming the verification block.

## Absorption complete

| Modified file | Absorbed into |
|---|---|
| <file> | <sha> <commit subject> |

**Final history** (<base>..HEAD)
```
<git log --oneline output>
```

**Verification**
- Lossless: <"backup and HEAD identical (empty diff)" or the failure>
- fixup residue: <"none" or the remaining commits>
- Working tree: <"clean" or remaining changes>
- Tests: <result, "n/a" when there's no suite>

**Recovery and cleanup**
- Backup branch: `<branch>-fixup-backup`
- If the result is wrong: `git reset --hard <branch>-fixup-backup`
- Once verified: `git branch -D <branch>-fixup-backup`

When you stop instead (unmappable, pushed branch, merge commits, conflict abort), skip this template and report what stopped you, what state the repo is in now, and what the options are.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.