linear-sdk-scripting
Linear SDK Scripting
Drive Linear through the official TypeScript SDK (@linear/sdk) by writing throwaway Node scripts and executing them. This replaces the Linear MCP server: anything the MCP can do (read issues, create issues, comment, change status, query teams/projects/cycles) you do here by calling SDK methods.
The SDK is preferred over hand-written GraphQL because pagination, relationship traversal, and mutation payloads are normalized, and method and input names are predictable. When you need a field or filter you do not know, consult the docs index in references/docs-index.md and fetch the specific page rather than guessing.
Workflow at a glance
Be reactive: try the script first, recover on auth failure, and only create a key as a last resort. Do not gate on $LINEAR_API_KEY being set in the current shell, that variable is almost always empty here even when a valid key is already persisted (see Setup).
- Make sure the SDK is installed in the working dir. See Setup.
- Write a small
.mjsscript into the working dir that importsLinearClientand does the task. - Run it with
node, sourcing the shell profiles first so a persisted key is picked up (see Execution pattern). - If it fails with a 401 /
AuthenticationLinearError, source the shell profiles and retry once. Only if it still fails is the key actually missing or invalid: run the API key setup flow with the user.