Maintain Git's scope, identity, candidates, and delivery rules. First read user authorization, project rules, and the complete task card to determine the repository, allowed paths, target branch, expected identity, and acceptance; only load the reference documents needed for the current scenario.
Scenario routing
Read the contract for that row before the corresponding operation; read cross-scenario tasks in execution order, and do not load all references at once.
| Current requirement | Read and execution entry |
|---|---|
| Local isolated development through delivery, baseline lagging, or shared main tree occupied | Local Worktree SOP |
| Create or narrow a Skill/suite worktree, cross-directory occupancy audit | Sparse worktree; for creation use scoped-worktree.py, for fully registered read-only audit use sparse-worktree-audit.py |
| Commit identity, Co-authored-by contamination, already-merged history receipt, full PR scope push | Identity and push, then read by contentPrivacy precheck |
| PR creation/review/merge, CI unknown, conflicts, or updating base | PR process; for text and full history verification readPrivacy precheck |
| Main directory pinned to main, all Agents develop in independent worktrees, named integration | Main directory branch protection; the main directory is read-only by default, and the command front door for named adoption is disabled main-git-gate.py / test-main-git-gate.py; the history index lock is only verified/released |
| Monorepo narrow adoption, cherry-pick and conflicts | Change integration |
| Incident recovery for mistaken amend / stash / branch deletion / reset | Incident recovery; locate evidence first, then recover according to authorization |
| Continuous Skill iteration, candidate observation, long-term feature line or milestone | Long-term integration branch |
| Branch/worktree cleanup, batch acceptance, or replacing and closing old PRs | Lifecycle and cleanup; for read-only inventory use branch-audit.sh / worktree-audit.sh |
| Short task/milestone/sub-branch naming, Commit / Issue / PR titles and closing semantics | Naming and commit format |
| GitHub Actions minutes exhausted, suspended, or restored | CI quota governance |
| Sensitive/private material has already been published and needs to be retracted from history | History retraction |
| Repository or object database bloat, configuration sync repository slimming | Bloat audit; first distinguish history, checkout, cache, and task materials |
| Look up gh parameters | gh quick reference, command examples are still bound by the corresponding contract |
Script names in this Skill are relative to the skill directory. When executing, set git_workflow_dir to the absolute path of this skill's installation directory and run it in the target repository; do not switch to the skill source repository just to call scripts. This document and the reference documents provide methods and cannot replace the user's authorization for external writes or destructive operations.
Shared Constraints
- Preserve existing changes, staging state, task materials, and other session ownership. Prefer reusing a suitable isolated checkout; do not clear others' work in progress via stash/reset/switching the shared main tree. Before committing, verify the actual branch and identity; worktrees share the repo-local Git configuration by default, and workers do not write
user.name/email。 - Single Skill/named suite by defaultsparse checkout at creation. Before side effects, fix the target, real dependencies, baseline, and disk budget; if the entry point does not support directory scope, stop before creation, and do not treat missing parameters as blanket permission. For narrowing existing trees, first protect dirty/index, ignored/untracked, and Session; detailed methods are maintained only in the sparse contract.
force push、reset --hard, discarding changes,clean -f, force-deleting branches, skipping hooks/signatures, and rewriting history require specific explicit authorization. For locks, check the holder first, do not delete directly; after a hook failure, fix it and create a new commit, do not bypass. Default to a new commit; amend requires user request; stage files precisely.- Ordinary commit publication goes through
safe-push.sh, identity and privacy verificationfull PR rangeand binds an immutable OID; do not check only HEAD, useHEAD~1to narrow the range or bare push to bypass the gate. When creating/merging a PR, usesafe-pr.pyto verify the final full text and exact head; do not use unchecked automatic descriptions. Explicitly authorized history rewrites and precise ref deletions are executed per the corresponding dedicated page, and this exception cannot be used to bypass ordinary publication gates. - Merging must bind authorization, a readable diff, allowed scope, independent review, and final checks. Stop when unknown, failed, missing, or candidate drift occurs; helpers do not replace these gates. Do not bypass repository protections, self-approve restrictions, or use admin override.
- Monorepos do not do local direct feature→main merges. Adopt narrowly according to the actual allowed scope or use a formal PR to preserve other modules on the target side; syncing trunk→long-lived feature line is another direction and follows the feature-line contract.
- Single-task cleanup binds the lifecycle and exact tip; long-lived branches and fixed trees are not deleted with sub-PRs. After a merged cleanup failure, record
CLEANUP_PENDING, do not replay push/merge; batch candidates do not equal deletion authorization. - When dependencies are missing, validation fails, or network results are unclear, preserve the first failure and the scene; verify the real result before retrying. Do not auto-install missing tools, do not downgrade to bypass gates, and follow the user's and project's existing authorization for environment installation.
All projects' Agent development, modification, testing, and commits are completed in their respective independent worktrees. The main directory is fixed to main and is used only for stable loading and serial adoption by the named integrator; switching back to main to fix drift is prohibited. Adoption must bind the full candidate, current HEAD, per-file scope, and the original index/dirty; stop that adoption when concurrent changes occur. Command gates deny add/commit in the main directory by default; only the named owner and the matching expected HEAD can enter the adoption path; this is not a mandatory security boundary for arbitrary programs. GUI/absolute paths/legacy runtime not yet integrated remain NOT_VERIFIED; do not reinstall the resident index.lock, and do not delete existing others' locks without authorization.
Execution and Closure
- Fix the scope and original scene, read the corresponding contract; ordinary short branches are based on the latest remote target, and long-lived lines fix this wave's OID. When the shared source is dirty, keep it as is.
- Execute within the allowed scope, run validation matching the artifacts, and review the full diff and final description. After candidate changes, rerun the affected checks.
- Before entering side effects such as commit, push, PR, and merge, verify the corresponding authorization and gates; return values do not replace the actual branch, PR metadata, or server-side merge receipt.
- Record actual artifacts, exit status, candidate OIDs, retained items, and unverified scope in the project's existing task source. Report local adoption, cloud delivery, and cleanup status separately; do not call static passing full-pipeline stability.
Dependencies
System Dependencies
| Dependency | Scope of use and installation method |
|---|---|
| Git | All Git operations; on macOS, the Git provided by Command Line Tools may be used; on Linux, use the distribution's package manager |
| Bash | .sh gates and auditing; use system Bash |
| Python 3.10+ | Privacy, PR, sparse creation/audit scripts; macOS: brew install python,Linux: apt install python3 |
| GitHub CLI(gh) | GitHub PR/CI and remote status queries; verify existing authentication first; macOS: brew install gh; on Linux, follow the GitHub CLI official installation instructions |
Python Packages
The Python entry point depends only on the standard library and does not require pip installation. For sparse auditing, the du / lsof and the gh degradation boundary for branch inventory are described in their respective contracts; missing evidence after degradation must be explicitly retained and must not be retroactively accepted as passing.
Collaboration Boundaries
git-batch-commit is responsible for the commit splitting and description generation explicitly requested by the user, following this Skill's identity/privacy and Issue closing rules; the project task source maintains status,multi-agent-orchestration is responsible for worker dispatch and sessions, continuing to reference the same sparse contract;release-workflow is responsible for releases and assets, while this Skill is responsible for daily Git/CI governance.
Project documentation health checks are integrated only within the project's existing processes and authorization; Git Workflow does not define their thresholds, directories, task statuses, or maintenance PR side effects, nor does it automatically dispatch or publish maintenance tasks due to the current request.