Skip to content
Skills Library
Programming · Learning & explanation

linear-sdk-patterns

/linear-sdk-patterns

TypeScript/JavaScript SDK patterns and best practices for Linear. Use when learning SDK idioms, implementing common patterns, or optimizing Linear API usage. Trigger with phrases like "linear SDK patterns", "linear best practices", "linear typescript", "linear API patterns", "linear SDK idioms".

Repository
agent ↗
Licence
MIT
Last repository change
14.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
3
Deprecation

No signals detected. Repository changed on 14.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

TypeScript/JavaScript SDK patterns and best practices for Linear. Use when learning SDK idioms, implementing common patterns, or optimizing Linear API usage. Trigger with phrases like "linear SDK patterns", "linear best practices", "linear typescript", "linear API patterns", "linear SDK idioms".

Triggers from the description

linear SDK patternslinear best practiceslinear typescriptlinear API patternslinear SDK idioms
Original author description

TypeScript/JavaScript SDK patterns and best practices for Linear. Use when learning SDK idioms, implementing common patterns, or optimizing Linear API usage. Trigger with phrases like "linear SDK patterns", "linear best practices", "linear typescript", "linear API patterns", "linear SDK idioms".

How it works

  1. Overview
  2. Prerequisites
  3. Core Patterns
  4. Output
  5. Error Handling
  6. Resources
  7. Next Steps
Original SKILL.md headings · 230 lines, 659 words
SKILL.md preview
---
name: linear-sdk-patterns
description: |
  TypeScript/JavaScript SDK patterns and best practices for Linear.
  Use when learning SDK idioms, implementing common patterns,
  or optimizing Linear API usage.
  Trigger with phrases like "linear SDK patterns", "linear best practices",
  "linear typescript", "linear API patterns", "linear SDK idioms".
allowed-tools: Read, Write, Edit, Grep
version: 1.0.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
---

# Linear SDK Patterns

## Overview
Essential patterns and best practices for working with the Linear SDK.

## Prerequisites
- Linear SDK installed and configured
- TypeScript project setup
- Understanding of async/await patterns

## Core Patterns

### Pattern 1: Client Singleton
```typescript
// lib/linear.ts
import { LinearClient } from "@linear/sdk";

let client: LinearClient | null = null;

export function getLinearClient(): LinearClient {
  if (!client) {
    if (!process.env.LINEAR_API_KEY) {
      throw new Error("LINEAR_API_KEY environment variable not set");
    }
    client = new LinearClient({
      apiKey: process.env.LINEAR_API_KEY,
    });
  }
  return client;
}
```

### Pattern 2: Pagination Handling
```typescript
import { LinearClient, Issue, IssueConnection } from "@linear/sdk";

async function* getAllIssues(
  client: LinearClient,
  filter?: Record<string, unknown>
): AsyncGenerator<Issue> {
  let hasNextPage = true;
  let endCursor: string | undefined;

  while (hasNextPage) {
    const connection: IssueConnection = await client.issues({
      filter,
      first: 50, // Max per page
      after: endCursor,
    });

    for (const issue of connection.nodes) {
      yield issue;
    }

    hasNextPage = connection.pageInfo.hasNextPage;
    endCursor = connection.pageInfo.endCursor;
  }
}

// Usage
for await (const issue of getAllIssues(client, { state: { name: { eq: "Todo" } } })) {
  console.log(issue.identifier, issue.title);
}
```

### Pattern 3: Error Handling Wrapper
```typescript
import { LinearClient, LinearError } from "@linear/sdk";

interface LinearResult<T> {
  success: boolean;
  data?: T;
  error?: {
    message: string;
    code?: string;
    retryable: boolean;
  };
}

async function linearOperation<T>(
  operation: () => Promise<T>
): Promise<LinearResult<T>> {
  try {
    const data = await operation();
    return { success: true, data };
  } catch (error) {
    if (error instanceof LinearError) {
      return {
        success: false,
        error: {
          message: error.message,
          code: error.type,
          retryable: error.type === "RateLimitedError",
        },
      };
    }
    return {
      success: false,
      error: {
        message: error instanceof Error ? error.message : "Unknown error",
        retryable: false,
      },
    };
  }
}

// Usage
const result = await linearOperation(() => client.createIssue({
  teamId: team.id,
  title: "New issue",
}));

if (result.success) {
  console.log("Issue created:", result.data);
} else if (result.error?.retryable) {
  // Implement retry logic
}
```

