wrsmith108/linear-claude-skill
Linear
UnverifiedManaging Linear issues, projects, and teams. Use when working with Linear tasks, creating issues, updating status, querying projects, or managing team workflows.
scripts/sync.ts
View on GitHub#!/usr/bin/env npx tsx
/**
* Bulk sync Linear issues to a target state
*
* Usage:
* LINEAR_API_KEY=lin_api_xxx npx tsx sync.ts --issues ENG-432,ENG-433,ENG-434 --state Done
* LINEAR_API_KEY=lin_api_xxx npx tsx sync.ts --issues ENG-432 --state "In Progress"
* LINEAR_API_KEY=lin_api_xxx npx tsx sync.ts --issues ENG-432,ENG-433 --state Done --comment "Completed in PR #42"
*
* Options:
* --issues Comma-separated issue identifiers (e.g., ENG-432,ENG-433)
* --state Target state name (e.g., Done, "In Progress", Backlog)
* --comment Optional comment to add to each issue
* --dry-run Preview changes without applying them
*/
import { LinearClient } from '@linear/sdk';
interface SyncOptions {
issues: string[];
state: string;
comment?: string;
dryRun: boolean;
}
function parseArgs(): SyncOptions {
const args = process.argv.slice(2);
const options: SyncOptions = {
issues: [],
state: '',
comment: undefined,
dryRun: false,
};
for (let i = 0; i < args.length; i++) {
switch (args[i]) {
case '--issues':
options.issues = args[++i]?.split(',').map((s) => s.trim()) ?? [];
break;
case '--state':
options.state = args[++i] ?? '';
break;
case '--comment':
options.comment = args[++i];
break;
case '--dry-run':
options.dryRun = true;
break;
}
}
return options;
}
function printUsage(): void {
console.error('Usage:');
console.error(
' LINEAR_API_KEY=lin_api_xxx npx tsx sync.ts --issues ENG-432,ENG-433 --state Done'
);
console.error('');
console.error('Options:');
console.error(
' --issues Comma-separated issue identifiers (required)'
);
console.error(' --state Target state name (required)');
console.error(' --comment Optional comment to add to each issue');
console.error(' --dry-run Preview changes without applying them');
}
async function main() {
const apiKey = process.env.LINEAR_API_KEY;
if (!apiKey) {
console.error('Error: LINEAR_API_KEY environment variable is required');
console.error('');
printUsage();
process.exit(1);
}
const options = parseArgs();
if (options.issues.length === 0) {
console.error('Error: --issues is required');
console.error('');
printUsage();
process.exit(1);
}
if (!options.state) {
console.error('Error: --state is required');
console.error('');
printUsage();
process.exit(1);
}
const client = new LinearClient({ apiKey });
console.log(`\nð Syncing ${options.issues.length} issue(s) to "${options.state}"...`);
if (options.dryRun) {
console.log('ð DRY RUN - no changes will be applied\n');
}
// Extract team key from first issue identifier
const teamKey = options.issues[0]?.split('-')[0];
if (!teamKey) {
console.error('Error: Could not extract team key from issue identifier');
process.exit(1);
}
// Find the target workflow state
console.log(`ð Looking up workflow state "${options.state}" for team ${teamKey}...`);
const team = await client.team(teamKey);
const states = await team.states();
const targetState = states.nodes.find(
(s) => s.name.toLowerCase() === options.state.toLowerCase()
);
if (!targetState) {
console.error(`\nâ Error: State "${options.state}" not found`);
console.error('\nAvailable states:');
states.nodes.forEach((s) => console.error(` - ${s.name}`));
process.exit(1);
}
console.log(`â
Found state: ${targetState.name} (${targetState.id})\n`);
// Process each issue
const results: { identifier: string; success: boolean; error?: string }[] = [];
for (const identifier of options.issues) {
process.stdout.write(` ${identifier}: `);
try {
// Fetch the issue by identifier
const issueNumber = parseInt(identifier.split('-')[1] ?? '0', 10);
const issuesResult = await client.issues({
filter: {
team: { key: { eq: teamKey } },
number: { eq: issueNumber },
},
});
const issue = issuesResult.nodes[0];
if (!issue) {
console.log('â Not found');
results.push({ identifier, success: false, error: 'Not found' });
continue;
}
if (options.dryRun) {
const currentState = await issue.state;
console.log(`Would update from "${currentState?.name}" â "${targetState.name}"`);
results.push({ identifier, success: true });
continue;
}
// Update the issue state
await issue.update({ stateId: targetState.id });
// Add comment if provided
if (options.comment) {
await client.createComment({ issueId: issue.id, body: options.comment });
}
console.log(`â
Updated to "${targetState.name}"${options.comment ? ' + comment' : ''}`);
results.push({ identifier, success: true });
// Small delay to avoid rate limiting
await new Promise((resolve) => setTimeout(resolve, 150));
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
console.log(`â ${errorMessage}`);
results.push({ identifier, success: false, error: errorMessage });
}
}
// Summary
const successful = results.filter((r) => r.success).length;
const failed = results.filter((r) => !r.success).length;
console.log(`\n${'â'.repeat(40)}`);
console.log(`ð Summary: ${successful} succeeded, ${failed} failed`);
if (failed > 0) {
console.log('\nFailed issues:');
results
.filter((r) => !r.success)
.forEach((r) => console.log(` ${r.identifier}: ${r.error}`));
process.exit(1);
}
console.log('');
}
main().catch((error) => {
console.error('Error:', error.message);
process.exit(1);
});
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| planning-and-task-breakdownaddyosmani/agent-skillsBreaks work into ordered tasks. Use when you have a spec or clear requirements and need to break work into implementable tasks. Use when a task feels too large to start, when you need to estimate scope, or when parallel work is possible. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| screenpipethedotmack/claude-memSearch screen and audio history recorded by Screenpipe and optionally save selected context into claude-mem. Use when the user asks to recall desktop activity, a meeting, or something seen in another app through Screenpipe. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| contact-widgetnexu-io/open-designSelf-contained floating chat widget with welcome screen, social links, meeting button, and message input. Single HTML file, zero dependencies. | Stars: 108k | Updated | Claude CodeCodex | Verified | Install |
| meeting-notesnexu-io/open-designMeeting notes page â title bar with attendees, agenda checklist, decisions block, action items table with owners + dates, and a "next meeting" footer. Use when the brief mentions "meeting notes", "minutes", "1:1 notes", "all-hands recap", or "äžčŪŪįšŠčĶ". | Stars: 108k | Updated | Claude CodeCodex | Verified | Install |