Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Data synchronization, backup, and consistency patterns for Linear. Use when implementing data sync, creating backups, exporting data, or ensuring data consistency between Linear and local state. Trigger: "linear data sync", "backup linear", "linear export", "linear data consistency", "sync linear issues".
.claude/skills/jeremylongshore-linear-data-handling/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | 13% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 63% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 35% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 55% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 72% | 0% |
Implement reliable data synchronization, backup, and consistency for Linear integrations. Covers full sync, incremental webhook sync, JSON/CSV export, consistency checks, and conflict resolution.
@linear/sdk with API key configuredtypescript// src/models/linear-entities.ts import { z } from "zod"; export const LinearIssueSchema = z.object({ id: z.string().uuid(), identifier: z.string(), // e.g., "ENG-123" title: z.string(), description: z.string().nullable(), priority: z.number().int().min(0).max(4), estimate: z.number().nullable(), stateId: z.string().uuid(), stateName: z.string(), stateType: z.string(), teamId: z.string().uuid(), teamKey: z.string(), assigneeId: z.string().uuid().nullable(), projectId: z.string().uuid().nullable(), cycleId: z.string().uuid().nullable(), parentId: z.string().uuid().nullable(), dueDate: z.string().nullable(), createdAt: z.string(), updatedAt: z.string(), completedAt: z.string().nullable(), canceledAt: z.string().nullable(), syncedAt: z.string(), }); export type LinearIssue = z.infer<typeof LinearIssueSchema>;
Paginate through all issues, resolve relations, and upsert locally.
typescriptimport { LinearClient } from "@linear/sdk"; interface SyncStats { total: number; created: number; updated: number; deleted: number; errors: number; } async function fullSync(client: LinearClient, teamKey: string): Promise<SyncStats> { const stats: SyncStats = { total: 0, created: 0, updated: 0, deleted: 0, errors: 0 }; const remoteIds = new Set<string>(); // Paginate all issues let cursor: string | undefined; let hasNext = true; while (hasNext) { const result = await client.client.rawRequest(` query FullSync($teamKey: String!, $cursor: String) { issues( first: 100, after: $cursor, filter: { team: { key: { eq: $teamKey } } }, orderBy: updatedAt ) { nodes { id identifier title description priority estimate dueDate createdAt updatedAt completedAt canceledAt state { id name type } team { id key } assignee { id } project { id } cycle { id } parent { id } } pageInfo { hasNextPage endCursor } } } `, { teamKey, cursor }); const issues = result.data.issues; for (const issue of issues.nodes) { remoteIds.add(issue.id); stats.total++; try { const mapped: LinearIssue = { id: issue.id, identifier: issue.identifier, title: issue.title, description: issue.description, priority: issue.priority, estimate: issue.estimate, stateId: issue.state.id, stateName: issue.state.name, stateType: issue.state.type, teamId: issue.team.id, teamKey: issue.team.key, assigneeId: issue.assignee?.id ?? null, projectId: issue.project?.id ?? null, cycleId: issue.cycle?.id ?? null, parentId: issue.parent?.id ?? null, dueDate: issue.dueDate, createdAt: issue.createdAt, updatedAt: issue.updatedAt, completedAt: issue.completedAt, canceledAt: issue.canceledAt, syncedAt: new Date().toISOString(), }; const existing = await db.issues.findById(issue.id); if (existing) { await db.issues.update(issue.id, mapped); stats.updated++; } else { await db.issues.insert(mapped); stats.created++; } } catch (error) { stats.errors++; console.error(`Error syncing ${issue.identifier}:`, error); } } hasNext = issues.pageInfo.hasNextPage; cursor = issues.pageInfo.endCursor; // Rate limit protection if (hasNext) await new Promise(r => setTimeout(r, 100)); } // Soft-delete issues that no longer exist remotely const localIds = await db.issues.listIds({ teamKey }); for (const localId of localIds) { if (!remoteIds.has(localId)) { await db.issues.softDelete(localId); stats.deleted++; } } console.log(`Full sync complete:`, stats); return stats; }
typescriptasync function processWebhookSync(event: { action: "create" | "update" | "remove"; type: string; data: any; }) { if (event.type !== "Issue") return; const syncedAt = new Date().toISOString(); switch (event.action) { case "create": await db.issues.insert({ id: event.data.id, identifier: event.data.identifier, title: event.data.title, description: event.data.description, priority: event.data.priority, estimate: event.data.estimate, stateId: event.data.stateId ?? event.data.state?.id, stateName: event.data.state?.name ?? "Unknown", stateType: event.data.state?.type ?? "unknown", teamId: event.data.teamId ?? event.data.team?.id, teamKey: event.data.team?.key ?? "", assigneeId: event.data.assigneeId ?? null, projectId: event.data.projectId ?? null, cycleId: event.data.cycleId ?? null, parentId: event.data.parentId ?? null, dueDate: event.data.dueDate ?? null, createdAt: event.data.createdAt, updatedAt: event.data.updatedAt, completedAt: event.data.completedAt ?? null, canceledAt: event.data.canceledAt ?? null, syncedAt, }); break; case "update": await db.issues.update(event.data.id, { ...event.data, syncedAt, }); break; case "remove": await db.issues.softDelete(event.data.id); break; } }
typescriptasync function exportToJson(client: LinearClient, outputDir: string) { const timestamp = new Date().toISOString().replace(/[:.]/g, "-"); const teams = await client.teams(); const backup = { exportedAt: new Date().toISOString(), version: "1.0", teams: teams.nodes.map(t => ({ id: t.id, key: t.key, name: t.name })), projects: [] as any[], issues: [] as any[], }; // Export projects const projects = await client.projects(); backup.projects = projects.nodes.map(p => ({ id: p.id, name: p.name, state: p.state, targetDate: p.targetDate, progress: p.progress, })); // Export issues with pagination for (const team of teams.nodes) { let cursor: string | undefined; let hasNext = true; while (hasNext) { const result = await client.issues({ first: 100, after: cursor, filter: { team: { id: { eq: team.id } } }, }); for (const issue of result.nodes) { backup.issues.push({ id: issue.id, identifier: issue.identifier, title: issue.title, description: issue.description, priority: issue.priority, estimate: issue.estimate, createdAt: issue.createdAt, updatedAt: issue.updatedAt, }); } hasNext = result.pageInfo.hasNextPage; cursor = result.pageInfo.endCursor; if (hasNext) await new Promise(r => setTimeout(r, 100)); } } const path = `${outputDir}/linear-backup-${timestamp}.json`; await fs.writeFile(path, JSON.stringify(backup, null, 2)); console.log(`Exported ${backup.issues.length} issues to ${path}`); }
typescriptasync function checkConsistency(client: LinearClient, teamKey: string): Promise<{ missing: string[]; stale: string[]; orphaned: string[]; }> { // Sample 50 remote issues const remote = await client.issues({ first: 50, filter: { team: { key: { eq: teamKey } } }, orderBy: "updatedAt", }); const missing: string[] = []; const stale: string[] = []; for (const issue of remote.nodes) { const local = await db.issues.findById(issue.id); if (!local) { missing.push(issue.identifier); } else if (local.updatedAt < issue.updatedAt) { stale.push(issue.identifier); } } // Find orphaned local records const orphaned: string[] = []; const localSample = await db.issues.findRecent(50); for (const local of localSample) { try { await client.issue(local.id); } catch { orphaned.push(local.identifier); } } const result = { missing, stale, orphaned }; console.log(`Consistency check: ${missing.length} missing, ${stale.length} stale, ${orphaned.length} orphaned`); // Auto-trigger full sync if too many issues if (missing.length > 10 || stale.length > 10) { console.warn("High inconsistency — triggering full sync"); await fullSync(client, teamKey); } return result; }
typescripttype ConflictStrategy = "remote-wins" | "local-wins" | "merge" | "manual"; interface ConflictResult { resolved: boolean; strategy: ConflictStrategy; winner: "local" | "remote" | "merged"; } function resolveConflict( local: LinearIssue, remote: any, strategy: ConflictStrategy, mergeFields?: string[] ): ConflictResult { switch (strategy) { case "remote-wins": // Remote always wins — standard for most integrations db.issues.update(remote.id, { ...remote, syncedAt: new Date().toISOString() }); return { resolved: true, strategy, winner: "remote" }; case "local-wins": // Keep local, skip remote update return { resolved: true, strategy, winner: "local" }; case "merge": // Field-level merge — use remote for specified fields, local for rest const merged = { ...local }; for (const field of mergeFields ?? ["title", "priority", "stateId"]) { (merged as any)[field] = remote[field]; } merged.syncedAt = new Date().toISOString(); db.issues.update(remote.id, merged); return { resolved: true, strategy, winner: "merged" }; case "manual": throw new Error(`Conflict on ${local.identifier} requires manual resolution`); } }
| Issue | Cause | Solution | |-------|-------|----------| | Sync timeout | Too many records | Use smaller page sizes, add delays | | Conflict detected | Concurrent edits | Apply conflict resolution strategy | | Stale data | Missed webhook events | Trigger full sync via consistency check | | Export failed | Rate limit during backup | Add 100ms delay between pagination calls | | Duplicate entries | Webhook retry without dedup | Deduplicate by Linear-Delivery header |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 41,889 | 34,763 | -17% | 1 | 1 | 0% | 7,627 | 7,999 | +5% | 0 | 0 | — |
case-02 | pass→pass | 28,996 | 26,228 | -10% | 1 | 1 | 0% | 5,225 | 7,858 | +50% | 0 | 0 | — |
case-03 | fail→pass | 37,356 | 25,293 | -32% | 1 | 1 | 0% | 6,783 | 7,637 | +13% | 0 | 0 | — |
case-04 | pass→pass | 22,507 | 15,584 | -31% | 1 | 1 | 0% | 3,497 | 5,445 | +56% | 0 | 0 | — |
case-05 | pass→pass | 22,265 | 16,809 | -25% | 1 | 1 | 0% | 3,723 | 5,724 | +54% | 0 | 0 | — |
case-06 | pass→pass | 16,003 | 11,047 | -31% | 1 | 1 | 0% | 2,079 | 4,020 | +93% | 0 | 0 | — |
case-07 | fail→pass | 22,094 | 18,912 | -14% | 1 | 1 | 0% | 3,235 | 5,278 | +63% | 0 | 0 | — |
case-08 | fail→fail | 19,882 | 12,576 | -37% | 1 | 1 | 0% | 2,827 | 5,376 | +90% | 0 | 0 | — |
case-09 | pass→pass | 23,734 | 17,776 | -25% | 1 | 1 | 0% | 2,904 | 5,132 | +77% | 0 | 0 | — |
case-10 | fail→pass | 25,488 | 16,026 | -37% | 1 | 1 | 0% | 3,985 | 5,385 | +35% | 0 | 0 | — |
case-11 | pass→fail | 14,398 | 17,302 | +20% | 1 | 1 | 0% | 2,391 | 4,899 | +105% | 0 | 0 | — |
case-12 | pass→pass | 8,032 | 9,677 | +20% | 1 | 1 | 0% | 1,061 | 4,006 | +278% | 0 | 0 | — |
case-13 | pass→pass | 17,406 | 14,736 | -15% | 1 | 1 | 0% | 2,278 | 4,545 | +100% | 0 | 0 | — |
case-14 | fail→fail | 19,511 | 14,657 | -25% | 1 | 1 | 0% | 2,267 | 4,742 | +109% | 0 | 0 | — |
case-15 | fail→pass | 30,772 | 15,499 | -50% | 1 | 1 | 0% | 3,973 | 6,145 | +55% | 0 | 0 | — |
case-16 | pass→pass | 19,503 | 4,539 | -77% | 1 | 1 | 0% | 2,450 | 3,932 | +60% | 0 | 0 | — |
case-17 | fail→fail | 18,646 | 13,794 | -26% | 1 | 1 | 0% | 3,394 | 5,629 | +66% | 0 | 0 | — |
case-18 | fail→pass | 26,569 | 17,558 | -34% | 1 | 1 | 0% | 3,303 | 5,666 | +72% | 0 | 0 | — |
case-19 | fail→fail | 19,252 | 14,781 | -23% | 1 | 1 | 0% | 2,908 | 5,537 | +90% | 0 | 0 | — |
case-20 | pass→pass | 27,350 | 3,741 | -86% | 1 | 1 | 0% | 3,503 | 3,743 | +7% | 0 | 0 | — |
case-21 | pass→pass | 18,799 | 12,563 | -33% | 1 | 1 | 0% | 2,637 | 4,771 | +81% | 0 | 0 | — |
case-22 | pass→pass | 20,910 | 20,385 | -3% | 1 | 1 | 0% | 3,080 | 5,588 | +81% | 0 | 0 | — |
case-23 | pass→pass | 16,372 | 14,684 | -10% | 1 | 1 | 0% | 2,159 | 5,036 | +133% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +17 percentage points is the difference between those two pass rates over the 23 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.