### Pattern 4: Batch Operations
```typescript
async function batchUpdateIssues(
  client: LinearClient,
  issueIds: string[],
  update: { stateId?: string; priority?: number }
): Promise<{ success: number; failed: number }> {
  const results = await Promise.allSettled(
    issueIds.map(id => client.updateIssue(id, update))
  );

  return {
    success: results.filter(r => r.status === "fulfilled").length,
    failed: results.filter(r => r.status === "rejected").length,
  };
}
```

### Pattern 5: Caching Layer
```typescript
interface CacheEntry<T> {
  data: T;
  expiresAt: number;
}

class LinearCache {
  private cache = new Map<string, CacheEntry<unknown>>();
  private ttl: number;

  constructor(ttlSeconds = 60) {
    this.ttl = ttlSeconds * 1000;
  }

  async get<T>(key: string, fetcher: () => Promise<T>): Promise<T> {
    const cached = this.cache.get(key) as CacheEntry<T> | undefined;

    if (cached && cached.expiresAt > Date.now()) {
      return cached.data;
    }

    const data = await fetcher();
    this.cache.set(key, { data, expiresAt: Date.now() + this.ttl });
    return data;
  }

  invalidate(key: string): void {
    this.cache.delete(key);
  }
}

// Usage
const cache = new LinearCache(300); // 5 minute TTL

const teams = await cache.get("teams", () => client.teams());
```

### Pattern 6: Type-Safe Filters
```typescript
import { IssueFilter } from "@linear/sdk";

function buildIssueFilter(options: {
  teamKeys?: string[];
  states?: string[];
  assigneeId?: string;
  priority?: number[];
}): IssueFilter {
  const filter: IssueFilter = {};

  if (options.teamKeys?.length) {
    filter.team = { key: { in: options.teamKeys } };
  }

  if (options.states?.length) {
    filter.state = { name: { in: options.states } };
  }

  if (options.assigneeId) {
    filter.assignee = { id: { eq: options.assigneeId } };
  }

  if (options.priority?.length) {
    filter.priority = { in: options.priority };
  }

  return filter;
}
```

## Output
- Reusable client singleton
- Pagination iterator for large datasets
- Type-safe error handling
- Efficient batch operations
- Caching for performance

## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| `Type mismatch` | SDK version incompatibility | Update @linear/sdk package |
| `Undefined property` | Nullable field access | Use optional chaining (?.) |
| `Promise rejection` | Unhandled async error | Wrap in try/catch or use wrapper |

## Resources
- [Linear SDK TypeScript](https://developers.linear.app/docs/sdk/getting-started)
- [GraphQL Schema Reference](https://developers.linear.app/docs/graphql/schema)
- [TypeScript Generics](https://www.typescriptlang.org/docs/handbook/2/generics.html)

## Next Steps
Apply these patterns in `linear-core-workflow-a` for issue management.

Versions

RepositoryScoreLicence
This page · HelixDevelopment/agent100MIT
jeremylongshore/tons-of-skills-marketplace100MIT

Database snapshot: 13.11.2026 · package version e5c38ff1008e (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90Linear SDK Usage
    This skill should be used when implementing Linear integrations using the official @linear/sdk — creating issues programmatically, advanced fetch/modify patterns, error handling, and type safety. Activates on "linear sdk", "@linear/sdk", "linear client", "linear typescript".
  • 95language-patterns
    Provides language-specific patterns for TypeScript, Python, and React including idioms, best practices, and common patterns. Use when implementing features in these languages.
  • 95language-patterns
    Provides language-specific patterns for TypeScript, Python, and React including idioms, best practices, and common patterns. Use when implementing features in these languages.
  • 100linear-install-auth
    Install and configure Linear SDK/CLI authentication. Use when setting up a new Linear integration, configuring API keys, or initializing Linear in your project. Trigger with phrases like "install linear", "setup linear", "linear auth", "configure linear API key", "linear SDK setup".
  • 100linear-reference-architecture
    Production-grade Linear integration architecture patterns. Use when designing system architecture, planning integrations, or reviewing architectural decisions. Trigger with phrases like "linear architecture", "linear system design", "linear integration patterns", "linear best…
  • 100clerk-sdk-patterns
    Common Clerk SDK patterns and best practices. Use when implementing authentication flows, accessing user data, or integrating Clerk SDK methods in your application. Trigger with phrases like "clerk SDK", "clerk patterns", "clerk best practices", "clerk API usage".

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.