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.
- Abort if $ARGUMENTS requires design choices or back-and-forth discussion.
- Abort if the index already contains staged changes. Restoring that index
after extracting a staged slice can fail on the newly committed content.
- 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.
- 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.
- Run
./check.shif present, fix any errors, repeat as needed. Abort if
fixing them requires design choices or back-and-forth discussion.
- 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:
- Pass each path as its own
git add/git rmargument, never-A,., a
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.
- Use no option but
git add's--intent-to-addorgit rm's
--cached.
- Draft the commit message.
- Call
/commitskill 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.
- 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.
- 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.
- 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.