git-helpers
Git Helpers
Recommended effort: medium for code review; low for commit, PR, and branch operations.
Git workflow with conventional commits, confidence-scored code review, and automated PR management.
Workflow
commit --> review --> summary --> create-pull-request --> finish-branch
Each step is independent. Use any workflow in isolation or chain them together.
Sub-agent Dispatch
Code review parallelizes via lens fan-out. After the main agent annotates the diff and clears the size gate, it selects active lenses based on the changed files (minimum 3, maximum 5), then dispatches them in a single turn -- each reads the same annotated diff under a focused scope and returns markdown findings. The main agent consolidates (dedup, severity sort, gap detection, partial-run handling) and renders the final report.
- Lens sub-agents -- up to five scopes (
security,bugs,data-loss,performance,guidelines).security,bugs, andguidelinesalways run;data-lossandperformanceactivate only when the diff contains relevant patterns (see code-review.md Step 7). Each receivesANNOTATED_DIFF(with[L<n>]line markers as the citation allowlist), the lens-specific scope, and the universal rules block (code-review.md Step 8). - Consolidation is main-agent work -- dedup across lenses on
file:line, severity-sorted output, gap detection, highlight collation, and partial-run header when a lens errors (code-review.md Step 9). Cross-lens visibility cannot be split across sub-agents.
Commit, summary, create-pull-request, and finish-branch run inline on the main agent (single-output workflows, no fan-out value).
Context Loading Strategy
Load only the reference matching the current trigger. Never load multiple references simultaneously unless explicitly noted (code-review.md loads guidelines-audit.md as part of its process).
Triggers
| Trigger Pattern | Reference |
|---|---|
| Commit changes, create commit, done, ready to commit | commit.md |
| Review code, check changes, check my code | code-review.md |
| Summarize changes, generate PR description | summary.md |
| Push branch, create PR, open pull request, ready to push | create-pull-request.md |
| Finish branch, merge branch, merge PR, cleanup branch | finish-branch.md |
Notes:
guidelines-audit.mdis not a direct trigger. It is loaded bycode-review.mdas part of the review process.
Cross-References
code-review.md -------------> guidelines-audit.md (loaded by guidelines lens at fan-out)
create-pull-request.md -----> templates/pull-request.md (PR body template)
finish-branch.md -----------> commit.md (squash commit message conventions)
Guidelines
DO:
- Preview commit messages before committing -- always show and ask for confirmation
- Use confidence scoring: only report findings with confidence >= 80
- Default base branch: main (user can override)
- Use imperative mood in commit messages and PR titles
- Use HEREDOC format for multi-line commit messages
- Analyze actual diff and staged files
- Follow existing project conventions for commit message format
- Prefer single-line commit messages -- only add body for complex or breaking changes
DON'T:
- Add attribution lines in commit messages or PRs
- Base analysis on conversation context instead of actual diff
- Report findings with confidence < 80
- Override project conventions with generic rules
Output
| Reference | Output |
|---|---|
| summary.md | PR_SUMMARY.md (PR description with impact assessment) |
| code-review.md | Terminal output or PR comment (optionally saved to CODE_REVIEW.md) |
Error Handling
- No changes to commit: inform user working tree is clean
- gh cli not available: stop and inform user to install it
- No guideline files found: skip guidelines audit, report it
- Merge conflicts: stop and inform user to resolve first