commit-work
Scannednpx machina-cli add skill jmerta/codex-skills/commit-work --openclawFiles (1)
SKILL.md
2.9 KB
Commit work
Goal
Make commits that are easy to review and safe to ship:
- only intended changes are included
- commits are logically scoped (split when needed)
- commit messages describe what changed and why
Inputs to ask for (if missing)
- Single commit or multiple commits? (If unsure: default to multiple small commits when there are unrelated changes.)
- Commit style: Conventional Commits are required.
- Any rules: max subject length, required scopes.
Workflow (checklist)
- Inspect the working tree before staging
git statusgit diff(unstaged)- If many changes:
git diff --stat
- Decide commit boundaries (split if needed)
- Split by: feature vs refactor, backend vs frontend, formatting vs logic, tests vs prod code, dependency bumps vs behavior changes.
- If changes are mixed in one file, plan to use patch staging.
- Stage only what belongs in the next commit
- Prefer patch staging for mixed changes:
git add -p - To unstage a hunk/file:
git restore --staged -porgit restore --staged <path> - If the commit is whole-file (no partial hunks), prefer the committer helper:
committer.ps1 "type(scope): summary" path1 path2 ...- If script execution is blocked, run:
pwsh -File committer.ps1 "type(scope): summary" path1 path2 ...
- If script execution is blocked, run:
- It clears the index and stages exactly the files you list (never use
.). - Use
--forceonly if git reports a stale.git/index.lock. - Skip it when you need partial hunks or a multi-line commit message body.
- Prefer patch staging for mixed changes:
- Review what will actually be committed
git diff --cached- Sanity checks:
- no secrets or tokens
- no accidental debug logging
- no unrelated formatting churn
- Describe the staged change in 1-2 sentences (before writing the message)
- "What changed?" + "Why?"
- If you cannot describe it cleanly, the commit is probably too big or mixed; go back to step 2.
- Write the commit message
- Use Conventional Commits (required):
type(scope): short summary- blank line
- body (what/why, not implementation diary)
- footer (BREAKING CHANGE) if needed
- Prefer an editor for multi-line messages:
git commit -v - Use
references/commit-message-template.mdif helpful.
- Use Conventional Commits (required):
- Run the smallest relevant verification
- Run the repo's fastest meaningful check (unit tests, lint, or build) before moving on.
- Repeat for the next commit until the working tree is clean
Deliverable
Provide:
- the final commit message(s)
- a short summary per commit (what/why)
- the commands used to stage/review (at minimum:
git diff --cached, plus any tests run)
Overview
Commit work helps you create commits that are easy to review and safe to ship. It emphasizes including only intended changes, keeping commits logically scoped, and writing messages that explain what changed and why, following Conventional Commits.
How This Skill Works
The workflow guides you to inspect the working tree, decide commit boundaries, and stage only what belongs in the next commit. Use patch staging for mixed changes, review the staged diffs with git diff --cached, craft a concise Conventional Commit message, then run quick verifications before moving on.
When to Use It
- When you are asked to commit changes or craft a final commit message.
- When changes are mixed within a single file and you need logical commits.
- When you want to enforce Conventional Commits for consistency.
- When you need to stage only selected hunks instead of whole files.
- When you want to verify the commit with a quick run of tests or lint before pushing.
Quick Start
- Step 1: Inspect the working tree with git status and git diff to see what changed.
- Step 2: Decide commit boundaries and stage changes with git add -p to include only what belongs in the next commit.
- Step 3: Write a Conventional Commits style message and run a quick verification before moving on.
Best Practices
- Inspect the working tree with git status and git diff before staging.
- Stage only what belongs in the next commit, using patch staging when needed.
- Split unrelated changes into separate commits to keep history clean.
- Describe the change in the commit message using the What and Why approach and follow Conventional Commits.
- Run the smallest relevant verification (tests, lint, or build) after each commit.
Example Use Cases
- Feature work and bug fix are split into separate commits with clear types and scopes.
- Refactor is kept in its own commit with a brief rationale in the body.
- A test addition is committed separately from the production code changes.
- Dependency bumps are isolated in a dedicated commit with a breaking change note if applicable.
- Debug logging removal is committed as a small focused change.
Frequently Asked Questions
Add this skill to your agents