hk-merge-resolve
Skill100 starsChanged 9 months agoMITView on GitHub
Resolve merge conflicts in the current branch. Only invoke when the user explicitly runs /hk-merge-resolve. Do NOT auto-trigger on mentions of merge conflicts, conflict markers, or similar keywords.
In this repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- harness_usage_status/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- harness_usage_status/CLAUDE.mdCLAUDE.md
- odin/CLAUDE.mdCLAUDE.md
- taskit/CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- fable-auditSkill
- hk-arch-auditSkill
- hk-autonomy-auditSkill
- hk-breadcrumb-creatorSkill
- hk-changelogSkill
- hk-compoundSkill
- hk-follow-breadcrumbSkill
- hk-local-diagnoseSkill
- hk-local-logsSkill
- hk-local-run-specSkill
- hk-mock-firstSkill
- hk-rcaSkill
- hk-refineSkill
- hk-scout-wikiSkill
- hk-shift-changelogSkill
- hk-skill-creatorSkill
- hk-slop-auditSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 16 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 18
Before changing anything, understand what state git is in and what caused the conflicts.
- Very specific: line 44
Do NOT blindly git stash when conflicts are already present — git won't allow it, and if the conflicts came from a stash pop, the user's …
- Distinctive: line 76
Write the result that achieves both goals
- Distinctive: line 77
Make sure imports, variable names, and types are consistent across the merged result
- Distinctive: line 80
Read the file to see the full conflict region with context
- Distinctive: line 84
After resolving all conflicts in a file, do a quick sanity check: does the file still make sense?
- Distinctive: line 88
After all conflicts are resolved, verification is mandatory, not optional.
- Distinctive: line 97
If either finds markers, go back and fix them before proceeding.
- Distinctive: line 101
Check which parts of the monorepo were touched by the merge.
- Distinctive: line 120
Run only the checks for projects that had conflicted files or files changed by the merge.
- Distinctive: line 129
If it passes: note it and move on
- Distinctive: line 152
After all checks complete, print a summary:
- Distinctive: line 163
If any check failed due to the merge, fix it before completing the merge operation (git merge --continue, git rebase --continue, etc.).
- Distinctive: line 167
Only after all checks pass (or pre-existing failures are identified and noted):
- Distinctive: line 172
Stash pop: No git command needed — files are already in working tree
- Distinctive: line 174
Ask the user before running the finalization command.
- Distinctive: line 178
If a conflict involves complex logic where both sides made substantial changes to the same code, and you're not confident about the correct …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Resolve Merge Conflicts
Your job is to resolve all merge conflicts in the current branch of the current repo.
Conflicts can come from many sources — git merge, git rebase, git stash pop, git cherry-pick, or any operation that combines divergent changes. This skill handles all of them.
Step 0: Diagnose the Situation
Before changing anything, understand what state git is in and what caused the conflicts.
- Snapshot the state — Run these to understand what's happening:
Print the HEAD sha to the user: "Safety checkpoint: HEAD is atgit status git rev-parse HEAD<sha>." Identify the conflict source — Check which operation is in progress:
git rev-parse MERGE_HEAD 2>/dev/null→ merge in progresstest -d .git/rebase-merge || test -d .git/rebase-apply→ rebase in progressgit stash list+ checkgit statusfor "Unmerged paths" without MERGE_HEAD → stash pop conflict
This matters because the abort/recovery command differs:
Source Abort command merge git merge --abortrebase git rebase --abortcherry-pick git cherry-pick --abortstash pop git checkout -- .(stash stays in list, nothing lost)Print the appropriate abort command to the user so they have an escape hatch.
Protect unstashed work — If there are uncommitted changes beyond the conflicted files (tracked modified files that aren't part of the conflict), warn the user. These are at risk during resolution. Suggest committing or stashing them separately before proceeding, and wait for confirmation.
Do NOT blindly
git stashwhen conflicts are already present — git won't allow it, and if the conflicts came from astash pop, the user's changes are already in the working tree as the conflicted content. Stashing again would lose them.
Step 1: Build Context
Understand what both sides of the conflict were trying to do:
Identify the two sides — Based on the conflict source:
- Merge: "ours" = current branch, "theirs" = the branch being merged in
- Stash pop: "ours" = current working tree (post-pull), "theirs" = the stashed changes (the user's local work)
- Rebase: "ours" = the branch being rebased onto, "theirs" = the commits being replayed
Understanding which side is which is critical — especially for stash pop conflicts where "theirs" is the user's own work and should generally be preserved.
- Find all conflicts — Use Grep to search for
<<<<<<<across the repo. This gives you the full list of files and locations. - Triage — Group conflicts before diving in:
- Trivial: Lock files, auto-generated files, whitespace-only — resolve mechanically.
- Straightforward: Both sides changed different things in the same region — combine them.
- Requires judgment: Both sides changed the same logic — need to understand intent.
Step 2: Resolve Each Conflict
For each conflicted file, read the file (or at minimum the conflicted region with surrounding context), then decide:
- Keep ours — when the incoming changes are superseded
- Keep theirs — when the incoming side has the better version
- Combine both — the most common case; merge both sides' intent into correct code
For stash pop conflicts: The user's stashed changes are their in-progress work. Default to preserving the user's intent — their local changes are the "important" side. The pulled/merged content is the "environment" that the user's work needs to be adapted to.
Correctness matters more than cleverness. When combining:
- Understand what each side was trying to do
- Write the result that achieves both goals
- Make sure imports, variable names, and types are consistent across the merged result
For each conflict:
- Read the file to see the full conflict region with context
- Edit the file to the desired final state — remove ALL conflict markers (
<<<<<<<,=======,>>>>>>>) - Stage the resolved file with
git add <file>
After resolving all conflicts in a file, do a quick sanity check: does the file still make sense? Are imports consistent? Are there dangling references?
Step 3: Verify — Close the Loop
After all conflicts are resolved, verification is mandatory, not optional. A merge that compiles is not a merge that works.
3a. Confirm clean state
git diff --check # No conflict markers remain
grep -rn '<<<<<<<' . # Belt-and-suspenders: grep for stray markersIf either finds markers, go back and fix them before proceeding.
3b. Determine affected projects
Check which parts of the monorepo were touched by the merge. Run:
# For merge: diff between merge base and current state
git diff --name-only $(git merge-base HEAD MERGE_HEAD) HEAD 2>/dev/null || \
git diff --name-only HEAD~1 HEAD # fallback for rebase/cherry-pickMap changed files to projects:
| Path prefix | Project | Check commands | ||
taskit/taskit-frontend/ | Frontend | npm run build (TypeScript + Vite), npm run lint | ||
taskit/taskit-backend/ | Backend | `cd taskit/taskit-backend && python manage.py check --deploy 2>/dev/null | python manage.py check` | |
odin/ | Odin | cd odin && python -m pytest tests/unit/ -v | ||
harness_usage_status/ | Harness Usage | cd harness_usage_status && python -m pytest tests/ -v 2>/dev/null |
3c. Run check commands for affected projects
Run only the checks for projects that had conflicted files or files changed by the merge. Do not run checks for unaffected projects — that wastes time and may surface pre-existing issues unrelated to the merge.
Execution order:
- Type checks / build first — catches structural problems (missing imports, type errors, broken references). These are the most likely merge casualties.
- Lint second — catches style issues introduced by conflict resolution.
- Fast tests last — unit tests for the affected project. Skip integration/e2e tests (too slow for merge verification; those belong in CI).
For each check:
- Run the command
- If it passes: note it and move on
- If it fails: analyze the failure. If it's clearly caused by the merge resolution (missing import, type mismatch, duplicated declaration), fix it immediately and re-run. If it's a pre-existing failure unrelated to the merge, note it for the user but don't block on it.
Frontend-specific (most common merge casualty in this repo):
cd taskit/taskit-frontend && npm run buildThis runs TypeScript type-checking AND Vite bundling — it catches duplicate imports, missing exports, type mismatches, and broken references. This single command is the highest-value check for frontend merges.
Backend-specific:
cd taskit/taskit-backend && python manage.py checkCatches model inconsistencies, migration conflicts, and configuration problems.
Odin-specific:
cd odin && python -m pytest tests/unit/ -v --tb=shortFast unit tests only. Mock and integration tests are too slow for merge verification.
3d. Report results
After all checks complete, print a summary:
Merge verification:
✓ No conflict markers remaining
✓ Frontend build passed (TypeScript + Vite)
✓ Frontend lint passed
✗ Backend check failed — missing migration (see output above)
— Odin tests skipped (no odin/ files in merge)If any check failed due to the merge, fix it before completing the merge operation (git merge --continue, git rebase --continue, etc.). Do NOT finalize a merge with known check failures — that defeats the purpose of conflict resolution.
3e. Complete the merge operation
Only after all checks pass (or pre-existing failures are identified and noted):
- Merge:
git commit(git usually has the merge commit staged already) - Rebase:
git rebase --continue - Cherry-pick:
git cherry-pick --continue - Stash pop: No git command needed — files are already in working tree
Ask the user before running the finalization command.
When You're Not Sure
If a conflict involves complex logic where both sides made substantial changes to the same code, and you're not confident about the correct resolution — stop and ask.
Show the user:
- The conflicting chunks (both sides)
- Your understanding of what each side intended
- Your proposed resolution (or the options you see)
Then wait for confirmation before editing. A wrong merge is worse than a slow merge.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

