plugins/ls-git/skills/git-edit-commit/SKILL.md
Use when needing to fixup, squash, drop, reword, reorder, or edit commits in a branch's history. Handles the non-interactive approach agents need since `git rebase -i` requires a TTY.
npx skillsauth add LandonSchropp/agent-toolkit plugins/ls-git/skills/git-edit-commitInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill outlines how agents can edit previous commits. Agents can't use git rebase -i directly, which requires a TTY. This skill provides helper scripts instead.
REQUIRED: Always reference commits by SHA, not by HEAD-relative notation like HEAD~3.
Run git log --oneline to get SHAs. Output is newest-first; the rebase plan is oldest-first.
To fold staged changes into the most recent commit without changing its message:
git add <files>
git commit --amend --no-edit
git commit --fixup=<target-sha> # merge into target, discard message
git commit --squash=<target-sha> # merge into target, combine messages
# <oldest-sha-in-scope>^ is the parent of the oldest commit in scope; use --root if it's the first commit
scripts/non-interactive-git-rebase.sh --autosquash <oldest-sha-in-scope>^
Use scripts/non-interactive-git-rebase.sh. Supply the plan via stdin. Use --root when the oldest commit in scope is the repository's first commit.
scripts/non-interactive-git-rebase.sh <oldest-sha-in-scope>^ <<'PLAN'
pick abc1234 Keep this commit
squash def5678 Merge this into the previous
drop ghi9012 Remove this commit entirely
PLAN
Mark the commit edit in the plan. Git pauses there. Then:
git add <files>
git commit --amend --no-edit
git rebase --continue
scripts/reword-commit.sh --sha <sha> --message "New commit message"
| Thought | Reality |
| ------------------------------------------------- | ---------------------------------------------------------------- |
| "I can't do interactive rebase without a TTY" | Use scripts/non-interactive-git-rebase.sh instead |
| "I'll use HEAD~N as the upstream" | Use a SHA — HEAD~N is fragile and ambiguous |
| "I'll just --amend instead" (for an older commit) | --amend only works on the latest commit; use rebase for others |
| "I'll undo the commits and redo them one by one" | Rebase rewrites history in one step — no need to redo commits |
| "I'll create a new commit to fix it" | That pollutes history; rebase is the right tool |
tools
Use when a finished, reviewed branch is committed and needs to be merged into the default branch in a repo that integrates directly to `main` (not via pull request).
tools
Use when working with a stack of GitHub pull requests — creating branches, keeping the stack in sync, or merging in order. Covers Git Town setup, PR targeting, rebasing, and landing the stack.
tools
Use when writing or modifying tests in a Bun project
tools
Use when publishing or releasing a new version of an npm/pnpm/yarn/bun package to the registry. Covers package-manager detection, semver bump selection, tagging, pushing, scoped-package access, authentication, and one-time passwords (OTP).