bidirectional-sync — Claude Code command: what it does, how to install
Sets up two-way synchronization between GitHub Issues and Linear tasks. Handles update conflicts and tracks state in local JSON files.
npx claude-code-templates@latest --command sync/bidirectional-syncWhat bidirectional-sync does
The command coordinates two-way data sync between GitHub Issues and Linear. It checks GitHub CLI authentication via gh and verifies whether the Linear MCP server is configured. Sync state is stored inside .sync-state.json or the sync/ directory.
Several conflict resolution strategies are available, including NEWER_WINS, GITHUB_WINS, LINEAR_WINS, and field-level merges. Atomic operations, rollback support, and webhook loop protection help maintain data integrity.
Without an authenticated gh CLI session and a configured Linear MCP server, the sync process will fail immediately.
What it helps with
- sync GitHub Issues with Linear tasks in both directions
- resolve edit collisions using strategies like
NEWER_WINS - preview sync operations safely with
--dry-run - prevent recursive update loops caused by webhooks
Example prompts for the agent
- /bidirectional-sync --dry-run
- /bidirectional-sync --incremental --conflict-strategy NEWER_WINS
- /bidirectional-sync --full
How to install bidirectional-sync
1claude-code-templates
npx claude-code-templates@latest --command sync/bidirectional-sync2Manually: put the files in place
.claude/commands/bidirectional-sync.mdCall it with /bidirectional-sync. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/bidirectional-sync.mdCall it with /prompts:bidirectional-sync. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/bidirectional-sync.prompt.mdManually: put the files in place
.gemini/commands/bidirectional-sync.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about bidirectional-sync
How to install bidirectional-sync in Claude Code?
Run npx claude-code-templates@latest --command sync/bidirectional-sync or place the command file into .claude/commands/bidirectional-sync.md.
What does bidirectional-sync do?
It syncs issues between GitHub and Linear, maintains cross-references, and applies conflict resolution rules.
What prerequisites does bidirectional-sync require?
You need an authenticated gh CLI tool and an accessible Linear MCP server. Status is tracked in .sync-state.json.
Source text
bidirectional-sync.md · MIT
---
allowed-tools: Read, Write, Edit, Bash
argument-hint: "[sync-mode] | --full | --incremental | --dry-run | --conflict-strategy"
description: Enable comprehensive bidirectional GitHub-Linear synchronization with conflict resolution
---
# Bidirectional Sync
Enable comprehensive bidirectional GitHub-Linear synchronization: **$ARGUMENTS**
## Current Sync Environment
- GitHub status: !`gh api user 2>/dev/null && echo "✓ Authenticated" || echo "⚠ Not authenticated"`
- Linear MCP: Check if Linear MCP server is available and configured
- Sync state: @.sync-state.json or @sync/ (if exists)
- Webhooks: !`gh api repos/{owner}/{repo}/hooks 2>/dev/null | grep -c linear || echo "0"`
## Task
Implement robust bidirectional synchronization between GitHub Issues and Linear tasks:
**Sync Mode**: Use $ARGUMENTS to specify full sync, incremental sync, dry-run preview, or conflict resolution strategy
**Synchronization Framework**:
1. **Sync State Management** - Initialize sync database, track entity relationships, maintain sync history
2. **Conflict Detection** - Identify simultaneous changes, field-level conflicts, timing issues
3. **Resolution Strategies** - NEWER_WINS, GITHUB_WINS, LINEAR_WINS, or intelligent field-level merge
4. **Transaction Management** - Atomic operations, rollback capability, distributed locking
5. **Webhook Integration** - Real-time event handling, sync loop prevention, automated triggers
6. **Data Integrity** - Bidirectional validation, cross-reference maintenance, audit trails
**Advanced Features**: Field-level merge rules, sync loop prevention, webhook automation, performance optimization, comprehensive monitoring.
**Production Ready**: Transaction safety, conflict resolution, error recovery, performance monitoring, comprehensive logging.
**Output**: Complete bidirectional sync system with conflict resolution, webhook integration, performance metrics, and comprehensive sync reporting.
© davila7 · MIT · davila7/claude-code-templates