cf:git · diff

v1.0.0 to v1.1.0

37 added, 44 removed. Audit A to A.

---
name: hapo:git
description: "Hapo Native Git Operations & Worktree Management. Handles safe commits, conventional split, branch finish choices, secret scanning, and sibling-branch worktrees locally."
user-invocable: true
when_to_use: "Invoke for commits, PRs, branch hygiene, or worktree management."
category: dev-tools
keywords: [git, commits, pr, worktree]
argument-hint: "commit | push | pr | finish | worktree <feature-desc>"
metadata:
author: haposoft
- version: "1.0.0"
+ version: "1.1.0"
---
# Git Operations & Worktree
- This skill merges Version Control Systems (VSC) capabilities and parallel Worktree management into a single, clean-room execution engine utilizing pure Bash commands rather than proprietary Node scripts.
+ Git operations and worktree management using plain `git` commands.
- **Mantra:** Secure, Conventional, and Isolated.
+ ## Default (no arguments)
+ Present options via AskUserQuestion — header "Git Operation": commit / push / pr / finish / worktree.
## Commands
-
- ### 1. Version Control Engine
- - **`commit`**: Scan secrets, analyze diff, auto-split chunks into conventional commits.
- - **`push`**: Securely push to the current branch.
- - **`pr`**: Propose merging current feature into `develop` or `main`.
- - **`finish`**: Verify current branch/worktree, then present explicit finish options.
-
- ### 2. Worktree Engine (Safe Parallel Development)
- - **`worktree <feature-description>`**: Creates a sibling directory alongside the current repo to isolate dependencies and database contexts without dirtying the main worktree.
-
- ## Core Directives
+ - `commit`: secret scan → analyze diff → split into conventional commits.
+ - `push`: push current branch.
+ - `pr`: push + open PR. Target = the repo's integration branch — detect via
+ `gh repo view --json defaultBranchRef` or `origin/HEAD`; never assume `main`/`develop`.
+ - `finish`: fresh `git status` + verification, then present exactly 4 options:
+ merge locally / push + PR / keep branch-worktree / discard (typed confirmation).
+ - `worktree <desc>`: sibling dir `../<project>-<branch>` for isolated setup.
- ### 1. Native Bash Execution Only
- - DO NOT rely on external JS/CJS scripts to evaluate git. Use pure system `git` CLI logic in bash.
- - Always check the status first: `git status && git diff --cached --stat`
+ ## Secret scan (before every commit)
+ ```bash
+ git diff --cached | grep -inE '\b(api[_-]?key|secret|password|credential(s)?|token)\b\s*[:=]'
+ ```
+ Match → STOP: show the lines, refuse to commit, suggest `.gitignore` + `git rm --cached`.
+ (Word-boundary + assignment context: "tokenizer" no longer false-positives.)
- ### 2. Pre-Commit Security Audit
- - Always run secret detection before creating a commit:
- ```bash
- git diff --cached | grep -iE "(api[_-]?key|token|password|secret|credential)"
- ```
- - If a secret is matched: **HALT!** Refuse to commit. Demand the user add the file to `.gitignore` and run `git rm --cached <file>`.
+ ## Split rules
+ Split when: mixed types (feat+fix), mixed scopes, config/deps mixed with code, >10 unrelated files.
+ Single commit when: same type+scope, ≤3 files, ≤50 lines.
- ### 3. Smart Worktree Strategy
- - Never run branching logic within the same root if the task requires heavy, isolated setup.
- - Worktrees MUST be created as *sibling directories*: `../<project-name>-<feature-branch>`.
+ ## Output
+ ```
+ ✓ staged: N files (+X/-Y)
+ ✓ secrets: none
+ ✓ commit: <hash> type(scope): description
+ ✓ pushed: yes|no
+ ```
- ### 4. Finish Branch Protocol
- - Before merge, push, PR, or discard, run a fresh status and verification check:
- ```bash
- git status --short
- git branch --show-current
- ```
- - If uncommitted changes exist, route through `commit` or ask whether to keep them unstaged.
- - Present explicit finish options:
- 1. Merge locally into the target branch.
- 2. Push current branch and open/update a PR.
- 3. Keep the branch/worktree for later.
- 4. Discard branch/worktree only after typed confirmation.
- - Never force-push or delete worktrees without explicit user confirmation.
- - If running inside a git worktree, detect it with `git worktree list` and clean up only the worktree created for this task.
+ ## Errors
+ | Error | Action |
+ |---|---|
+ | Secrets matched | Block; show lines |
+ | Nothing staged | Exit cleanly |
+ | Push rejected | Suggest `git pull --rebase` |
+ | Conflicts | List files; never auto-resolve |
- ## References & Protocols
+ Never force-push or delete a worktree without explicit confirmation.
- - `references/commit-protocols.md`: Strict rules for analyzing Git Diffs and determining commit splitting behavior.
- - `references/finish-branch.md`: Finish branch / PR / worktree closeout protocol.
- - `references/worktree-blueprint.md`: The 4-step Bash process to accurately construct an out-of-bounds Git Worktree Environment.
+ ## References (unchanged)
+ - `references/commit-protocols.md` · `references/finish-branch.md` · `references/worktree-blueprint.md`