Skip to content

wrsmith108/linear-claude-skill

Managing Linear issues, projects, and teams. Use when working with Linear tasks, creating issues, updating status, querying projects, or managing team workflows.

FileKindSize
SKILL.mdskill md22.7 KB
scripts/__tests__/bulk-create.test.tsscript5.0 KB
scripts/__tests__/issue-description.test.tsscript6.8 KB
scripts/__tests__/lin-cli.test.tsscript3.8 KB
scripts/__tests__/lint-issues.test.tsscript2.3 KB
scripts/__tests__/retry.test.tsscript8.2 KB
scripts/__tests__/smoke.test.tsscript7.0 KB
scripts/__tests__/validate-description.test.tsscript4.3 KB
scripts/build.mjsscript1.4 KB
scripts/bulk-create.tsscript12.5 KB
scripts/create-initiative-update.tsscript5.8 KB
scripts/create-issue-with-project.tsscript8.0 KB
scripts/create-project-update.tsscript5.5 KB
scripts/extract-image.tsscript2.2 KB
scripts/lib/agent-selection.tsscript8.7 KB
scripts/lib/exit-codes.tsscript357 B
scripts/lib/index.tsscript3.1 KB
scripts/lib/initiative.tsscript5.0 KB
scripts/lib/issue-description.tsscript7.1 KB
scripts/lib/labels.tsscript7.6 KB
scripts/lib/lin-cli.tsscript7.3 KB
scripts/lib/linear-utils.tsscript9.3 KB
scripts/lib/project-template.tsscript8.8 KB
scripts/lib/retry.tsscript4.8 KB
scripts/lib/taxonomy-data.tsscript8.1 KB
scripts/lib/taxonomy-validation.tsscript10.0 KB
scripts/lib/taxonomy.tsscript3.6 KB
scripts/lib/verify.tsscript6.6 KB
scripts/linear-api.mjsexecutablescript12.1 KB
scripts/linear-ops.tsscript69.1 KB
scripts/lint-issues.tsscript6.9 KB
scripts/phase-complete.tsscript12.4 KB
scripts/query.shexecutablescript498 B
scripts/query.tsscript3.5 KB
scripts/run.shexecutablescript321 B
scripts/setup.tsscript8.6 KB
scripts/sync-skill-version.mjsscript2.0 KB
scripts/sync.tsscript5.7 KB
scripts/upload-image.tsscript4.4 KB

scripts/lib/retry.ts

View on GitHub
/**
 * Retry helper for transient Linear API failures.
 *
 * Wraps an async function with exponential backoff + jitter for 429 and 5xx
 * responses. Everything else re-throws immediately so real bugs aren't masked.
 *
 * Kill switch: LINEAR_DISABLE_RETRY=1 disables all retrying.
 */

export interface RetryOptions {
  /** Max attempts including the first call. Default 4. */
  maxAttempts?: number
  /** Initial backoff in ms. Default 500. */
  baseDelayMs?: number
  /** Cap on a single backoff delay in ms. Default 8000. */
  maxDelayMs?: number
  /** Label used in log output. Default 'linear'. */
  label?: string
  /** Injectable sleep for tests. Defaults to setTimeout. */
  sleep?: (ms: number) => Promise<void>
  /** Injectable logger. Defaults to console.warn. */
  log?: (msg: string) => void
}

const DEFAULTS = {
  maxAttempts: 4,
  baseDelayMs: 500,
  maxDelayMs: 8000,
  label: 'linear'
}

const defaultSleep = (ms: number) =>
  new Promise<void>(resolve => setTimeout(resolve, ms))

/**
 * Extract an HTTP-like status code from an SDK or fetch error. Returns
 * undefined if none can be found — callers treat that as non-retryable.
 */
export function extractStatusCode(err: unknown): number | undefined {
  if (!err || typeof err !== 'object') return undefined
  const e = err as Record<string, unknown>

  for (const key of ['status', 'statusCode']) {
    const v = e[key]
    if (typeof v === 'number') return v
  }

  const resp = e.response
  if (resp && typeof resp === 'object') {
    const v = (resp as Record<string, unknown>).status
    if (typeof v === 'number') return v
  }

  const msg = typeof e.message === 'string' ? e.message : ''
  const m = msg.match(/\b(429|500|502|503|504)\b/)
  if (m) return Number(m[1])

  return undefined
}

