Commit and Push by Feature
Commit and push all changes to GitHub grouped by feature/function.
Process
Inspect changes:
- Run
git statusandgit diffto understand all changes.
- Run
Identify logical buckets:
- Group changes into feature/function buckets (e.g., "auth", "api", "ui", "tests", "docs", "build", "refactor"). Prefer 2–6 commits total unless the change set is tiny.
Commit each bucket:
- For each bucket:
- Stage only the files for that bucket (use
git add <paths>; avoidgit add -Aunless it's the final bucket and everything belongs together). - Create a conventional commit message:
feat(<scope>): <summary>for new functionalityfix(<scope>): <summary>for bug fixesrefactor(<scope>): <summary>for refactors without behavior changetest(<scope>): <summary>for tests onlydocs(<scope>): <summary>for documentationchore(<scope>): <summary>for tooling/config
- Include a short body only if it clarifies intent or risk.
- Verify
git diff --cachedmatches the bucket before committing.
- Stage only the files for that bucket (use
- If there are uncommitted leftover changes at the end, bucket them; do not leave a dirty working tree.
- For each bucket:
Branch handling:
- Determine the primary branch: prefer
main; if it does not exist, usemaster. If neither exists, stop and explain the blocker. - Ensure the commits land on the primary branch.
- If already on
mainormaster, stay there. - If on any other branch, switch to the primary branch before committing and pushing. Carry the working tree across only if it can be done safely.
- If switching would discard work, introduce conflicts you cannot resolve confidently, or otherwise prevent a safe move onto the primary branch, stop and explain the blocker. Do not push the feature branch instead.
- Determine the primary branch: prefer
Push and report:
- Push the resulting commits to the primary branch.
commit-and-push-by-featuremeans commit and push when the workflow succeeds. - Output a concise summary: branch name, list of commits (hash + subject), confirmation that working tree is clean, and whether push was performed or blocked.
- Push the resulting commits to the primary branch.
Output Format
## Commits
| Hash | Message |
|------|---------|
| abc1234 | feat(auth): add OAuth2 login flow |
| def5678 | docs(readme): update setup instructions |
Branch: current branch
Working tree: clean
Constraints
- Do not amend or rewrite history unless explicitly asked.
- Do not commit secrets; if you detect likely secrets, stop and report before committing.
- If pre-commit hooks/tests fail, fix and retry.
Default Shipping Contract
Follow the shared shipping contract convention in CLAUDE.md.