Complete Linear integration skill pack with 24 skills covering issue tracking, project management, workflows, and team collaboration. Flagship tier vendor pack.
Installation
Open Claude Code and run this command:
/plugin install linear-pack@claude-code-plugins-plus
Use --global to install for all projects, or --project for current project only.
Skills (24)
Integrate Linear with GitHub Actions CI/CD pipelines.
Linear CI Integration
Overview
Integrate Linear into GitHub Actions CI/CD pipelines: run integration tests against the Linear API, automatically link PRs to issues, transition issue states on PR events, and create Linear issues from build failures.
Prerequisites
- GitHub repository with Actions enabled
- Linear API key stored as GitHub secret
- npm/pnpm project with
@linear/sdkconfigured
Instructions
Step 1: Store Secrets in GitHub
# Using GitHub CLI
gh secret set LINEAR_API_KEY --body "lin_api_xxxxxxxxxxxx"
gh secret set LINEAR_WEBHOOK_SECRET --body "whsec_xxxxxxxxxxxx"
# Store team ID for CI-created issues
gh variable set LINEAR_TEAM_ID --body "team-uuid-here"
Step 2: Integration Test Workflow
# .github/workflows/linear-tests.yml
name: Linear Integration Tests
on:
push:
branches: [main]
pull_request:
env:
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: npm run test:linear
env:
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: test-results/
Step 3: Integration Test Suite
// tests/linear.integration.test.ts
import { describe, it, expect, beforeAll, afterAll } from "vitest";
import { LinearClient } from "@linear/sdk";
describe("Linear Integration", () => {
let client: LinearClient;
let teamId: string;
const cleanup: string[] = [];
beforeAll(async () => {
const apiKey = process.env.LINEAR_API_KEY;
if (!apiKey) throw new Error("LINEAR_API_KEY required for integration tests");
client = new LinearClient({ apiKey });
const teams = await client.teams();
teamId = teams.nodes[0].id;
});
afterAll(async () => {
for (const id of cleanup) {
try { await client.deleteIssue(id); } catch {}
}
});
it("authenticates successfully", async () => {
const viewer = await client.viewer;
expect(viewer.name).toBeDefined();
expect(viewer.email).toBeDefined();
});
it("creates an issue", async () => {
const result = await client.createIssue({
teamId,
title: `[CI] ${new Date().toISOString()}`,
description: "Created by CI pipeline",
});
expect(result.success).toBe(true);
const issue = await result.issue;
expect(issue?.identifier).toBeDefined();
if (issue) cleanup.push(issue.id);
});
it("queries issues with filtering", async () =Diagnose and fix common Linear API and SDK errors.
Linear Common Errors
Overview
Quick reference for diagnosing and resolving common Linear API and SDK errors. Linear's GraphQL API returns errors in response.errors[] with extensions.type and extensions.userPresentableMessage fields. HTTP 200 responses can still contain partial errors -- always check the errors array.
Prerequisites
- Linear SDK or raw API access configured
- Access to application logs
- Understanding of GraphQL error response format
Instructions
Error Response Structure
// Linear GraphQL error shape
interface LinearGraphQLResponse {
data: Record<string, any> | null;
errors?: Array<{
message: string;
path?: string[];
extensions: {
type: string; // "authentication_error", "forbidden", "ratelimited", etc.
userPresentableMessage?: string;
};
}>;
}
// SDK throws these typed errors
import { LinearError, InvalidInputLinearError } from "@linear/sdk";
// LinearError includes: .status, .message, .type, .query, .variables
// InvalidInputLinearError extends LinearError for mutation input errors
Error 1: Authentication Failures
// extensions.type: "authentication_error"
// HTTP 401 or error in response.errors
// Diagnostic check
async function testAuth(): Promise<void> {
try {
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
const viewer = await client.viewer;
console.log(`OK: ${viewer.name} (${viewer.email})`);
} catch (error: any) {
if (error.message?.includes("Authentication")) {
console.error("API key is invalid or expired.");
console.error("Fix: Settings > Account > API > Personal API keys");
}
throw error;
}
}
Quick curl diagnostic:
curl -s -X POST https://api.linear.app/graphql \
-H "Authorization: $LINEAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "{ viewer { id name email } }"}' | jq .
Error 2: Rate Limiting (HTTP 429)
Linear uses the leaky bucket algorithm with two budgets:
- Request limit: 5,000 requests/hour per API key
- Complexity limit: 250,000 complexity points/hour per API key
- Max single query complexity: 10,000 points
// extensions.type: "ratelimited"
// HTTP 429 with rate limit headers
async function withRetry<T>(fn: () => Promise<T>, maxRetries = 5): Promise<T> {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await fn();
Issue lifecycle management with Linear: create, update, transition, relate, comment, and organize issues through the SDK and GraphQL API.
Linear Core Workflow A: Issue Lifecycle
Overview
Master issue lifecycle management: creating, updating, transitioning states, building parent/sub-issue hierarchies, managing labels, and commenting. Linear issues flow through typed workflow states (triage -> backlog -> unstarted -> started -> completed | canceled), belong to a team, and support priorities 0-4, estimates, due dates, labels, and cycle/project assignment.
Prerequisites
@linear/sdkinstalled with API key or OAuth token configured- Access to target team(s)
- Understanding of your team's workflow states
Instructions
Step 1: Create Issues
import { LinearClient } from "@linear/sdk";
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
// Get team
const teams = await client.teams();
const team = teams.nodes.find(t => t.key === "ENG") ?? teams.nodes[0];
// Basic issue
const result = await client.createIssue({
teamId: team.id,
title: "Implement user authentication",
description: "Add OAuth 2.0 login flow with Google and GitHub providers.",
priority: 2, // 0=None, 1=Urgent, 2=High, 3=Medium, 4=Low
});
if (result.success) {
const issue = await result.issue;
console.log(`Created: ${issue?.identifier} — ${issue?.title}`);
console.log(`URL: ${issue?.url}`);
}
// Issue with full metadata
const labelResult = await client.issueLabels({ filter: { name: { eq: "Bug" } } });
const bugLabel = labelResult.nodes[0];
const states = await team.states();
const todoState = states.nodes.find(s => s.type === "unstarted")!;
await client.createIssue({
teamId: team.id,
title: "Fix login redirect loop on Safari",
description: "Users get stuck in infinite redirect after SSO callback.",
priority: 1,
stateId: todoState.id,
assigneeId: "user-uuid",
labelIds: bugLabel ? [bugLabel.id] : [],
estimate: 3,
dueDate: "2026-04-15",
});
Step 2: Update Issues
// Update by issue ID
await client.updateIssue("issue-uuid", {
title: "Updated title",
priority: 1,
estimate: 5,
dueDate: "2026-04-30",
});
// Find issue by team key + number, then update
const issues = await client.issues({
filter: { number: { eq: 123 }, team: { key: { eq: "ENG" } } },
});
const issue = issues.nodes[0];
if (issue) {
await issue.update({
priority: 2,
description: "Updated description with more details.",
});
}
// Add/remove labels
const featureLabel = (await client.issueLabels({
filter: { name: { eq: "Feature" } },
})).nodes[0];
if (featureLabel) {
await client.updateIssue(issue.id, {
labelIds: [...(issue.labelIds ?? []), featureLabel.id],Project, cycle, and roadmap management workflows with Linear.
Linear Core Workflow B: Projects & Cycles
Overview
Manage projects, cycles (sprints), milestones, and roadmaps using the Linear API. Projects group issues across teams with states (planned, started, paused, completed, canceled), target dates, and progress tracking. Cycles are time-boxed iterations (sprints) owned by a single team. Initiatives group projects at the organizational level.
Prerequisites
- Linear SDK configured with API key or OAuth token
- Understanding of Linear's hierarchy: Organization > Team > Cycle/Project > Issue
- Team access with project create permissions
Instructions
Step 1: Project CRUD
import { LinearClient } from "@linear/sdk";
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
// List projects (optionally filter by team)
const projects = await client.projects({
filter: {
accessibleTeams: { some: { key: { eq: "ENG" } } },
state: { nin: ["completed", "canceled"] },
},
orderBy: "updatedAt",
first: 20,
});
for (const project of projects.nodes) {
console.log(`${project.name} [${project.state}] — progress: ${Math.round(project.progress * 100)}%`);
}
// Create a project
const teams = await client.teams();
const eng = teams.nodes.find(t => t.key === "ENG")!;
const projectResult = await client.createProject({
name: "Authentication Overhaul",
description: "Modernize auth infrastructure with OAuth 2.0 + MFA.",
teamIds: [eng.id],
state: "planned",
targetDate: "2026-06-30",
});
const project = await projectResult.project;
console.log(`Created project: ${project?.name} (${project?.id})`);
// Update project
await client.updateProject(project!.id, {
state: "started",
description: "Updated scope: includes SSO integration.",
});
// Get project by slug
const found = await client.projects({
filter: { slugId: { eq: "auth-overhaul" } },
});
Step 2: Project Milestones
// Create milestones for a project
await client.createProjectMilestone({
projectId: project!.id,
name: "OAuth 2.0 Implementation",
targetDate: "2026-04-15",
});
await client.createProjectMilestone({
projectId: project!.id,
name: "MFA Rollout",
targetDate: "2026-05-30",
});
// List milestones
const milestones = await project!.projectMilestones();
for (const ms of milestones.nodes) {
console.log(` Milestone: ${ms.name} — target: ${ms.targetDate}`);
}
Step 3: Assign Issues to Projects
// Create issue directly in a project
await client.createIssue({
teamId: eng.id,
title: "Implement OAuth 2.0 login flow",
projectId: projecOptimize Linear API usage, reduce unnecessary calls, and maximize efficiency within rate limit budgets.
Linear Cost Tuning
Overview
Optimize Linear API usage to stay within rate budgets and minimize infrastructure costs. Linear's API is free (no per-request billing), but rate limits (5,000 requests/hour, 250,000 complexity/hour) constrain throughput. Efficient patterns let you do more within these limits.
Cost Factors
| Factor | Budget Impact | Optimization |
|---|---|---|
| Request count | 5,000/hr limit | Batch operations, coalesce requests |
| Query complexity | 250,000/hr limit | Flat queries, small page sizes |
| Payload size | Bandwidth + latency | Select only needed fields |
| Polling frequency | Wastes budget | Replace with webhooks |
| Webhook volume | Processing costs | Filter by event type and team |
Instructions
Step 1: Audit Current Usage
import { LinearClient } from "@linear/sdk";
class UsageTracker {
private requests = 0;
private totalComplexity = 0;
private startTime = Date.now();
track(complexity: number) {
this.requests++;
this.totalComplexity += complexity;
}
report() {
const elapsedHours = (Date.now() - this.startTime) / 3600000;
return {
requests: this.requests,
requestsPerHour: Math.round(this.requests / elapsedHours),
totalComplexity: this.totalComplexity,
complexityPerHour: Math.round(this.totalComplexity / elapsedHours),
budgetUsed: {
requests: `${Math.round((this.requests / elapsedHours / 5000) * 100)}%`,
complexity: `${Math.round((this.totalComplexity / elapsedHours / 250000) * 100)}%`,
},
};
}
}
const tracker = new UsageTracker();
Step 2: Replace Polling with Webhooks
The single biggest optimization. A polling loop checking every minute uses 1,440 requests/day. A webhook uses zero.
// BAD: Polling every 60 seconds (1,440 req/day, ~60 req/hr)
setInterval(async () => {
const issues = await client.issues({
first: 100,
filter: { updatedAt: { gte: lastCheck } },
});
await syncIssues(issues.nodes);
lastCheck = new Date().toISOString();
}, 60000);
// GOOD: Webhook receives updates in real-time (0 requests for monitoring)
app.post("/webhooks/linear", express.raw({ type: "*/*" }), (req, res) => {
// Verify signature, process event
const event = JSON.parse(req.body.toString());
if (event.type === "Issue") {
syncSingleIssue(event.data);
}
res.json({ ok: true });
});
Step 3: Minimize Query Complexity
// BAD: ~12,500 pts — deeply nested with large page
// issues(50) * (labels(50 default) * fields + comments(50) * user)
const expensive = `query {
issues(fData synchronization, backup, and consistency patterns for Linear.
Linear Data Handling
Overview
Implement reliable data synchronization, backup, and consistency for Linear integrations. Covers full sync, incremental webhook sync, JSON/CSV export, consistency checks, and conflict resolution.
Prerequisites
@linear/sdkwith API key configured- Database for local storage (any ORM — Drizzle, Prisma, Knex)
- Understanding of eventual consistency
Instructions
Step 1: Data Model Schema
// 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>;
Step 2: Full Sync
Paginate through all issues, resolve relations, and upsert locally.
import { 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,
identComprehensive debugging toolkit for Linear integrations.
Linear Debug Bundle
Overview
Production-ready debugging tools for Linear API integrations: instrumented client with request/response logging, request tracer with performance metrics, health check endpoint, environment validator, and interactive debug console.
Prerequisites
@linear/sdkinstalled and configured- Node.js 18+
- Optional: pino or winston for structured logging
Instructions
Tool 1: Debug Client Wrapper
Intercept all API calls with timing, logging, and error capture by wrapping the SDK's underlying fetch.
import { LinearClient } from "@linear/sdk";
interface DebugOptions {
logRequests?: boolean;
logResponses?: boolean;
onRequest?: (query: string, variables: any) => void;
onResponse?: (query: string, duration: number, data: any) => void;
onError?: (query: string, duration: number, error: any) => void;
}
function createDebugClient(apiKey: string, opts: DebugOptions = {}): LinearClient {
const { logRequests = true, logResponses = true } = opts;
return new LinearClient({
apiKey,
headers: { "X-Debug": "true" },
});
}
// Manual instrumentation wrapper
async function debugQuery<T>(
label: string,
fn: () => Promise<T>,
opts?: DebugOptions
): Promise<T> {
const start = Date.now();
console.log(`[Linear:DEBUG] >>> ${label}`);
try {
const result = await fn();
const ms = Date.now() - start;
console.log(`[Linear:DEBUG] <<< ${label} (${ms}ms) OK`);
opts?.onResponse?.(label, ms, result);
return result;
} catch (error) {
const ms = Date.now() - start;
console.error(`[Linear:DEBUG] !!! ${label} (${ms}ms) FAILED:`, error);
opts?.onError?.(label, ms, error);
throw error;
}
}
// Usage
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
const teams = await debugQuery("teams()", () => client.teams());
const issues = await debugQuery("issues(first:50)", () => client.issues({ first: 50 }));
Tool 2: Request Tracer
Track all API calls with timing, success/failure, and aggregate stats.
interface TraceEntry {
id: string;
operation: string;
startTime: number;
endTime?: number;
duration?: number;
success: boolean;
error?: string;
}
class LinearTracer {
private traces: TraceEntry[] = [];
private maxTraces = 200;
startTrace(operation: string): string {
const id = `trace-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
this.traces.push({ id, operation, startTime: Date.now(), success: false });
if (this.traces.length > this.maxTraces) this.traces = this.traces.slice(-100);
return id;
}
endTrace(id: string, success: boolean, error?: string): void {
const trace = this.traces.find(t => t.id === id);
ifDeploy Linear-integrated applications and track deployments.
Linear Deploy Integration
Overview
Deploy Linear-integrated applications with automatic deployment tracking. Linear's GitHub integration links PRs to issues using magic words (Fixes, Closes, Resolves) and auto-detects Vercel preview links. This skill adds custom deployment comments, state transitions, and rollback tracking.
Prerequisites
- Working Linear integration with API key or OAuth
- Deployment platform (Vercel, Railway, Cloud Run, etc.)
- GitHub integration enabled in Linear (Settings > Integrations > GitHub)
Instructions
Step 1: Deployment Workflow with Linear Tracking
# .github/workflows/deploy.yml
name: Deploy and Track
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for commit scanning
- name: Deploy
id: deploy
run: |
# Replace with your deploy command
DEPLOY_URL=$(npx vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }} 2>&1 | tail -1)
echo "url=$DEPLOY_URL" >> $GITHUB_OUTPUT
- name: Track deployment in Linear
if: success()
env:
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
run: |
npx tsx scripts/track-deployment.ts \
--env production \
--url "${{ steps.deploy.outputs.url }}" \
--sha "${{ github.sha }}" \
--before "${{ github.event.before }}"
- name: Create failure issue
if: failure()
env:
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
run: |
curl -s -X POST https://api.linear.app/graphql \
-H "Authorization: $LINEAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation($i: IssueCreateInput!) { issueCreate(input: $i) { success } }",
"variables": { "i": { "teamId": "${{ vars.LINEAR_TEAM_ID }}", "title": "[Deploy] Failed: ${{ github.sha }}", "priority": 1 } }
}'
Step 2: Deployment Tracking Script
// scripts/track-deployment.ts
import { LinearClient } from "@linear/sdk";
import { execSync } from "child_process";
import { parseArgs } from "util";
const { values } = parseArgs({
options: {
env: { type: "string" },
url: { type: "string" },
sha: { type: "string" },
before: { type: "string" },
},
});
async function trackDeployment() {
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
// Extract Linear issue IDs from commit messaImplement enterprise role-based access control with Linear.
Linear Enterprise RBAC
Overview
Implement role-based access control for Linear integrations. Linear provides built-in organization roles (Owner, Admin, Member, Guest), team-level access control, and fine-grained OAuth scopes. Enterprise plans add SAML 2.0 SSO and SCIM user provisioning.
Prerequisites
- Linear Business or Enterprise plan (for SSO/SCIM)
- Organization admin access
- SSO provider (Okta, Azure AD, Google Workspace) for SAML
- Understanding of OAuth 2.0 scopes
Instructions
Step 1: Understand Linear's Built-In Roles
| Role | Capabilities |
|---|---|
| Owner | Full workspace control, billing, delete workspace |
| Admin | Manage members, teams, integrations, workspace settings |
| Member | Create/edit issues, access team-visible data |
| Guest | Read-only access to invited teams only |
These roles are fixed in Linear. Your application can layer additional permissions on top.
Step 2: Map Application Roles to OAuth Scopes
// src/auth/permissions.ts
// Available Linear OAuth scopes:
// read, write, issues:create, admin
// initiative:read, initiative:write
// customer:read, customer:write
const ROLE_SCOPES: Record<string, string[]> = {
admin: ["read", "write", "issues:create", "admin"],
manager: ["read", "write", "issues:create"],
developer: ["read", "write", "issues:create"],
viewer: ["read"],
};
const TEAM_ACCESS: Record<string, "member" | "guest" | "none"> = {
admin: "member",
manager: "member",
developer: "member",
viewer: "guest",
};
Step 3: Permission Guard
import { LinearClient } from "@linear/sdk";
interface UserContext {
userId: string;
role: string;
linearClient: LinearClient;
teamIds: string[];
}
class PermissionGuard {
constructor(private ctx: UserContext) {}
canAccessTeam(teamId: string): boolean {
if (this.ctx.role === "admin") return true;
return this.ctx.teamIds.includes(teamId);
}
async canModifyIssue(issueId: string): Promise<boolean> {
if (this.ctx.role === "viewer") return false;
const issue = await this.ctx.linearClient.issue(issueId);
const team = await issue.team;
return team ? this.canAccessTeam(team.id) : false;
}
canCreateIssue(): boolean {
return ["admin", "manager", "developer"].includes(this.ctx.role);
}
canDeleteIssue(): boolean {
return this.ctx.role === "admin&Create your first Linear issue and query using the SDK and GraphQL API.
Linear Hello World
Overview
Create your first issue, query teams, and explore the Linear data model using the @linear/sdk. Linear's API is GraphQL-based -- the SDK wraps it with typed models, lazy-loaded relations, and pagination helpers.
Prerequisites
@linear/sdkinstalled (npm install @linear/sdk)LINEARAPIKEYenvironment variable set (starts withlinapi)- Access to at least one Linear team
Instructions
Step 1: Connect and Identify
import { LinearClient } from "@linear/sdk";
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
// Get current authenticated user
const me = await client.viewer;
console.log(`Hello, ${me.name}! (${me.email})`);
// Get your organization
const org = await me.organization;
console.log(`Workspace: ${org.name}`);
Step 2: List Teams
Every issue in Linear belongs to a team. Teams have a short key (e.g., "ENG") used in identifiers like ENG-123.
const teams = await client.teams();
console.log("Your teams:");
for (const team of teams.nodes) {
console.log(` ${team.key} — ${team.name} (${team.id})`);
}
Step 3: Create Your First Issue
const team = teams.nodes[0];
const result = await client.createIssue({
teamId: team.id,
title: "Hello from Linear SDK!",
description: "This issue was created using the `@linear/sdk` TypeScript SDK.",
priority: 3, // 0=None, 1=Urgent, 2=High, 3=Medium, 4=Low
});
if (result.success) {
const issue = await result.issue;
console.log(`Created: ${issue?.identifier} — ${issue?.title}`);
console.log(`URL: ${issue?.url}`);
}
Step 4: Query Issues
// Get recent issues from a team
const issues = await client.issues({
filter: {
team: { key: { eq: team.key } },
state: { type: { nin: ["completed", "canceled"] } },
},
first: 10,
});
console.log(`\nOpen issues in ${team.key}:`);
for (const issue of issues.nodes) {
const state = await issue.state;
console.log(` ${issue.identifier}: ${issue.title} [${state?.name}]`);
}
Step 5: Explore Workflow States
Each team has customizable workflow states organized by type: triage, backlog, unstarted, started, completed, canceled.
const states = await team.states();
console.log(`\nWorkflow states for ${team.key}:`);
for (const state of states.nodes) {
console.log(` ${state.name} (type: ${state.type}, position: ${state.position})`);
}
Step 6: Fetch a Single Issue by Identifier
Production incident response procedures for Linear integrations.
ReadWriteEditBash(curl:*)Grep
Linear Incident Runbook
Overview
Step-by-step runbooks for handling production incidents with Linear integrations. Covers API authentication failures, rate limiting, webhook issues, and Linear platform outages.
Incident Classification
Severity
Impact
Response
Examples
SEV1
Complete integration outage
< 15 min
Auth broken, API unreachable
SEV2
Major degradation
< 30 min
High error rate, rate limited
SEV3
Minor issues
< 2 hours
Some features affected
SEV4
Low impact
< 24 hours
Warnings, non-critical
Immediate Actions (All Incidents)
Step 1: Confirm the Issue
set -euo pipefail
# 1. Check Linear platform status
curl -s https://status.linear.app/api/v2/status.json | jq '.status'
# 2. Test your API key
curl -s -X POST https://api.linear.app/graphql \
-H "Authorization: $LINEAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "{ viewer { name email } }"}' | jq .
# 3. Check rate limit status
curl -s -I -X POST https://api.linear.app/graphql \
-H "Authorization: $LINEAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "{ viewer { id } }"}' 2>&1 | grep -i ratelimit
# 4. Check your app health endpoint
curl -s https://yourapp.com/health/linear | jq .
Step 2: Gather Diagnostic Info
// scripts/incident-diagnostic.ts
import { LinearClient } from "@linear/sdk";
async function diagnose() {
console.log("=== Linear Incident Diagnostic ===\n");
// 1. Auth check
console.log("1. Authentication:");
try {
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
const viewer = await client.viewer;
console.log(` OK: ${viewer.name} (${viewer.email})`);
} catch (error: any) {
console.log(` FAILED: ${error.message}`);
}
// 2. Team access
console.log("\n2. Team Access:");
try {
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
const teams = await client.teams();
console.log(` OK: ${teams.nodes.length} teams accessible`);
teams.nodes.forEach(t => console.log(` ${t.key}: ${t.name}`));
} catch (error: any) {
console.log(` FAILED: ${error.message}`);
}
// 3. Write test
console.log("\n3. Write Capability:");
try {
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
const teams = await client.teams();
const result = await client.createIssue({
teamId: teams.nodes[0].id,
title: "[INCIDENT-DIAG] Safe
Install and configure Linear SDK/CLI authentication.
Linear Install & Auth
Overview
Install the @linear/sdk TypeScript SDK and configure authentication for the Linear GraphQL API at https://api.linear.app/graphql. Supports personal API keys for scripts and OAuth 2.0 (with PKCE) for user-facing apps.
Prerequisites
- Node.js 18+ (SDK is TypeScript-first, works in any JS environment)
- Package manager (npm, pnpm, or yarn)
- Linear account with workspace access
- For API key: Settings > Account > API > Personal API keys
- For OAuth: Create app at Settings > Account > API > OAuth applications
Instructions
Step 1: Install the SDK
set -euo pipefail
npm install @linear/sdk
# or: pnpm add @linear/sdk
# or: yarn add @linear/sdk
The SDK exposes LinearClient, typed models for every entity (Issue, Project, Cycle, Team), and error classes (LinearError, InvalidInputLinearError).
Step 2: API Key Authentication (Scripts & Server-Side)
Generate a Personal API key at Linear Settings > Account > API > Personal API keys. Keys start with linapi and are shown only once.
import { LinearClient } from "@linear/sdk";
// Environment variable (recommended)
const client = new LinearClient({
apiKey: process.env.LINEAR_API_KEY,
});
// Verify connection
const me = await client.viewer;
console.log(`Authenticated as: ${me.name} (${me.email})`);
Environment setup:
# .env (never commit)
LINEAR_API_KEY=lin_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
# .gitignore
echo '.env' >> .gitignore
Step 3: OAuth 2.0 Authentication (User-Facing Apps)
Linear supports the standard Authorization Code flow with optional PKCE. As of October 2025, newly created OAuth apps issue refresh tokens by default.
import crypto from "crypto";
// 1. Build authorization URL
const SCOPES = ["read", "write", "issues:create"];
const state = crypto.randomBytes(16).toString("hex");
const authUrl = new URL("https://linear.app/oauth/authorize");
authUrl.searchParams.set("client_id", process.env.LINEAR_CLIENT_ID!);
authUrl.searchParams.set("redirect_uri", process.env.LINEAR_REDIRECT_URI!);
authUrl.searchParams.set("response_type", "code");
authUrl.searchParams.set("scope", SCOPES.join(","));
authUrl.searchParams.set("state", state);
// Optional PKCE:
// authUrl.searchParams.set("code_challenge", challenge);
// authUrl.searchParams.set("code_challenge_method", "S256");
// 2. Exchange authorization code for tokens
const tokenResponse = await fetch("https://api.linear.app/oauth/tokenSet up local Linear development environment and testing workflow.
Linear Local Dev Loop
Overview
Set up an efficient local development workflow for building Linear integrations. Covers project scaffolding, environment config, test utilities, webhook tunneling with ngrok, and integration testing with vitest.
Prerequisites
- Node.js 18+ with TypeScript
@linear/sdkpackage- Separate Linear workspace or team for development (recommended)
- ngrok or cloudflared for webhook tunnel testing
Instructions
Step 1: Project Scaffolding
set -euo pipefail
mkdir linear-integration && cd linear-integration
npm init -y
npm install @linear/sdk dotenv
npm install -D typescript @types/node vitest tsx
# TypeScript config
npx tsc --init --target ES2022 --module NodeNext --moduleResolution NodeNext --strict
Step 2: Environment Configuration
# .env (never commit)
cat > .env << 'EOF'
LINEAR_API_KEY=lin_api_dev_xxxxxxxxxxxx
LINEAR_WEBHOOK_SECRET=whsec_dev_xxxxxxxxxxxx
LINEAR_DEV_TEAM_KEY=DEV
NODE_ENV=development
EOF
# .env.example (commit this for onboarding)
cat > .env.example << 'EOF'
LINEAR_API_KEY=lin_api_your_key_here
LINEAR_WEBHOOK_SECRET=
LINEAR_DEV_TEAM_KEY=DEV
NODE_ENV=development
EOF
echo -e ".env\n.env.local\n.env.*.local" >> .gitignore
Step 3: Client Module with Connection Verification
// src/client.ts
import { LinearClient } from "@linear/sdk";
import "dotenv/config";
let _client: LinearClient | null = null;
export function getClient(): LinearClient {
if (!_client) {
const apiKey = process.env.LINEAR_API_KEY;
if (!apiKey) throw new Error("LINEAR_API_KEY not set — copy .env.example to .env");
_client = new LinearClient({ apiKey });
}
return _client;
}
export async function verifyConnection(): Promise<void> {
const client = getClient();
const viewer = await client.viewer;
const teams = await client.teams();
console.log(`[Linear] Connected as ${viewer.name} (${viewer.email})`);
console.log(`[Linear] Teams: ${teams.nodes.map(t => t.key).join(", ")}`);
}
Step 4: Test Data Utilities
// src/test-utils.ts
import { getClient } from "./client";
const TEST_PREFIX = "[DEV-TEST]";
export async function getDevTeam() {
const client = getClient();
const teamKey = process.env.LINEAR_DEV_TEAM_KEY ?? "DEV";
const teams = await client.teams({ filter: { key: { eq: teamKey } } });
const team = teams.nodes[0];
if (!team) throw new Error(`Team ${teamKey} not found — set LINEAR_DEV_TEAM_KEY`);
return team;
}
export async function createTestIssue(title?: string) {
const client = getClient();
const team = await getDevTeam();
const result = await client.createIssue(Migrate from Jira, Asana, GitHub Issues, or other tools to Linear.
Linear Migration Deep Dive
Overview
Comprehensive guide for migrating from Jira, Asana, or GitHub Issues to Linear. Covers assessment, workflow mapping, data export, transformation, batch import with hierarchy support, and post-migration validation. Linear also has a built-in importer (Settings > Import) for Jira, Asana, GitHub, and CSV.
Prerequisites
- Admin access to source system (Jira/Asana/GitHub)
- Linear workspace with admin access
- API keys for both source and Linear
- Migration timeline and rollback plan
Instructions
Step 1: Migration Assessment Checklist
Data Volume
[ ] Total issues/tasks: ___
[ ] Projects/boards: ___
[ ] Users to map: ___
[ ] Attachments: ___
[ ] Custom fields: ___
[ ] Comments: ___
Workflow Analysis
[ ] Source statuses documented
[ ] Status-to-state mapping defined
[ ] Priority mapping defined
[ ] Issue type-to-label mapping defined
[ ] Automations to recreate: ___
Timeline
[ ] Migration window: ___
[ ] Parallel run period: ___
[ ] Cutover date: ___
[ ] Rollback deadline: ___
Step 2: Workflow Mapping
Jira -> Linear:
| Jira Status | Linear State (type) |
|---|---|
| To Do | Todo (unstarted) |
| In Progress | In Progress (started) |
| In Review | In Review (started) |
| Blocked | In Progress (started) + "Blocked" label |
| Done | Done (completed) |
| Won't Do | Canceled (canceled) |
| Jira Priority | Linear Priority |
|---|---|
| Highest/Blocker | 1 (Urgent) |
| High | 2 (High) |
| Medium | 3 (Medium) |
| Low/Lowest | 4 (Low) |
| Jira Issue Type | Linear Label |
|---|---|
| Bug | Bug |
| Story | Feature |
| Task | Task |
| Epic | (becomes Project or parent issue) |
Asana -> Linear:
| Asana Section | Linear State |
|---|---|
| Backlog | Backlog (backlog) |
| To Do | Todo (unstarted) |
| In Progress | In Progress (started) |
| Review | In Review (started) |
| Done | Done (completed) |
Step 3: Export from Source System
Jira Export:
// src/migration/jira-exporter.ts
interface JiraIssue {
key: string;
summary: string;
description: string;
status: string;
priority: string;
issuetype: string;
assignee?: string;
Configure Linear across development, staging, and production environments.
Linear Multi-Environment Setup
Overview
Configure Linear integrations across dev, staging, and production with isolated API keys, secret management, environment guards, and per-environment webhook routing. Use separate Linear workspaces or at minimum separate API keys per environment.
Prerequisites
- Separate Linear API keys per environment (dev, staging, prod)
- Secret management (Vault, AWS Secrets Manager, GCP Secret Manager)
- CI/CD pipeline with environment support
- Node.js 18+
Instructions
Step 1: Environment Configuration
// src/config/linear.ts
import { LinearClient } from "@linear/sdk";
interface LinearEnvConfig {
apiKey: string;
webhookSecret: string;
defaultTeamKey: string;
enableWebhooks: boolean;
enableDebugLogging: boolean;
cacheEnabled: boolean;
}
type Environment = "development" | "staging" | "production" | "test";
function getEnvironment(): Environment {
const env = process.env.NODE_ENV ?? "development";
if (!["development", "staging", "production", "test"].includes(env)) {
throw new Error(`Unknown NODE_ENV: ${env}`);
}
return env as Environment;
}
async function loadConfig(): Promise<LinearEnvConfig> {
const env = getEnvironment();
// In production, use secret manager instead of env vars
if (env === "production" || env === "staging") {
return {
apiKey: await getSecret(`linear-api-key-${env}`),
webhookSecret: await getSecret(`linear-webhook-secret-${env}`),
defaultTeamKey: process.env.LINEAR_DEFAULT_TEAM_KEY ?? "ENG",
enableWebhooks: true,
enableDebugLogging: env === "staging",
cacheEnabled: true,
};
}
// Dev/test: use environment variables
return {
apiKey: process.env.LINEAR_API_KEY ?? "",
webhookSecret: process.env.LINEAR_WEBHOOK_SECRET ?? "",
defaultTeamKey: process.env.LINEAR_DEV_TEAM_KEY ?? "DEV",
enableWebhooks: false, // No webhook server in local dev
enableDebugLogging: true,
cacheEnabled: false,
};
}
Step 2: Secret Manager Integration
// GCP Secret Manager
import { SecretManagerServiceClient } from "@google-cloud/secret-manager";
async function getSecret(name: string): Promise<string> {
const client = new SecretManagerServiceClient();
const projectId = process.env.GCP_PROJECT_ID!;
const [version] = await client.accessSecretVersion({
name: `projects/${projectId}/secrets/${name}/versions/latest`,
});
return version.payload?.data?.toString() ?? "";
}
// AWS Secrets Manager
import { SecretsManagerClient, GetSecretValueCommand } from "@aws-sdk/client-secrets-manager";
async function getSecretAWS(name: string):Implement monitoring, logging, and alerting for Linear integrations.
Linear Observability
Overview
Production monitoring for Linear integrations using Prometheus metrics, structured logging with pino, health checks, and alerting rules. Track API latency, error rates, rate limit headroom, and webhook throughput.
Prerequisites
- Linear integration deployed
- Prometheus or Datadog for metrics
- Structured logging (pino, winston)
- Alerting system (PagerDuty, OpsGenie, Slack)
Instructions
Step 1: Define Metrics
// src/metrics/linear-metrics.ts
import { Counter, Histogram, Gauge, register } from "prom-client";
export const metrics = {
// API request tracking
apiRequests: new Counter({
name: "linear_api_requests_total",
help: "Total Linear API requests",
labelNames: ["operation", "status"],
}),
// Request duration
apiLatency: new Histogram({
name: "linear_api_request_duration_seconds",
help: "Linear API request duration",
labelNames: ["operation"],
buckets: [0.1, 0.25, 0.5, 1, 2, 5, 10],
}),
// Rate limit headroom
rateLimitRemaining: new Gauge({
name: "linear_rate_limit_remaining",
help: "Remaining rate limit budget",
labelNames: ["type"], // "requests" or "complexity"
}),
// Webhook tracking
webhooksReceived: new Counter({
name: "linear_webhooks_received_total",
help: "Total webhooks received",
labelNames: ["type", "action"],
}),
webhookProcessingDuration: new Histogram({
name: "linear_webhook_processing_seconds",
help: "Webhook processing duration",
labelNames: ["type"],
buckets: [0.01, 0.05, 0.1, 0.5, 1, 5],
}),
// Cache effectiveness
cacheHits: new Counter({
name: "linear_cache_hits_total",
help: "Cache hit count",
labelNames: ["key"],
}),
cacheMisses: new Counter({
name: "linear_cache_misses_total",
help: "Cache miss count",
labelNames: ["key"],
}),
};
// Expose metrics endpoint
app.get("/metrics", async (req, res) => {
res.set("Content-Type", register.contentType);
res.end(await register.metrics());
});
Step 2: Instrumented Client Wrapper
import { LinearClient } from "@linear/sdk";
function instrumentedCall<T>(
operation: string,
fn: () => Promise<T>
): Promise<T> {
const timer = metrics.apiLatency.startTimer({ operation });
return fn()
.then((result) => {
metrics.apiRequests.inc({ operation, status: "success" });
timer();
return result;
})
.catch((error: any) => {
const status = error.status === 429 ? "rate_limited"Optimize Linear API queries, caching, and batching for performance.
Linear Performance Tuning
Overview
Optimize Linear API usage for minimal latency and efficient resource consumption. The three main levers are: (1) query flattening to avoid N+1 and reduce complexity, (2) caching static data with webhook-driven invalidation, and (3) batching mutations into single GraphQL requests.
Key numbers:
- Query complexity budget: 250,000 pts/hour, max 10,000 per query
- Each property: 0.1 pt, each object: 1 pt, connections: multiply by
first - Best practice: sort by
updatedAtto get fresh data first
Prerequisites
- Working Linear integration with
@linear/sdk - Understanding of GraphQL query structure
- Optional: Redis for distributed caching
Instructions
Step 1: Eliminate N+1 Queries
The SDK lazy-loads relations. Accessing .assignee on 50 issues makes 50 separate API calls.
import { LinearClient } from "@linear/sdk";
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
// BAD: N+1 — 1 query for issues + 50 for assignees + 50 for states = 101 requests
const issues = await client.issues({ first: 50 });
for (const i of issues.nodes) {
const assignee = await i.assignee; // API call!
const state = await i.state; // API call!
console.log(`${i.identifier}: ${assignee?.name} [${state?.name}]`);
}
// GOOD: 1 request — use rawRequest with exact field selection
const response = await client.client.rawRequest(`
query TeamDashboard($teamId: String!) {
team(id: $teamId) {
issues(first: 50, orderBy: updatedAt) {
nodes {
id identifier title priority estimate updatedAt
assignee { name email }
state { name type }
labels { nodes { name color } }
project { name }
}
pageInfo { hasNextPage endCursor }
}
}
}
`, { teamId: "team-uuid" });
// Complexity: ~50 * (10 fields * 0.1 + 4 objects) = ~275 pts
Step 2: Cache Static Data
Teams, workflow states, and labels change rarely. Cache them with appropriate TTLs.
interface CacheEntry<T> {
data: T;
expiresAt: number;
}
class LinearCache {
private store = new Map<string, CacheEntry<any>>();
get<T>(key: string): T | null {
const entry = this.store.get(key);
if (!entry || Date.now() > entry.expiresAt) {
this.store.delete(key);
return null;
}
return entry.data;
}
set<T>(key: string, data: T, ttlSeconds: number): void {
this.store.set(key, { data, expiresAt: Date.now() + ttlSeconds * 1000 });
}
invalidate(key: string): void {
this.store.delete(key);
}
}
const cache = new LinearCache();
// Teams: 10 minute TTL (almost never change)
async function getTeams(client: LinearCliProduction readiness checklist for Linear integrations.
Linear Production Checklist
Overview
Comprehensive checklist and implementation patterns for deploying Linear integrations to production. Covers authentication, error handling, rate limiting, monitoring, data handling, and deployment verification.
Prerequisites
- Working development integration passing all tests
- Production Linear workspace (or production API key)
- Deployment infrastructure (Vercel, Cloud Run, etc.)
- Secret management solution (not
.envfiles in production)
Pre-Production Checklist
1. Authentication & Security
[ ] Production API key generated (separate from dev)
[ ] API key stored in secret manager (Vault, AWS SM, GCP SM)
[ ] OAuth redirect URIs updated for production domain
[ ] Webhook secrets are unique per environment
[ ] All dev secrets rotated before launch
[ ] HTTPS enforced on all endpoints
[ ] Webhook HMAC-SHA256 verification implemented
[ ] Webhook timestamp validation (< 60s age)
[ ] Token refresh flow implemented (mandatory since Oct 2025)
2. Error Handling & Resilience
[ ] All Linear API calls wrapped in try/catch
[ ] Rate limit retry with exponential backoff (max 5 retries)
[ ] 30s timeout on all API calls
[ ] Graceful degradation when Linear API is down
[ ] Error logging includes context (no secrets in logs)
[ ] InvalidInputLinearError caught separately from network errors
[ ] Alerts configured for auth failures and error rate spikes
3. Performance & Rate Limits
[ ] Pagination with first:50 for all list queries
[ ] Caching for static data (teams, states, labels) — 10-30 min TTL
[ ] Request batching for bulk operations (20 mutations per batch)
[ ] Query complexity stays under 5,000 pts per request
[ ] No polling — webhooks for real-time updates
[ ] N+1 query patterns eliminated (use rawRequest for joins)
[ ] Response times monitored with p95 alerting
4. Monitoring & Observability
[ ] Health check endpoint hitting Linear API
[ ] API latency metrics collected per operation
[ ] Error rate monitoring with alerting (>1% = alert)
[ ] Rate limit remaining tracked (alert if < 100 requests)
[ ] Structured JSON logging for API calls and webhooks
[ ] Webhook delivery tracking via Linear-Delivery header
5. Data Handling
[ ] No PII logged or stored unnecessarily
[ ] Webhook event idempotency (deduplicate by Linear-Delivery)
[ ] Data retention policy defined for synced data
[ ] Stale data detection with periodic consistency checks
Production Configuration
import { LinearClient } from "@linear/sdk";
interface ProdConfig {
linear: { apiKey: string; webhookSecret: string };
rateLimit: { maxRetries: number; baseDelayMs: number; maxDelayMs: number };
cache: { teamsTtl: number; statesTtl: number; labHandle Linear API rate limiting, complexity budgets, and quotas.
Linear Rate Limits
Overview
Linear uses the leaky bucket algorithm with two rate limiting dimensions. Understanding both is critical for reliable integrations:
| Budget | Limit | Refill Rate |
|---|---|---|
| Requests | 5,000/hour per API key | ~83/min constant refill |
| Complexity | 250,000 points/hour | ~4,167/min constant refill |
| Max single query | 10,000 points | Hard reject if exceeded |
Complexity scoring: Each property = 0.1 pt, each object = 1 pt, connections multiply children by first arg (default 50), then round up.
Prerequisites
@linear/sdkinstalled- Understanding of HTTP response headers
- Familiarity with async/await patterns
Instructions
Step 1: Read Rate Limit Headers
Linear returns rate limit info on every response.
const response = await fetch("https://api.linear.app/graphql", {
method: "POST",
headers: {
Authorization: process.env.LINEAR_API_KEY!,
"Content-Type": "application/json",
},
body: JSON.stringify({ query: "{ viewer { id } }" }),
});
// Key headers
const headers = {
requestsRemaining: response.headers.get("x-ratelimit-requests-remaining"),
requestsLimit: response.headers.get("x-ratelimit-requests-limit"),
requestsReset: response.headers.get("x-ratelimit-requests-reset"),
complexityRemaining: response.headers.get("x-ratelimit-complexity-remaining"),
complexityLimit: response.headers.get("x-ratelimit-complexity-limit"),
queryComplexity: response.headers.get("x-complexity"),
};
console.log(`Requests: ${headers.requestsRemaining}/${headers.requestsLimit}`);
console.log(`Complexity: ${headers.complexityRemaining}/${headers.complexityLimit}`);
console.log(`This query cost: ${headers.queryComplexity} points`);
Step 2: Exponential Backoff with Jitter
import { LinearClient } from "@linear/sdk";
class RateLimitedClient {
private client: LinearClient;
constructor(apiKey: string) {
this.client = new LinearClient({ apiKey });
}
async withRetry<T>(fn: () => Promise<T>, maxRetries = 5): Promise<T> {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await fn();
} catch (error: any) {
const isRateLimited = error.status === 429 ||
error.message?.includes("rate") ||
error.type === "ratelimited";
if (!isRateLimited || attempt === maxRetries - 1) throw error;
// Exponential backoff: 1s, 2s, 4s,Production-grade Linear integration architecture patterns.
Linear Reference Architecture
Overview
Production-grade architectural patterns for Linear integrations. Choose the right pattern based on team size, complexity, and real-time requirements.
Architecture Decision Matrix
| Pattern | Best For | Complexity | Rate Budget | Example |
|---|---|---|---|---|
| Simple | Single app, small team | Low | < 500 req/hr | Internal dashboard |
| Service-Oriented | Multiple apps, shared state | Medium | 500-2,000 req/hr | Platform with Linear sync |
| Event-Driven | Real-time needs, many consumers | High | < 500 req/hr + webhooks | Multi-service notification system |
| CQRS | Audit trails, complex queries | Very High | Minimal API calls | Compliance-grade tracking |
Architecture 1: Simple Integration
Direct SDK calls from your application. Best for scripts, internal tools, and prototypes.
// src/linear.ts — single module, shared client
import { LinearClient } from "@linear/sdk";
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
// Direct SDK calls from any part of your app
export async function getOpenIssues(teamKey: string) {
return client.issues({
first: 50,
filter: {
team: { key: { eq: teamKey } },
state: { type: { nin: ["completed", "canceled"] } },
},
orderBy: "priority",
});
}
export async function createBugReport(teamId: string, title: string, description: string) {
const labels = await client.issueLabels({ filter: { name: { eq: "Bug" } } });
return client.createIssue({
teamId,
title,
description,
priority: 2,
labelIds: labels.nodes.length ? [labels.nodes[0].id] : [],
});
}
Architecture 2: Service-Oriented with Gateway
Centralized Linear access through a gateway service with caching and rate limiting.
// src/linear-gateway.ts
import { LinearClient } from "@linear/sdk";
class LinearGateway {
private client: LinearClient;
private cache = new Map<string, { data: any; expiresAt: number }>();
private requestQueue: Array<{ fn: () => Promise<any>; resolve: Function; reject: Function }> = [];
private processing = false;
constructor(apiKey: string) {
this.client = new LinearClient({ apiKey });
}
// Cached reads
async getTeams() {
return this.cachedQuery("teams", () => this.client.teams().then(r => r.nodes), 600);
}
async getStates(teamId: string) {
return this.cachedQuery(`states:${teamId}`, async () => {
const team = await this.client.team(teamId);
return (await team.states()).nodes;
}, 1800);
}
TypeScript/JavaScript SDK patterns and best practices for Linear.
Linear SDK Patterns
Overview
Production patterns for @linear/sdk. The SDK wraps Linear's GraphQL API with strongly-typed models, cursor-based pagination (fetchNext()/fetchPrevious()), lazy-loaded relations, and typed error classes. Understanding these patterns avoids N+1 queries and rate limit waste.
Prerequisites
@linear/sdkinstalled- TypeScript project with
strict: true - Understanding of async/await and GraphQL concepts
Instructions
Pattern 1: Client Singleton
import { LinearClient } from "@linear/sdk";
let _client: LinearClient | null = null;
export function getLinearClient(): LinearClient {
if (!_client) {
const apiKey = process.env.LINEAR_API_KEY;
if (!apiKey) throw new Error("LINEAR_API_KEY is required");
_client = new LinearClient({ apiKey });
}
return _client;
}
// For multi-user OAuth apps — one client per user
const clientCache = new Map<string, LinearClient>();
export function getClientForUser(userId: string, accessToken: string): LinearClient {
if (!clientCache.has(userId)) {
clientCache.set(userId, new LinearClient({ accessToken }));
}
return clientCache.get(userId)!;
}
Pattern 2: Cursor-Based Pagination
Linear uses Relay-style cursor pagination. The SDK provides fetchNext() and fetchPrevious() helpers, plus raw pageInfo for manual control.
// SDK built-in pagination helpers
const firstPage = await client.issues({ first: 50 });
console.log(`Page 1: ${firstPage.nodes.length} issues`);
if (firstPage.pageInfo.hasNextPage) {
const secondPage = await firstPage.fetchNext();
console.log(`Page 2: ${secondPage.nodes.length} issues`);
}
// Manual pagination with cursor — good for streaming all data
async function* paginateAll<T>(
fetchPage: (cursor?: string) => Promise<{
nodes: T[];
pageInfo: { hasNextPage: boolean; endCursor: string };
}>
): AsyncGenerator<T> {
let cursor: string | undefined;
let hasNext = true;
while (hasNext) {
const page = await fetchPage(cursor);
for (const node of page.nodes) yield node;
hasNext = page.pageInfo.hasNextPage;
cursor = page.pageInfo.endCursor;
}
}
// Stream all issues without loading everything into memory
for await (const issue of paginateAll(c => client.issues({ first: 50, after: c }))) {
console.log(`${issue.identifier}: ${issue.title}`);
}
Pattern 3: Relation Loading (Avoiding N+1)
SDK models lazy-load relations. Accessing .assignee triggers a separate API call. Use raw GraphQL to batch-fetch relations in one request.
// LAZY (N+1 problem) — each .assignee is a separate API call
const issues = await client.issues(Secure API key management, OAuth best practices, and webhook verification for Linear integrations.
Linear Security Basics
Overview
Secure authentication patterns for Linear integrations: API key management, OAuth 2.0 with PKCE, token refresh (mandatory for new apps after Oct 2025), webhook HMAC-SHA256 signature verification, and secret rotation.
Prerequisites
- Linear account with API access
- Understanding of environment variables and secret management
- Familiarity with OAuth 2.0 and HMAC concepts
Instructions
Step 1: Secure API Key Storage
// NEVER hardcode keys
// BAD:
// const client = new LinearClient({ apiKey: "lin_api_xxxx" });
// GOOD: environment variable
import { LinearClient } from "@linear/sdk";
const client = new LinearClient({
apiKey: process.env.LINEAR_API_KEY!,
});
Environment setup:
# .env (never commit)
LINEAR_API_KEY=lin_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
LINEAR_WEBHOOK_SECRET=whsec_xxxxxxxxxxxx
# .gitignore
.env
.env.*
!.env.example
# .env.example (commit for documentation)
LINEAR_API_KEY=lin_api_your_key_here
LINEAR_WEBHOOK_SECRET=your_webhook_secret_here
Startup validation:
function validateConfig(): void {
const key = process.env.LINEAR_API_KEY;
if (!key) throw new Error("LINEAR_API_KEY is required");
if (!key.startsWith("lin_api_")) throw new Error("LINEAR_API_KEY has invalid format");
if (key.length < 30) throw new Error("LINEAR_API_KEY appears truncated");
}
validateConfig();
Step 2: OAuth 2.0 with PKCE
import express from "express";
import crypto from "crypto";
const app = express();
const OAUTH = {
clientId: process.env.LINEAR_CLIENT_ID!,
clientSecret: process.env.LINEAR_CLIENT_SECRET!,
redirectUri: process.env.LINEAR_REDIRECT_URI!,
scopes: ["read", "write", "issues:create"],
};
// Generate PKCE verifier and challenge
function generatePKCE() {
const verifier = crypto.randomBytes(32).toString("base64url");
const challenge = crypto.createHash("sha256").update(verifier).digest("base64url");
return { verifier, challenge };
}
// Step 1: Redirect to Linear authorization
app.get("/auth/linear", (req, res) => {
const state = crypto.randomBytes(16).toString("hex");
const { verifier, challenge } = generatePKCE();
// Store state + verifier in session
req.session!.oauthState = state;
req.session!.codeVerifier = verifier;
const url = new URL("https://linear.app/oauth/authorize");
url.searchParams.set("client_id", OAUTH.clientId);
url.searchParams.set("redirect_uri", OAUTH.redirectUri);
url.searchParams.set("response_type", "code");
url.searchParams.set(&Upgrade Linear SDK versions and handle breaking changes safely.
Linear Upgrade Migration
Overview
Safely upgrade @linear/sdk versions with zero downtime. The SDK is auto-generated from Linear's GraphQL schema -- major versions can rename fields, change return types, add required parameters, or remove deprecated methods. This skill covers version checking, upgrade procedure, compatibility layers, and rollback.
Prerequisites
- Existing Linear integration with version control (Git)
- Test suite covering Linear SDK operations
- Understanding of semantic versioning
Instructions
Step 1: Check Current vs Latest Version
set -euo pipefail
# Current installed version
npm list @linear/sdk 2>/dev/null || echo "Not installed"
# Latest available
npm view @linear/sdk version
# All recent versions
npm view @linear/sdk versions --json | jq '.[-10:]'
Step 2: Review Changelog for Breaking Changes
set -euo pipefail
# View SDK changelog on GitHub
npm view @linear/sdk repository.url
# Then check: https://github.com/linear/linear/blob/master/packages/sdk/CHANGELOG.md
# Also review Linear's API changelog:
# https://linear.app/changelog (filter for API/developer updates)
Common breaking changes between major versions:
- Renamed fields: e.g.,
issue.stateproperty vs lazy relation - Changed return types: direct value to paginated connection
- New required parameters: mutations gaining mandatory fields
- Removed methods: deprecated methods dropped
- ESM/CJS: module system changes
Step 3: Create Upgrade Branch and Install
set -euo pipefail
git checkout -b upgrade/linear-sdk-$(npm view @linear/sdk version)
npm install @linear/sdk@latest
# Immediately check for type errors
npx tsc --noEmit 2>&1 | head -50
Step 4: Fix Type Errors with Compatibility Layer
// src/linear-compat.ts
// Bridge pattern for gradual migration across SDK versions
import { LinearClient } from "@linear/sdk";
/**
* Normalize issue state access across SDK versions.
* SDK v2: issue.state was a direct string property
* SDK v3+: issue.state is a lazy-loaded WorkflowState relation
*/
export async function getIssueStateName(issue: any): Promise<string> {
if (typeof issue.state === "string") return issue.state;
const state = await issue.state;
return state?.name ?? "unknown";
}
export async function getIssueStateType(issue: any): Promise<string> {
if (typeof issue.stateType === "string") return issue.stateType;
const state = await issue.state;
return state?.type ?? "unknown";
}
/**
* Normalize team access — some versions changed Configure and handle Linear webhooks for real-time event processing.
Linear Webhooks & Events
Overview
Set up and handle Linear webhooks for real-time event processing. Linear sends HTTP POST requests for data changes on Issues, Comments, Issue Attachments, Documents, Emoji Reactions, Projects, Project Updates, Cycles, Labels, Users, and Issue SLAs.
Webhook headers:
Linear-Signature— HMAC-SHA256 hex digest of the raw bodyLinear-Delivery— Unique delivery ID for deduplicationLinear-Event— Event type (e.g., "Issue")Content-Type: application/json; charset=utf-8
Payload body includes: action, type, data, url, actor, updatedFrom (previous values on update), createdAt, webhookTimestamp (UNIX ms).
Prerequisites
- Linear workspace admin access (required for webhook creation)
- Public HTTPS endpoint for webhook delivery
- Webhook signing secret (generated in Linear Settings > API > Webhooks)
Instructions
Step 1: Build Webhook Receiver with Signature Verification
import express from "express";
import crypto from "crypto";
const app = express();
// CRITICAL: use raw body parser — JSON parsing destroys the original for signature verification
app.post("/webhooks/linear", express.raw({ type: "*/*" }), (req, res) => {
const signature = req.headers["linear-signature"] as string;
const delivery = req.headers["linear-delivery"] as string;
const eventType = req.headers["linear-event"] as string;
const rawBody = req.body.toString();
// 1. Verify HMAC-SHA256 signature
const expected = crypto
.createHmac("sha256", process.env.LINEAR_WEBHOOK_SECRET!)
.update(rawBody)
.digest("hex");
if (!crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))) {
console.error(`Invalid signature for delivery ${delivery}`);
return res.status(401).json({ error: "Invalid signature" });
}
// 2. Parse and verify timestamp (guard against replay attacks)
const event = JSON.parse(rawBody);
const age = Date.now() - event.webhookTimestamp;
if (age > 60000) {
return res.status(400).json({ error: "Webhook expired" });
}
// 3. Respond 200 immediately, process asynchronously
res.json({ received: true });
processEvent(event, delivery).catch(err =>
console.error(`Failed processing ${delivery}:`, err)
);
});
app.listen(3000, () => console.log("Webhook server on :3000"));
Step 2: Event Type Definition
interface LinearWebhookPayload {
action: "create" | "update" | "remove";
type: string; // "Issue&qReady to use linear-pack?
Related Plugins
000-jeremy-content-consistency-validator
Read-only validator that generates comprehensive discrepancy reports comparing messaging consistency across ANY HTML-based website (WordPress, Hugo, Next.js, React, Vue, static HTML, etc.), GitHub repositories, and local documentation. Detects mixed messaging without making changes.
002-jeremy-yaml-master-agent
Intelligent YAML validation, generation, and transformation agent with schema inference, linting, and format conversion capabilities
003-jeremy-vertex-ai-media-master
Comprehensive Google Vertex AI multimodal mastery for Jeremy - video processing (6+ hours), audio generation, image creation with Gemini 2.0/2.5 and Imagen 4. Marketing campaign automation, content generation, and media asset production.
004-jeremy-google-cloud-agent-sdk
Google Cloud Agent Development Kit (ADK) and Agent Starter Pack mastery - build containerized multi-agent systems with production-ready templates, deploy to Cloud Run/GKE/Agent Engine, RAG agents, ReAct agents, and multi-agent orchestration.
agent-context-manager
Automatically detects and loads AGENTS.md files to provide agent-specific instructions
ai-commit-gen
AI-powered commit message generator - analyzes your git diff and creates conventional commit messages instantly