Imported from golifox/codex-skills (
konsierge-git-flow/SKILL.md). Install upstream withnpx skills add golifox/codex-skills --skill konsierge-git-flow. Copyright stays with the author.
Konsierge Git Flow
Treat this as the standing delivery workflow for Konsierge repositories.
This skill owns branch topology, commits, target integration, pushes, and delivery evidence. For commit-message selection and formatting, use konsierge-commit-conventions. That skill generates text only; this skill controls when and where the commit is created.
The global commit hook first identifies the repository. Repositories with any remote hosted exactly at gitlab.konsierge.com, or repositories explicitly configured with git config konsierge.commitPolicy true, use the KON rules below. Other repositories keep unrestricted branch names and require Conventional Commit subjects such as feat: add export or fix(api): reject invalid input; real Git merge and revert operations retain their generated subjects.
The global hook directory dispatches every standard Git hook back to an executable repository-local .git/hooks/<hook> when one exists. The global commit-msg policy runs first and then chains the repository-local commit-msg, so enabling policy enforcement must not silently disable existing project hooks.
A repository-local core.hooksPath overrides Git's global value before any global hook can run. Before every commit, inspect git config --local --get core.hooksPath. When it is set, do not commit until that hook manager explicitly invokes the Konsierge validator (or its effective commit-msg is installed with the global pre-commit config). This is an agent-side fail-closed preflight because Git provides no higher-precedence client-side hook. Never claim that the global installation covers a repository with an unintegrated local override.
Hard Rules
- Develop the feature and create its original commits in a ticket branch. A regular checkout may use either
KON-XXXXorKON-XXXX-<kebab-case-description>. A linked worktree must use the descriptive form, for exampleKON-0000-passes-cancellationorKON-1234-authorization-implementation, so concurrent worktrees remain distinguishable. - Use the concrete ticket from the request or current branch. When none exists, use
KON-0000; add a kebab-case description whenever the work is performed in a linked worktree. - Treat the
contractstree as out-of-scope by default. When the user did not explicitly ask to change contracts, ignorecontractscompletely: do not mention it in status/final reports, do not treat its dirty state as relevant, and do not include it in staging, commits, checks, or delivery decisions. - Never commit feature work directly to
devormaster. - Never push task branches or their
-devdelivery branches under any circumstance. - By default, merge the completed feature branch locally into every delivery target that exists on
origin: bothdevandmaster, onlydev, or onlymaster. - When
KON-XXXX-devalready exists locally or onorigin, or a directKON-XXXX->devmerge has conflicts that cannot be resolved safely, use the split delivery topology: mergeKON-XXXX-devintodevand the originalKON-XXXXintomaster. - Treat
KON-XXXX-devonly as thedevintegration branch. Update it fromorigin/dev; never merge it intomaster. - Push only the delivery targets that exist on
origin, after their local merges and checks succeed. If onlydevexists, push onlydev. If onlymasterexists, push onlymaster. Stop and ask for direction when neither exists. - When both targets exist, always push them sequentially: push
dev, require its successful staging deployment, then pushmasterand require its successful production deployment. Never push both targets together or start their pipelines concurrently; their parallel test jobs share temporary database infrastructure and can delete each other's databases. - Monitor pipelines and deployments only when the user explicitly requests monitoring or when both
devandmasterare being pushed. For a single-target push, verify the remote SHA and feature-commit containment, but do not monitor its deployment unless explicitly requested. - Never force-push, rebase, or rewrite
devormaster. - Keep every merge commit message generated by Git. Never pass
-m/--messagetogit mergeor edit the default merge message. - Merge only a local named task-branch ref. Never merge
FETCH_HEAD, a raw commit SHA, a filesystem path, or a repository URL into a delivery branch. When importing a branch from another worktree or clone, fetch it, create the correctly named local branch ref, and merge that ref. - Before pushing a delivery branch, inspect the merge subject. It must name only the task branch, for example
Merge branch 'KON-0000-passes-cancellation' into dev, and must not containFETCH_HEAD,.worktrees/,file://, a repository URL, or an absolute filesystem path. - When deployment monitoring is required, treat delivery as incomplete until GitLab MCP confirms every monitored target's exact pushed SHA deployed successfully to its environment.
Prepare
- Read repository instructions and inspect branch, status, staged/unstaged diffs, upstreams, recent subjects, and remote target state.
Also inspect
git config --local --get core.hooksPath; stop if a local override does not invoke the global commit policy. - Preserve unrelated and pre-existing changes. Do not switch branches with an unresolved dirty worktree.
- Fetch
originbefore starting and determine whetherdev,master, or both exist on the remote. Reuse the local task branch when present; otherwise create it from the repository's established base. If the base is genuinely ambiguous, ask. - Ensure a regular checkout branch matches
KON-[0-9]+(?:-[a-z0-9]+(?:-[a-z0-9]+)*)?. In a linked worktree, requireKON-[0-9]+-[a-z0-9]+(?:-[a-z0-9]+)*.
Commit in the Feature Branch
- Implement and verify the requested work.
- Build atomic commits using
konsierge-commit-conventions. Nearby repository history remains authoritative when it establishes a more specific convention. - Confirm the feature worktree is clean and relevant checks pass.
- Do not push the feature branch.
Merge Locally
Fetch origin again immediately before merging. First check which delivery targets exist and whether the matching task -dev branch exists locally or on origin. Apply the steps below only to existing target branches; skip every step for an absent target.
Default topology
When no KON-XXXX-dev branch exists and the feature branch merges into dev without unsafe conflicts:
- Switch to
dev, fast-forward it toorigin/dev, merge the feature branch with the repository's established merge style, and run relevant checks. - Switch to
master, fast-forward it toorigin/master, merge the same feature branch, and run relevant checks. - Stop on conflicts, failed checks, non-fast-forward target state, or unexpected commits. Do not push a partial delivery.
Split -dev topology
Use this path when KON-XXXX-dev already exists or the direct feature-to-dev merge cannot be resolved safely. This is used by repositories such as CRM when dev and master require different integration branches.
- Abort the conflicted direct merge into
dev, if one is in progress. - Check out the existing
KON-XXXX-devbranch, including fromorigin/KON-XXXX-devwhen only the remote branch exists; otherwise create it fromorigin/dev. - Merge the current
origin/devintoKON-XXXX-dev; do not rebase or reset the delivery branch. Bring over any missing feature commits from the originalKON-XXXXwith explicit cherry-picks, preserving the original feature branch formaster. - Resolve integration differences only on
KON-XXXX-dev, run the relevant checks there, then fast-forward localdevtoorigin/devand mergeKON-XXXX-devintodev. - Fast-forward local
mastertoorigin/masterand merge the originalKON-XXXXintomaster. - Never merge
KON-XXXX-devintomasteror the originalKON-XXXXintodevafter selecting this topology. Stop if either integration still cannot be resolved safely.
Prefer explicit merge commits when that matches the repository history:
# Default topology and `master` in split topology
GIT_MERGE_AUTOEDIT=no git merge --no-ff KON-0000-passes-cancellation
# `dev` in split topology
GIT_MERGE_AUTOEDIT=no git merge --no-ff KON-0000-passes-cancellation-dev
GIT_MERGE_AUTOEDIT=no only suppresses the editor; it preserves Git's default merge message. Do not replace it with a custom message.
If the task branch came from another worktree or clone, bind the fetched object to its descriptive name before merging:
git fetch /absolute/path/to/source-worktree KON-0000-passes-cancellation
git branch --force KON-0000-passes-cancellation FETCH_HEAD
GIT_MERGE_AUTOEDIT=no git merge --no-ff KON-0000-passes-cancellation
Never use git merge FETCH_HEAD in the delivery branch: Git can expose the source filesystem path in the generated merge subject.
Push Targets
When both local target branches are correct and verified, deliver sequentially:
-
Fetch
originand confirm localdevstill descends from the currentorigin/dev. -
Push only
dev:git push origin dev -
Monitor the exact pushed
devSHA and requiredeploy_stagingto succeed. Stop on any failed, canceled, skipped, or blocked job; do not pushmasterwhile the staging pipeline is unfinished or unsuccessful. -
Fetch
originagain and confirm localmasterstill descends from the currentorigin/master. -
Push only
master:git push origin master -
Monitor the exact pushed
masterSHA and requiredeploy_productionto succeed.
When only one target exists, fetch origin, confirm the local target still descends from its remote counterpart, push only that target, and verify its remote SHA plus feature-commit containment. Do not monitor its pipeline or deployment unless the user explicitly requested monitoring.
Never include the feature branch in a push refspec. Never use one atomic or multi-ref push for dev and master. If either remote target advanced, fetch, reconcile locally, rerun affected checks, then retry or report the blocker.
Verify every pushed remote target SHA and feature-commit containment after the push.
Monitor Deployments When Required
Enter this section only when the user explicitly requests deployment monitoring or both dev and master are being pushed. Otherwise stop after remote SHA and containment verification.
Use GitLab MCP to verify deployments. Resolve project_id from the origin URL; do not ask for it when it is available locally. Activate the pipelines and ci tool categories with discover_tools when their tools are not already available.
Monitor each pushed target before pushing the next one:
| Branch | Environment |
|---|---|
dev |
staging |
master |
production |
- Call
list_pipelineswith the branch and exact SHA. Select only the pipeline for that SHA; never substitute an older successful pipeline. - Poll
get_pipelinewhile the pipeline is non-terminal. Recheck at progressively longer intervals instead of rapid polling. - Call
list_pipeline_jobsand identify the deployment job for the expected environment from its name, stage, and environment metadata. Require that exact job to finish withsuccess; pipeline success alone is not deployment proof. - When GitLab exposes environment/deployment records, resolve them with
list_environmentsandlist_deployments, then confirm withget_deploymentthat the matching environment, branch, and SHA succeeded. If the project does not create deployment records, use the successful exact-SHA deployment job as the proof. - Continue until every monitored deployment succeeds. Treat
failed,canceled,skipped, or blockedmanualdeployment jobs as unsuccessful. Do not retry, play, cancel, or otherwise mutate a pipeline unless the user explicitly requests it.
On failure, inspect the failed deployment job with get_pipeline_job or get_pipeline_job_output and report the pipeline, job, environment, SHA, status, URL, and concise failure evidence. Do not claim delivery succeeded.
Report feature commits, merge commits for existing targets, remote SHAs, checks, and final worktree state. When monitoring was required, also report each monitored pipeline/job or deployment ID, URL, and final status.