merge-resolve
Resolve git merge conflicts using AI-powered context analysis and OpenSpec context bundles.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Resolve git merge conflicts using AI-powered context analysis and OpenSpec context bundles.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Run the implement pipeline over multiple backlog tickets in one session. Per ticket: spawn architect → spawn developer → spawn reviewer (the same three-phase pipeline $implement runs), then move to the next. Sequential by default; parallel only when the user explicitly opts in AND the tickets are independent. Reports an aggregated verdict at the end. Use when the user invokes `$batch-implement #N #M #K` or `$batch-implement --status todo`.
Implement a single backlog ticket through a multi-phase pipeline: architect plans (OpenSpec proposal+design+tasks+specs), sr-developer codes in TDD order, sr-reviewer validates (correctness, tests, security, performance). A profile may add custom-* rails. Reads .specrails/local-tickets.json, closes the ticket in place, reports concisely. Use when the user invokes `$implement #N` or `$implement <free-form>`.
Architect role for the specrails implement pipeline. Reads a backlog ticket, surveys the repo, produces (a) an OpenSpec change package under openspec/changes/<slug>/ and (b) a plan artefact under .specrails/agent-memory/explanations/. Does NOT write production code. Invoked by the implement orchestrator via $sr-architect after a spawn_agent / send_message handoff.
Developer role for the specrails implement pipeline. Reads the architect's design + tasks.md and implements them in TDD order: for each task, write a failing test first, run it to confirm it fails, then write the minimum production code to make it pass, then re-run. Reports the files changed. Does NOT review its own work beyond the per-task test cycle. Invoked by the implement orchestrator via $sr-developer.
Reviewer role for the specrails implement pipeline. Validates the entire implementation: the OpenSpec change package (proposal/design/tasks/specs) is well-formed, the developer's code matches the design's public API and invariants, every tasks.md box is ticked, the tests cover every spec scenario, and the project's full test/build suite passes. Writes a confidence-score.json artefact. Does NOT modify the developer's code. Invoked via $sr-reviewer.
sr:batch-implement — Batch implementation orchestrator. Accepts multiple feature references, computes dependency-aware execution waves, invokes sr:implement per wave.
| name | merge-resolve |
| description | Resolve git merge conflicts using AI-powered context analysis and OpenSpec context bundles. |
| license | MIT |
| compatibility | Requires git. |
| metadata | {"author":"specrails","version":"1.0"} |
Resolves git conflict markers in working tree files using AI-powered context analysis. For each conflict block, reads OpenSpec context bundles from the features that produced the conflict, infers the correct resolution, and writes it in place — or preserves clean markers for conflicts it cannot safely resolve.
IMPORTANT: Always follow this procedure exactly as written. Launch the sr-merge-resolver agent as specified. Do NOT attempt to resolve conflicts yourself in the main conversation.
Input: $ARGUMENTS — flags controlling which files to process, where to find context, and resolution behavior.
Scan $ARGUMENTS for the following flags:
--files <paths>Type: space-separated file paths or glob patterns Default: auto-detect (scan working tree)
Explicit list of files to process. If a path contains * or ?, treat it as a glob and expand it. Strip this flag and its value from $ARGUMENTS before further processing.
--context <directory>Type: directory path
Default: openspec/changes/
Directory to scan for context bundles. The command globs <directory>/*/context-bundle.md. Strip this flag and its value from $ARGUMENTS before further processing.
--threshold NType: integer 0–100 Default: 70
Minimum confidence score for the resolver to apply an AI resolution. Below this threshold, the resolver preserves conflict markers in normalized format. Strip this flag and its value from $ARGUMENTS before further processing.
--mode auto|manual-fallback-onlyType: enum
Default: auto
auto: attempt AI resolution for each conflict blockmanual-fallback-only: only normalize conflict marker format; do not attempt AI resolutionStrip this flag and its value from $ARGUMENTS before further processing.
After parsing, if any unrecognized flags remain in $ARGUMENTS: print a warning:
[merge-resolve] Warning: unrecognized flags ignored: <remaining>
--files was provided:For each path (or expanded glob): check that the file exists. If a path does not exist: print [merge-resolve] Warning: <path> not found — skipped. and remove it from the list.
Filter to only files containing <<<<<<<. For any file in the provided list that does NOT contain <<<<<<<: print [merge-resolve] <path>: no conflict markers found — skipped.
--files was NOT provided:Scan the entire working tree for files containing <<<<<<<:
grep -rl "<<<<<<< " . --include="*" 2>/dev/null
Exclude .git/ directory from results.
If no conflicted files are found (either from explicit list or auto-detect):
[merge-resolve] No conflict markers found in the working tree.
Nothing to do.
Exit cleanly.
Otherwise, print:
[merge-resolve] Found N conflicted file(s):
- path/to/file.ts
- path/to/other.md
Glob <context-directory>/*/context-bundle.md.
Build CONTEXT_BUNDLES map: for each matched path, the key is the subdirectory name (the feature name), the value is the file path.
Example:
openspec/changes/feature-a/context-bundle.md → { "feature-a": "openspec/changes/feature-a/context-bundle.md" }
openspec/changes/feature-b/context-bundle.md → { "feature-b": "openspec/changes/feature-b/context-bundle.md" }
If no context bundles are found:
[merge-resolve] No context bundles found at <context-directory>.
The resolver will use structural analysis only (no feature-intent context).
Set CONTEXT_BUNDLES = {}.
Construct the agent prompt with:
CONFLICTED_FILES: the list of conflicted file pathsCONTEXT_BUNDLES: the map built in Step 3CONFIDENCE_THRESHOLD: the --threshold value (default 70)RESOLUTION_MODE: the --mode value (default auto)REPORT_PATH: openspec/changes/<first-feature>/merge-resolution-report.md if CONTEXT_BUNDLES has entries; otherwise merge-resolution-report.md in the working directory rootLaunch the sr-merge-resolver agent (subagent_type: sr:merge-resolver, foreground, run_in_background: false). Wait for it to complete.
Read the final MERGE_RESOLUTION_STATUS line from the agent's output.
After the agent completes, print:
## Merge Resolution Complete
| Metric | Count |
|--------|-------|
| Files processed | N |
| Conflicts found | N |
| Auto-resolved | N |
| Low-confidence (kept) | N |
| Skipped | N |
Resolution report: <REPORT_PATH>
If MERGE_RESOLUTION_STATUS = PARTIAL or UNRESOLVED:
## Remaining Conflicts
The following files still contain conflict markers that require manual resolution:
- path/to/file.ts (N block(s))
Search for `<<<<<<<` in each file to locate the markers.
Run `/specrails:merge-resolve` again after addressing the low-confidence conflicts,
or resolve them manually and commit.
If MERGE_RESOLUTION_STATUS = CLEAN:
All conflict markers resolved. Working tree is clean.
You can now stage and commit the resolved files.
[merge-resolve] Error: sr-merge-resolver did not complete. Files may be partially modified — check for remaining conflict markers before committing. Exit with a non-zero status.[merge-resolve] Warning: <path> disappeared during processing — skipped.