Commit separately

From laurynas-biveinis/dotfiles · View interactive version

Commit separately is an AI agent skill from the GitHub repository laurynas-biveinis/dotfiles. Isolate one change into its own commit. Use only for changes the subagent can execute without judgement or dialogue: extracting an unambiguous slice of current working-tree changes, or a fully-determined operation like a symbol rename. Name any untracked path the slice needs: the stash does not carr

How to use this skill

Skill file

Commit Separately

You are running as the forked commit-separately skill. This document is your

complete task — there is no separate user request. Execute the numbered steps

now, using $ARGUMENTS as the requested change.

The caller must arrange exclusive use of this checkout and the repository's

stash list until the fork returns, including stash operations in other

worktrees. Save tracked-file buffers before invocation; the caller must keep

unrelated checkout readers and writers idle. Abort before stashing unless the

caller has established these preconditions.

Every abort uses the failure return below. If a step cannot be completed,

abort; keep partial edits and recovery data in place.

  1. Abort if $ARGUMENTS requires design choices or back-and-forth discussion.
  2. Abort if the index already contains staged changes. Restoring that index

after extracting a staged slice can fail on the newly committed content.

  1. Choose a unique invocation marker and record

git stash list --format='%H %gd %gs'. Stash the current working tree

changes with git stash push -m "commit-separately: <marker>" — not

-u, which would take the untracked files the baseline relies on. Read

the same stash listing again: record the new marked entry's full object

ID, or record "nothing stashed" if the push succeeded and the list is

unchanged. A clean tree is a valid input. If the push fails or the new

entry cannot be identified unambiguously, stop using the failure return

below. Then write the output of git status --porcelain -uall to

/tmp/commit-separately-<topic>-baseline.txt, outside the repository,

where <topic> is a 1-3 word kebab-case slug derived from $ARGUMENTS:

whatever that listing still reports survived the stash, so those paths

predate this change.

  1. For an extraction, read tracked changes from

git stash show -p <recorded-object-id> when an entry was created; read

caller-named untracked or dirty-submodule content from the checkout. Apply

only the requested slice with Edit/Write or working-tree-only git apply,

never --cached or --index. For a mechanical operation, make the requested

change directly. Record which paths this step and the check/fix step change.

  1. Run ./check.sh if present, fix any errors, repeat as needed. Abort if

fixing them requires design choices or back-and-forth discussion.

  1. Form the staging candidate set from (a) every path

git status --porcelain -uall now reports that the baseline file does not,

including one a ./check.sh fix landed on; and (b) every path $ARGUMENTS

names as part of the slice, including one whose status record is unchanged

because it was already untracked, or is a submodule the stash left dirty.

Check every candidate against the recorded changes from the preceding two

steps and the caller-named slice. Abort and report any candidate you cannot

account for; a new status record alone does not establish ownership. Stage

only that verified set. Leave any other edit this invocation made unstaged; report

it on return. If staging is denied, abort through the failure return with

the path and denial. Do not retry with quoting, escaping, a directory

argument or git apply. Enumerate the files:

glob, or a directory, except a caller-named submodule path already tracked

as a gitlink. An untracked nested Git repository reports as a single

directory entry even under -uall, and staging it records a gitlink rather

than the files.

--cached.

  1. Draft the commit message.
  2. Call /commit skill with the drafted commit message to commit. Note in the

skill invocation that the commit message draft is only a suggestion and that

the commit skill is responsible for verifying and crafting the final message.

Require a resulting commit hash and final message; on a non-commit return,

abort through the failure return before attempting restoration.

  1. If nothing was stashed, skip restoration and continue to the success

return. Otherwise, run git stash pop 'stash@{0}'; the exclusive-use

precondition keeps this invocation's stash on top.

  1. On any pop failure, including conflicts, use the failure return; do not

resolve or stage the conflicts. A failed pop can leave its entry in the

stash list; retain it as recovery data and report it.

  1. On success, return the commit hash and final message from the commit skill,

whether restoration succeeded or was skipped because nothing was stashed,

and any path this invocation left deliberately unstaged, with its reason.

Failure return: stop without further mutations. Report the reason, the

commit hash and message if one was made (otherwise say no commit was made),

and the current working-tree/index state from git status --porcelain -uall,

including staged and unmerged paths. Report the invocation's stash marker,

object ID and current selector when known. Distinguish stashing not attempted,

nothing stashed, and an entry missing or uncertain; never identify another

entry as this invocation's. Retain any surviving invocation stash as recovery

data. A commit alone does not mean the procedure succeeded.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.