/**
 * Extract a Retry-After delay (ms) from an error, if the server sent one.
 * Supports both numeric seconds and HTTP-date values.
 */
export function extractRetryAfterMs(err: unknown): number | undefined {
  if (!err || typeof err !== 'object') return undefined
  const e = err as Record<string, unknown>

  const headers =
    (e.headers as Record<string, unknown> | undefined) ??
    ((e.response as Record<string, unknown> | undefined)?.headers as
      | Record<string, unknown>
      | undefined)

  const raw =
    (headers && (headers['retry-after'] ?? headers['Retry-After'])) ??
    e.retryAfter ??
    e['retry-after']

  if (raw == null) return undefined

  if (typeof raw === 'number') return Math.max(0, raw * 1000)

  if (typeof raw === 'string') {
    const asNum = Number(raw)
    if (!Number.isNaN(asNum)) return Math.max(0, asNum * 1000)
    const asDate = Date.parse(raw)
    if (!Number.isNaN(asDate)) return Math.max(0, asDate - Date.now())
  }

  return undefined
}

export function isRetryableStatus(code: number | undefined): boolean {
  if (code === undefined) return false
  return code === 429 || code === 502 || code === 503 || code === 504
}

export function isRetryDisabled(): boolean {
  return process.env.LINEAR_DISABLE_RETRY === '1'
}

/**
 * Compute backoff with full jitter: random in [0, min(maxDelay, base * 2^n)].
 */
export function computeBackoffMs(
  attempt: number,
  baseDelayMs: number,
  maxDelayMs: number,
  rng: () => number = Math.random
): number {
  const exp = baseDelayMs * Math.pow(2, attempt)
  const capped = Math.min(maxDelayMs, exp)
  return Math.floor(rng() * capped)
}

/**
 * Run `fn`, retrying on 429 / 5xx. Non-retryable errors bubble up immediately.
 *
 * @example
 *   const labels = await withRetry(() => client.issueLabels(), { label: 'labels' })
 */
export async function withRetry<T>(
  fn: () => Promise<T>,
  opts: RetryOptions = {}
): Promise<T> {
  if (isRetryDisabled()) {
    return fn()
  }

  const maxAttempts = opts.maxAttempts ?? DEFAULTS.maxAttempts
  const baseDelayMs = opts.baseDelayMs ?? DEFAULTS.baseDelayMs
  const maxDelayMs = opts.maxDelayMs ?? DEFAULTS.maxDelayMs
  const label = opts.label ?? DEFAULTS.label
  const sleep = opts.sleep ?? defaultSleep
  const log = opts.log ?? ((msg: string) => console.warn(msg))

  let lastErr: unknown

  for (let attempt = 0; attempt < maxAttempts; attempt++) {
    try {
      return await fn()
    } catch (err) {
      lastErr = err
      const status = extractStatusCode(err)
      const isLast = attempt === maxAttempts - 1

      if (!isRetryableStatus(status) || isLast) {
        throw err
      }

      const retryAfter = extractRetryAfterMs(err)
      const backoff =
        retryAfter !== undefined
          ? Math.min(retryAfter, maxDelayMs)
          : computeBackoffMs(attempt, baseDelayMs, maxDelayMs)

      log(
        `[retry:${label}] attempt ${attempt + 1}/${maxAttempts} after ${backoff}ms — ${status}${
          retryAfter !== undefined ? ' (Retry-After honored)' : ''
        }`
      )

      await sleep(backoff)
    }
  }

  throw lastErr
}
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: 119kUpdated Claude CodeCodexVerifiedInstall
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: 118kUpdated Claude CodeCodexVerifiedInstall
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: 108kUpdated Claude CodeCodexVerifiedInstall
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: 108kUpdated Claude CodeCodexVerifiedInstall