merge-base-branch
Merge the chosen base branch into the current branch and finish with a clean lint, full test coverage, and successful build. Use when you want the branch fully reconciled with its parent and CI-quality checks passing locally.
Usage:
/merge-base-branch— Run the full workflow below
Prerequisites:
- Repository root must be a git checkout on a named branch (not detached HEAD).
- If the project uses Node/npm,
package.jsonmust define scriptslint,test:coverage, andbuild. Ifpackage.jsonis missing or any of those scripts is missing, report what is absent and STOP (do not merge or proceed without the mandated checks).
Instructions:
-
Current branch:
- Run
git branch --show-current. If detached HEAD, inform the user and STOP.
- Run
-
Determine base branch candidate, then let the user choose:
- First, if
.agentexists at the repo root, read it forbaseBranch=<value>. That value is the detected candidate (if present). - Else, infer from git: run
git merge-base --fork-point main HEAD,git merge-base --fork-point master HEAD, andgit merge-base --fork-point develop HEAD. Any branch name that returns a commit is a match. If exactly one matches, that is the detected candidate. If several match, choose by priority:main, thenmaster, thendevelop. If none match, detected candidate is unset. - Use
AskUserQuestionso the user picks the base branch to merge. Always includemainas an option. Include the detected candidate as an option when it is set and differs frommain. Includemasteranddevelopas additional options when they exist onorigin(or locally). Include a short label on each option (e.g. “Detected from history: develop”). Wait for the answer; the selected branch is<base-branch>.
- First, if
-
Verify base branch and fetch:
- Confirm with
git rev-parse --verify origin/<base-branch>or, failing that,git rev-parse --verify <base-branch>. If neither exists, inform the user and STOP. - Run
git fetch origin <base-branch>. On failure, show the error and STOP.
- Confirm with
-
Stop if already up to date with the base:
- Let
<merge-ref>beorigin/<base-branch>when that ref exists after fetch; otherwise<base-branch>(local only). - Run
git rev-list --count HEAD..<merge-ref>(or equivalent: no commits ingit log --oneline HEAD..<merge-ref>). - If the count is 0, inform the user that the current branch already contains everything from
<merge-ref>and no merge is needed. If the working tree is not clean, note that uncommitted changes remain. STOP (do not commit WIP for this workflow, merge, or run lint/tests/build).
- Let
-
Commit all uncommitted work before merge:
- If
git statusshows no unstaged/staged/untracked changes that need committing, skip to step 6. - Otherwise stage and commit everything in the working tree (not limited to files touched in the current session). Split into multiple commits when the diff clearly contains separate logical chunks (e.g. group by feature area or directory); each commit gets a clear message. Use
git addselectively (orgit add -p) to build coherent commits—do not squash unrelated work into one commit when multiple distinct chunks exist.
- If
-
Merge base branch:
- Run
git merge origin/<base-branch> --no-edit(usegit merge <base-branch> --no-editonly if there is noorigin/<base-branch>but the local branch exists). - If the merge succeeds, summarize merged commits briefly.
- Run
-
Resolve conflicts and conclude merge:
- On conflicts: list with
git diff --name-only --diff-filter=U, resolve each file (remove conflict markers; combine or choose per intent—prefer base for upstream fixes, keep branch work for feature code),git addeach resolved file, thengit merge --continue --no-edituntil the merge completes.
- On conflicts: list with
-
Lint:
- From repo root, run
npm run lint. Fix all reported issues; re-run until it passes.
- From repo root, run
-
Commit after lint (if anything changed):
- If lint fixes (or formatter churn) changed files, commit with an appropriate message (one or more commits if chunks warrant it).
-
Tests with coverage:
- Run
npm run test:coverage. If it fails, read the coverage report and any failure output; add or adjust tests until all lines are covered at 100% (per project/tooling). Re-run and iterate until the command succeeds.
- Run
-
Commit test/coverage changes:
- Commit any test or source changes from step 10 with a clear message.
-
Build:
- Run
npm run build. Fix compile/bundler errors; re-run until it passes.
- Run
-
Commit build fixes (if any):
- Commit if step 12 produced file changes.
Summary for the user: base branch used, merge result (or “already up to date”), lint/test/build outcomes, and list of commits created during the run.
More from morphet81/cheat-sheets
localise
Generate an HTML translation helper page for Lokalise. Use when the user provides English text (singular/plural) and wants translations across all 23 supported languages, rendered as an interactive HTML page with copy buttons. Triggers on phrases like "translate for Lokalise", "generate translations", "translation table", or when the user provides English strings and mentions languages/i18n/localization.
67translate-pdf
Translate a PDF document from one language to another. Extracts text to structured Markdown, translates it, and builds a new translated PDF. Requires a Python environment with pymupdf, markdown, and weasyprint.
67create-jira-ticket
Create a JIRA ticket from user instructions via acli. Uses project from the current branch when possible, lists project epics, recommends the best epic, asks confirmation before creating, uses ADF descriptions, and can attach Figma designs via the Jira integration.
67adb
Use ADB to interact with an Android device or emulator. Takes a screenshot, understands the screen, performs actions (tap, swipe, type, navigate), and loops until the mission is complete.
66pre-push
Run pre-push checks including tests and linting to ensure code is clean and ready to push. Automatically detects project type and available scripts. Runs independent checks in parallel using agents.
66update-jira-ticket
Compare the JIRA ticket description to changes made in the current branch and propose description edits and/or comments to keep the ticket accurate and well-documented.
66