linear-sdk-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/.claude-plugin/marketplace.json +20 -0
  2. package/.claude-plugin/plugin.json +9 -0
  3. package/CHANGELOG.md +807 -0
  4. package/COVERAGE.md +495 -0
  5. package/LICENSE +21 -0
  6. package/MIGRATING.md +220 -0
  7. package/README.md +524 -0
  8. package/package.json +87 -0
  9. package/skills/linear-sdk-cli/SKILL.md +534 -0
  10. package/skills/linear-sdk-cli/references/api.md +27 -0
  11. package/skills/linear-sdk-cli/references/attachment.md +82 -0
  12. package/skills/linear-sdk-cli/references/auth.md +174 -0
  13. package/skills/linear-sdk-cli/references/commands.md +37 -0
  14. package/skills/linear-sdk-cli/references/comment.md +154 -0
  15. package/skills/linear-sdk-cli/references/completion.md +17 -0
  16. package/skills/linear-sdk-cli/references/config.md +99 -0
  17. package/skills/linear-sdk-cli/references/cycle.md +131 -0
  18. package/skills/linear-sdk-cli/references/document.md +180 -0
  19. package/skills/linear-sdk-cli/references/favorite.md +78 -0
  20. package/skills/linear-sdk-cli/references/initiative-update.md +67 -0
  21. package/skills/linear-sdk-cli/references/initiative.md +256 -0
  22. package/skills/linear-sdk-cli/references/issue.md +928 -0
  23. package/skills/linear-sdk-cli/references/label.md +112 -0
  24. package/skills/linear-sdk-cli/references/milestone.md +139 -0
  25. package/skills/linear-sdk-cli/references/notification.md +123 -0
  26. package/skills/linear-sdk-cli/references/open.md +29 -0
  27. package/skills/linear-sdk-cli/references/organization.md +99 -0
  28. package/skills/linear-sdk-cli/references/project-update.md +67 -0
  29. package/skills/linear-sdk-cli/references/project.md +234 -0
  30. package/skills/linear-sdk-cli/references/roadmap.md +150 -0
  31. package/skills/linear-sdk-cli/references/schema.md +21 -0
  32. package/skills/linear-sdk-cli/references/state.md +61 -0
  33. package/skills/linear-sdk-cli/references/team.md +227 -0
  34. package/skills/linear-sdk-cli/references/user.md +103 -0
  35. package/skills/linear-sdk-cli/references/webhook.md +151 -0
  36. package/skills/linear-sdk-cli/references/whoami.md +26 -0
  37. package/skills/linear-sdk-cli/scripts/generate-docs.ts +339 -0
  38. package/src/bin/linear.ts +97 -0
  39. package/src/cli.ts +232 -0
  40. package/src/client.ts +172 -0
  41. package/src/commands/agent-session.ts +121 -0
  42. package/src/commands/api.ts +317 -0
  43. package/src/commands/attach.ts +90 -0
  44. package/src/commands/attachment.ts +74 -0
  45. package/src/commands/comment.ts +225 -0
  46. package/src/commands/completion.ts +69 -0
  47. package/src/commands/cycle.ts +125 -0
  48. package/src/commands/discover.ts +170 -0
  49. package/src/commands/document.ts +211 -0
  50. package/src/commands/favorite.ts +72 -0
  51. package/src/commands/initiative-update.ts +47 -0
  52. package/src/commands/initiative.ts +261 -0
  53. package/src/commands/issue.ts +1263 -0
  54. package/src/commands/label.ts +119 -0
  55. package/src/commands/meta.ts +534 -0
  56. package/src/commands/milestone.ts +163 -0
  57. package/src/commands/notification.ts +110 -0
  58. package/src/commands/open.ts +84 -0
  59. package/src/commands/organization.ts +79 -0
  60. package/src/commands/project-update.ts +47 -0
  61. package/src/commands/project.ts +339 -0
  62. package/src/commands/roadmap.ts +131 -0
  63. package/src/commands/state.ts +58 -0
  64. package/src/commands/team.ts +243 -0
  65. package/src/commands/user.ts +107 -0
  66. package/src/commands/webhook.ts +156 -0
  67. package/src/config.ts +1236 -0
  68. package/src/context.ts +117 -0
  69. package/src/git.ts +174 -0
  70. package/src/index.ts +10 -0
  71. package/src/lib/action.ts +26 -0
  72. package/src/lib/body.ts +172 -0
  73. package/src/lib/errors.ts +195 -0
  74. package/src/lib/introspect.ts +150 -0
  75. package/src/lib/keyring.ts +270 -0
  76. package/src/lib/mutation.ts +53 -0
  77. package/src/lib/open.ts +32 -0
  78. package/src/lib/options.ts +640 -0
  79. package/src/lib/output-shapes.ts +562 -0
  80. package/src/lib/pagination.ts +145 -0
  81. package/src/lib/prompt.ts +91 -0
  82. package/src/lib/resolve.ts +596 -0
  83. package/src/lib/shape.ts +273 -0
  84. package/src/lib/status-update.ts +91 -0
  85. package/src/lib/upload.ts +329 -0
  86. package/src/output/color.ts +52 -0
  87. package/src/output/format.ts +238 -0
  88. package/src/output/markdown.ts +133 -0
  89. package/src/output/pager.ts +131 -0
  90. package/src/output/sanitize.ts +76 -0
  91. package/src/output/table.ts +198 -0
  92. package/src/services/agent-session.ts +289 -0
  93. package/src/services/attachment.ts +198 -0
  94. package/src/services/comment.ts +262 -0
  95. package/src/services/cycle.ts +224 -0
  96. package/src/services/document.ts +357 -0
  97. package/src/services/favorite.ts +147 -0
  98. package/src/services/initiative-update.ts +59 -0
  99. package/src/services/initiative.ts +449 -0
  100. package/src/services/issue.ts +1153 -0
  101. package/src/services/label.ts +193 -0
  102. package/src/services/milestone.ts +262 -0
  103. package/src/services/notification.ts +190 -0
  104. package/src/services/organization.ts +144 -0
  105. package/src/services/project-update.ts +36 -0
  106. package/src/services/project.ts +494 -0
  107. package/src/services/roadmap.ts +177 -0
  108. package/src/services/state.ts +127 -0
  109. package/src/services/team.ts +386 -0
  110. package/src/services/user.ts +137 -0
  111. package/src/services/webhook.ts +203 -0
@@ -0,0 +1,534 @@
1
+ ---
2
+ name: linear-sdk-cli
3
+ description: Manage Linear from the command line and automate Linear workflows with the `linear` (alias `lin`) CLI. Use this whenever an agent needs to read or modify Linear issues, projects, cycles, initiatives, comments, labels, documents, or any other Linear resource — listing, viewing, creating, updating, deleting, or reaching the raw GraphQL API.
4
+ allowed-tools: Bash(linear:*), Bash(lin:*), Bash(curl:*)
5
+ ---
6
+
7
+ # Linear SDK CLI
8
+
9
+ `linear` (alias `lin`) is an ergonomic, agent-friendly command-line interface for
10
+ Linear, built on `@linear/sdk`. It is designed to be driven by scripts and agents:
11
+ every data command has a stable `--json` envelope, stable exit codes, file-based
12
+ body inputs, and machine-readable discovery commands. (`completion` is the one
13
+ exception — it always prints a shell script.)
14
+
15
+ ## Prerequisites
16
+
17
+ Check the CLI is installed:
18
+
19
+ ```bash
20
+ linear --version # or: lin --version — prints 0.x for this CLI
21
+ ```
22
+
23
+ If that fails, or prints `2.x` (that is `schpet/linear-cli`, a different tool that shares the
24
+ `linear` name), install this one — it needs Bun ≥ 1.1:
25
+
26
+ ```bash
27
+ git clone https://github.com/zhendalf/linear-sdk-cli.git
28
+ cd linear-sdk-cli && bun install
29
+ bun run dev -- --version
30
+ ```
31
+
32
+ The npm package has not been published yet; use a source clone until its first release.
33
+
34
+ `lin` is the safe spelling when both might be present. If the user is coming from
35
+ `schpet/linear-cli`, their credentials and `.linear.toml` are picked up automatically — see
36
+ `MIGRATING.md` in the package; do not ask them to re-enter an API key before running
37
+ `linear auth status`.
38
+
39
+ ### Authentication
40
+
41
+ The CLI needs a Linear API key. Three ways to provide one, in order of precedence:
42
+
43
+ 1. **`--api-key <key>`** flag (per invocation) or **`LINEAR_API_KEY`** env var — best
44
+ for CI and ephemeral agent runs:
45
+
46
+ ```bash
47
+ LINEAR_API_KEY=lin_api_... linear whoami --json
48
+ ```
49
+
50
+ 2. **Stored credentials** via `linear auth login` (validates the key and saves it):
51
+
52
+ ```bash
53
+ linear auth login --key lin_api_... # non-interactive
54
+ linear auth login # prompts for the key (interactive only)
55
+ ```
56
+
57
+ 3. **Multiple workspaces** — store several credentials and select one per call with
58
+ `--workspace <slug>`; set a default with `linear auth default <slug>`:
59
+
60
+ ```bash
61
+ linear auth list # show configured workspace credentials
62
+ linear auth default acme # make 'acme' the default
63
+ linear issue list --workspace acme --json
64
+ ```
65
+
66
+ Inspect resolution with `linear auth status`. Get the resolved key for scripting
67
+ (e.g. raw `curl`) with `linear auth token`.
68
+
69
+ ## Agent best practices
70
+
71
+ This CLI is built for non-interactive use. Follow these and it will never hang and
72
+ always emit parseable output.
73
+
74
+ ### Always pass `--json`
75
+
76
+ On every data command, **stdout carries only machine JSON** (status/progress notes go to
77
+ stderr), so it is always safe to pipe into `jq`. The envelope is a stable contract:
78
+
79
+ - **list** commands → a **bare array** `[...]` (even when empty `[]`, even for one result).
80
+ - **single-resource** commands (`view`, `whoami`, …) → a **bare object** `{...}`.
81
+ - **mutations** (`create`/`update`/`delete`/`archive`/…) → the affected object, e.g.
82
+ `{ "id": "...", "url": "..." }`, or `{ "id": "...", "success": true }` when the API
83
+ returns no body; destructive commands add a flag like `{ "deleted": true }` /
84
+ `{ "archived": true }`.
85
+ - **errors** → **stderr** as `{"error":{"message":"…","code":"…"}}`, never on stdout. With
86
+ `--debug` the extra detail rides _inside_ that object as `error.detail`, so `--json --debug`
87
+ stays parseable.
88
+
89
+ Relations are **objects with ids**, on list rows and on `view` alike — `state: {id,name,type}`,
90
+ `team: {id,key,name}`, `assignee: {id,displayName,email}`, `project`/`milestone: {id,name}`,
91
+ `cycle: {id,number,name}`, `parent: {id,identifier}`, `labels: [{id,name}]` — so `.state.name`
92
+ reads the same everywhere and the id you need to act on is already in hand. Issues also carry
93
+ `archivedAt` and `trashed`; a deleted issue still views, and says so.
94
+
95
+ ```bash
96
+ linear issue list --json | jq -r '.[].identifier'
97
+ linear issue view TES-42 --json | jq -r '.url'
98
+ linear issue view TES-42 --json | jq -r '.state.type, .team.key, .assignee.id'
99
+ ID=$(linear issue create --title "Fix" --team TES --json | jq -r '.id')
100
+ ```
101
+
102
+ ### Know the keys before you run anything
103
+
104
+ **Do not guess field names** (`comment list` rows carry `author`? No — `user`; `comment reply`
105
+ returns `parentId`? No — `parent`). Every command's `--json` shape is declared and testable, and
106
+ `linear commands <path>` prints it — the same text the per-command reference files carry:
107
+
108
+ ```bash
109
+ linear commands issue list # options, then "Output (--json): array of objects:" + one `key: type` per line
110
+ linear commands comment reply --json | jq '.output' # {"kind":"receipt","fields":{"id":"string","parent":"string","issue":"string|null","url":"string"}}
111
+ linear commands --json | jq -r '.[] | select(.output.kind=="list") | .path' # every command that prints an array
112
+ ```
113
+
114
+ `output` reads as:
115
+
116
+ - `kind` — `list` (bare array of `fields`-shaped rows), `object` (a `view`, `whoami`, …), `receipt`
117
+ (a mutation: ids plus what happened), `raw` (`api`, `schema`: keys depend on the request), `none`
118
+ (`completion` never prints JSON). A group that only holds subcommands has no `output`.
119
+ - `fields` — key → type. Scalars are `"string"`, `"number"`, `"boolean"` (`"string|null"` when the
120
+ value may be null); an object is nested `{…}`; an array is `[<type>]`; a relation that may be
121
+ null is `{"nullable": {…}}`; a key spelled `"comments?"` is present only sometimes (its `note`
122
+ or `variants` say when).
123
+ - `variants` — a different output under a flag or argument (`"--web"`, `"--start"`, `"op=list"`),
124
+ each a whole shape of its own.
125
+
126
+ The shapes cannot lie: each is checked against the TypeScript type the service returns at
127
+ compile time, and a test runs every command and compares what it printed to what it declared.
128
+
129
+ ### Fail fast, never prompt
130
+
131
+ - **`--no-input`** — never prompt. Anything that would be prompted for becomes a usage
132
+ error (exit `2`) instead of hanging. **`--json` already implies this**, as does a stdout
133
+ that is not a TTY, so an agent gets it for free; pass it anyway when you want the
134
+ intent on the record.
135
+ - **`-y, --yes`** — pre-confirm destructive actions (`delete`/`archive`). Without a TTY,
136
+ destructive commands _require_ `--yes` or they refuse rather than block. If a human
137
+ declines the prompt, the command exits `6` and prints `{"cancelled": true, "action": "…"}`
138
+ under `--json` — never `0`.
139
+ - **`-q, --quiet`** — suppress success/status lines on stderr (errors still print).
140
+
141
+ ```bash
142
+ # agent-safe: no prompts, no chatter, parseable error on failure
143
+ linear issue delete TES-42 --yes --no-input --quiet --json
144
+ ```
145
+
146
+ ### Branch on exit codes and error `code`s
147
+
148
+ Exit codes are stable and distinct:
149
+
150
+ | Exit | Meaning |
151
+ | ---: | ---------------------------------------------------------------- |
152
+ | `0` | ok |
153
+ | `1` | runtime/API failure (network, GraphQL, feature-not-accessible) |
154
+ | `2` | usage — bad flags/arguments, missing required input, validation |
155
+ | `3` | not-found / ambiguous (resource missing, or a name matched many) |
156
+ | `4` | auth — missing/invalid key or forbidden |
157
+ | `5` | rate-limited |
158
+ | `6` | cancelled — a confirmation prompt was declined; nothing changed |
159
+
160
+ The error envelope's `code` field is finer-grained — one of: `usage`, `auth`,
161
+ `not_found`, `ambiguous`, `forbidden`, `validation`, `rate_limited`, `network`,
162
+ `feature_not_accessible`, `api`, `runtime`. Several map to the same exit code (e.g.
163
+ `ambiguous` → `3`, `validation` → `2`, `forbidden` → `4`). Prefer `code` for precise
164
+ handling and the exit code for coarse branching:
165
+
166
+ ```bash
167
+ if ! out=$(linear issue view BAD-1 --json 2>err.json); then
168
+ code=$(jq -r '.error.code' err.json) # e.g. "not_found"
169
+ echo "failed: $code"
170
+ fi
171
+ ```
172
+
173
+ ### Prefer file-based body flags over inline markdown
174
+
175
+ For any markdown body — issue/initiative descriptions, comment bodies, document
176
+ content — **use the file flag, not the inline flag**. It avoids shell-escaping
177
+ headaches with newlines, quotes, and special characters, and keeps `\n` from leaking
178
+ into the rendered markdown. The file flags accept `-` to read **stdin**, which pairs
179
+ perfectly with a heredoc:
180
+
181
+ - `issue create` / `issue update` / `initiative create` / `initiative update` →
182
+ `--description-file <path>` (and `--description-file -` for stdin)
183
+ - `comment add` / `comment update` / `comment reply` → `--body-file <path>`
184
+ - `document create` / `document update` → `--content-file <path>`
185
+
186
+ ```bash
187
+ linear issue create --title "Onboarding bug" --team TES --no-input --json \
188
+ --description-file - <<'EOF'
189
+ ## Summary
190
+
191
+ The signup flow 500s when the email contains a `+`.
192
+
193
+ ## Steps
194
+ 1. Sign up as `a+b@example.com`
195
+ 2. Observe the error
196
+ EOF
197
+ ```
198
+
199
+ For short, single-line content, use inline `-d/--description` (issues/initiatives),
200
+ the positional `[body]` arg (comments: `linear comment add TES-42 "lgtm"`), or
201
+ `--body` (status updates). There is no `-b` short flag. The CLI rejects an inline
202
+ body containing literal `\n` sequences and points back to stdin; never encode a
203
+ multiline body by inserting `\n` inside an ordinary quoted argument.
204
+
205
+ ### Discovery — learn the surface without scraping help
206
+
207
+ Lead with these two machine-readable commands:
208
+
209
+ - **`linear commands --json`** — the full command tree as a bare array of
210
+ `{ path, description, aliases, arguments, options, output }`; `linear commands <path> --json`
211
+ is one command as a bare object. `output` is what that command prints under `--json` (see
212
+ "Know the keys before you run anything" above). Enumerate everything callable:
213
+
214
+ ```bash
215
+ linear commands --json | jq -r '.[].path' # every command path
216
+ linear commands issue create --json | jq '.options' # one command's flags
217
+ linear commands issue create --json | jq '.output.fields' # …and its --json keys
218
+ ```
219
+
220
+ - **`linear schema -o <file>`** — dump the Linear GraphQL schema as SDL to a file, then
221
+ grep it to find types/fields for `linear api`:
222
+
223
+ ```bash
224
+ linear schema -o "${TMPDIR:-/tmp}/linear.graphql"
225
+ grep -n 'type Issue ' "${TMPDIR:-/tmp}/linear.graphql"
226
+ ```
227
+
228
+ ## Available commands
229
+
230
+ Generated from `linear commands --json` (run `bun run skill:docs` to refresh):
231
+
232
+ <!-- BEGIN GENERATED COMMANDS -->
233
+
234
+ ```text
235
+ linear api
236
+
237
+ linear attachment
238
+ linear attachment create
239
+ linear attachment delete
240
+ linear attachment list
241
+
242
+ linear auth
243
+ linear auth adopt
244
+ linear auth default
245
+ linear auth list
246
+ linear auth login
247
+ linear auth logout
248
+ linear auth migrate
249
+ linear auth status
250
+ linear auth token
251
+ linear auth whoami
252
+
253
+ linear commands
254
+
255
+ linear comment
256
+ linear comment add
257
+ linear comment delete
258
+ linear comment list
259
+ linear comment reply
260
+ linear comment resolve
261
+ linear comment unresolve
262
+ linear comment update
263
+
264
+ linear completion
265
+
266
+ linear config
267
+ linear config init
268
+ linear config set
269
+ linear config show
270
+
271
+ linear cycle
272
+ linear cycle create
273
+ linear cycle current
274
+ linear cycle list
275
+ linear cycle update
276
+ linear cycle view
277
+
278
+ linear document
279
+ linear document create
280
+ linear document delete
281
+ linear document list
282
+ linear document update
283
+ linear document view
284
+
285
+ linear favorite
286
+ linear favorite add
287
+ linear favorite list
288
+ linear favorite remove
289
+
290
+ linear initiative
291
+ linear initiative add-project
292
+ linear initiative archive
293
+ linear initiative create
294
+ linear initiative delete
295
+ linear initiative list
296
+ linear initiative remove-project
297
+ linear initiative unarchive
298
+ linear initiative update
299
+ linear initiative view
300
+
301
+ linear initiative-update
302
+ linear initiative-update create
303
+ linear initiative-update list
304
+
305
+ linear issue
306
+ linear issue agent-session
307
+ linear issue agent-session list
308
+ linear issue agent-session view
309
+ linear issue archive
310
+ linear issue assign
311
+ linear issue attach
312
+ linear issue branch
313
+ linear issue comment
314
+ linear issue comment add
315
+ linear issue comment delete
316
+ linear issue comment list
317
+ linear issue comment update
318
+ linear issue comments
319
+ linear issue create
320
+ linear issue delete
321
+ linear issue describe
322
+ linear issue id
323
+ linear issue label
324
+ linear issue list
325
+ linear issue mine
326
+ linear issue pull-request
327
+ linear issue relation
328
+ linear issue search
329
+ linear issue start
330
+ linear issue state
331
+ linear issue subscribe
332
+ linear issue title
333
+ linear issue unarchive
334
+ linear issue unsubscribe
335
+ linear issue update
336
+ linear issue url
337
+ linear issue view
338
+
339
+ linear label
340
+ linear label create
341
+ linear label delete
342
+ linear label list
343
+ linear label update
344
+
345
+ linear milestone
346
+ linear milestone create
347
+ linear milestone delete
348
+ linear milestone list
349
+ linear milestone update
350
+ linear milestone view
351
+
352
+ linear notification
353
+ linear notification archive
354
+ linear notification list
355
+ linear notification read
356
+ linear notification read-all
357
+ linear notification snooze
358
+ linear notification unread
359
+
360
+ linear open
361
+
362
+ linear organization
363
+ linear organization invites
364
+ linear organization members
365
+ linear organization view
366
+
367
+ linear project
368
+ linear project archive
369
+ linear project create
370
+ linear project delete
371
+ linear project list
372
+ linear project milestones
373
+ linear project update
374
+ linear project view
375
+
376
+ linear project-update
377
+ linear project-update create
378
+ linear project-update list
379
+
380
+ linear roadmap
381
+ linear roadmap create
382
+ linear roadmap delete
383
+ linear roadmap list
384
+ linear roadmap update
385
+ linear roadmap view
386
+
387
+ linear schema
388
+
389
+ linear state
390
+ linear state list
391
+ linear state view
392
+
393
+ linear team
394
+ linear team create
395
+ linear team cycles
396
+ linear team delete
397
+ linear team id
398
+ linear team labels
399
+ linear team list
400
+ linear team members
401
+ linear team states
402
+ linear team update
403
+ linear team view
404
+
405
+ linear user
406
+ linear user list
407
+ linear user me
408
+ linear user view
409
+
410
+ linear webhook
411
+ linear webhook create
412
+ linear webhook delete
413
+ linear webhook list
414
+ linear webhook update
415
+ linear webhook view
416
+
417
+ linear whoami
418
+ ```
419
+
420
+ <!-- END GENERATED COMMANDS -->
421
+
422
+ ## Reference documentation
423
+
424
+ One file per command group, generated from `linear commands --json`: every command's options
425
+ and, under **Output (`--json`)**, the exact keys and types it prints (`linear commands <path>`
426
+ prints the same). These are supplementary — `--help` on any command is authoritative.
427
+
428
+ - [api](references/api.md) — Run a raw GraphQL query or mutation against the Linear API
429
+ - [attachment](references/attachment.md) — Work with issue attachments
430
+ - [auth](references/auth.md) — Manage authentication
431
+ - [commands](references/commands.md) — Machine-readable command tree (for scripts/agents)
432
+ - [comment](references/comment.md) — Manage comments
433
+ - [completion](references/completion.md) — Output a shell completion script
434
+ - [config](references/config.md) — Show the resolved configuration (secrets redacted)
435
+ - [cycle](references/cycle.md) — Work with cycles
436
+ - [document](references/document.md) — Work with documents
437
+ - [favorite](references/favorite.md) — Manage your favorites
438
+ - [initiative](references/initiative.md) — Work with initiatives
439
+ - [initiative-update](references/initiative-update.md) — Post and list initiative status updates
440
+ - [issue](references/issue.md) — Work with issues
441
+ - [label](references/label.md) — Work with issue labels
442
+ - [milestone](references/milestone.md) — Work with project milestones
443
+ - [notification](references/notification.md) — Work with your notifications
444
+ - [open](references/open.md) — Open the workspace, an issue, team, project, or URL
445
+ - [organization](references/organization.md) — Inspect the current workspace
446
+ - [project](references/project.md) — Work with projects
447
+ - [project-update](references/project-update.md) — Post and list project status updates
448
+ - [roadmap](references/roadmap.md) — Work with roadmaps
449
+ - [schema](references/schema.md) — Print the Linear GraphQL schema as SDL
450
+ - [state](references/state.md) — Inspect workflow states
451
+ - [team](references/team.md) — Inspect and manage teams
452
+ - [user](references/user.md) — Inspect workspace users
453
+ - [webhook](references/webhook.md) — Manage workspace webhooks
454
+ - [whoami](references/whoami.md) — Show the authenticated user
455
+
456
+ ## Discovering options
457
+
458
+ `--help` on any command lists its flags; `linear commands --json` gives the same as
459
+ data:
460
+
461
+ ```bash
462
+ linear --help
463
+ linear issue --help
464
+ linear issue create --help
465
+ linear commands --json | jq '.[] | select(.path=="issue list")'
466
+ ```
467
+
468
+ Useful surface notes (all verified against the current CLI):
469
+
470
+ - `issue describe [id]` prints a commit message (`ID Title`, then `Linear-issue: Fixes ID` /
471
+ `Linear-issue-url:` trailers); `issue pull-request` (alias `pr`) creates a GitHub PR titled
472
+ `ID Title` with those trailers as the body. `issue start` checks the branch out AND moves the
473
+ issue to the first `started` state (`--no-move` for branch only); `issue branch` prints the name.
474
+ - `--fields`, `--limit`, `--all` are refused (usage error) on commands that print only a receipt
475
+ — every mutation, `issue id`, `commands`, … — so `-f <file>` cannot be swallowed silently.
476
+ - `cycle create`/`cycle update` use `--start <date>` and `--end <date>` (ISO); `cycle current`
477
+ resolves the active cycle. Issue commands take `--cycle <n|id|current>`.
478
+ - `initiative create`/`update` use `--target <date>` for the estimated completion date,
479
+ plus `--owner` and `--status`.
480
+ - `label create` adds `--shared` to create a workspace-level (shared) label even when a
481
+ default team is set, and `--parent <name>` for sub-labels.
482
+ - `project-update` (alias `pu`) and `initiative-update` (alias `iu`) post and list status
483
+ updates.
484
+
485
+ ## Raw GraphQL API
486
+
487
+ When a curated command doesn't cover what you need, drop to raw GraphQL with
488
+ `linear api`. Inspect the schema first (`linear schema -o file`) to find types/fields.
489
+
490
+ **Pass queries containing non-null type markers (a type followed by `!`) via heredoc
491
+ stdin, not inline** — this avoids shell history-expansion and quoting issues with `!`.
492
+ Simple queries without `!` are fine inline.
493
+
494
+ ```bash
495
+ # Simple query — inline is fine (no `!`)
496
+ linear api '{ viewer { id name email } }'
497
+
498
+ # Query with variables — heredoc + --query-file - (reads the query from stdin)
499
+ linear api --query-file - --var id=TES-1 <<'GRAPHQL'
500
+ query($id: String!) { issue(id: $id) { identifier title state { name } } }
501
+ GRAPHQL
502
+
503
+ # Multiple string variables (repeat --var k=v)
504
+ linear api --query-file - --var term=onboarding --var n=20 <<'GRAPHQL'
505
+ query($term: String!) { searchIssues(term: $term) { nodes { identifier title } } }
506
+ GRAPHQL
507
+
508
+ # Complex / typed variables via JSON (inline or from a file with --vars-file)
509
+ linear api --query-file - --vars '{"filter":{"state":{"name":{"eq":"In Progress"}}}}' <<'GRAPHQL'
510
+ query($filter: IssueFilter!) { issues(filter: $filter) { nodes { identifier title } } }
511
+ GRAPHQL
512
+
513
+ # Auto-follow pagination on the first connection
514
+ linear api --query-file q.graphql --vars-file vars.json --paginate
515
+
516
+ # Pipe data straight to jq (status notes go to stderr)
517
+ linear api '{ issues(first: 5) { nodes { identifier title } } }' | jq '.data.issues.nodes[].title'
518
+ ```
519
+
520
+ `api` flags: `--query-file <path>` (`-` = stdin), `--var <k=v>` (repeatable string
521
+ vars), `--vars <json>`, `--vars-file <path>` (`-` = stdin), `--operation <name>`,
522
+ `--paginate`, `--raw` (full response incl. extensions), `--json`.
523
+
524
+ ### Raw `curl` fallback
525
+
526
+ For full HTTP control, get the resolved key with `linear auth token` (Linear expects
527
+ the raw key in the `Authorization` header — no `Bearer` prefix):
528
+
529
+ ```bash
530
+ curl -s -X POST https://api.linear.app/graphql \
531
+ -H "Content-Type: application/json" \
532
+ -H "Authorization: $(linear auth token)" \
533
+ -d '{"query": "{ viewer { id } }"}'
534
+ ```
@@ -0,0 +1,27 @@
1
+ # linear api
2
+
3
+ > Run a raw GraphQL query or mutation against the Linear API
4
+
5
+ _Generated from `linear commands --json`. `linear api --help` (or `<subcommand> --help`) is authoritative._
6
+
7
+ Every command also accepts the global flags `-j/--json`, `--no-input`, `-y/--yes`, `-q/--quiet`, `--workspace <slug>`, `--api-key <key>`, `-t/--team <key>`, `-n/--limit <n>`, `--all`, `-f/--fields <a,b,c>`, `--no-ansi` (alias `--no-color`), and `--debug`. Only command-specific options are listed below.
8
+
9
+ ### `linear api`
10
+
11
+ Run a raw GraphQL query or mutation against the Linear API
12
+
13
+ ```
14
+ linear api [options] [query]
15
+ ```
16
+
17
+ | Option | Description |
18
+ | --------------------- | ------------------------------------------------------------------------------ |
19
+ | `--query-file <path>` | read the query from a file ('-' for stdin) |
20
+ | `--var <k=v...>` | set a variable (repeatable; JSON literals are typed, other values are strings) |
21
+ | `--vars <json>` | variables as a JSON object |
22
+ | `--vars-file <path>` | read variables from a JSON file ('-' for stdin) |
23
+ | `--operation <name>` | run this operation of a multi-operation document |
24
+ | `--paginate` | auto-follow the first connection's pageInfo cursor (queries only) |
25
+ | `--raw` | print the full GraphQL response (data + extensions) |
26
+
27
+ **Output (`--json`)**: raw JSON (keys depend on the request) — the response `data` as the API returned it (`--raw`: {data, extensions}); `--paginate` prints one array of every page's nodes
@@ -0,0 +1,82 @@
1
+ # linear attachment
2
+
3
+ > Work with issue attachments
4
+
5
+ Group alias: `at`
6
+
7
+ _Generated from `linear commands --json`. `linear attachment --help` (or `<subcommand> --help`) is authoritative._
8
+
9
+ Every command also accepts the global flags `-j/--json`, `--no-input`, `-y/--yes`, `-q/--quiet`, `--workspace <slug>`, `--api-key <key>`, `-t/--team <key>`, `-n/--limit <n>`, `--all`, `-f/--fields <a,b,c>`, `--no-ansi` (alias `--no-color`), and `--debug`. Only command-specific options are listed below.
10
+
11
+ ### `linear attachment`
12
+
13
+ Work with issue attachments
14
+
15
+ Aliases: `at`
16
+
17
+ ```
18
+ linear attachment [options]
19
+ ```
20
+
21
+ ### `linear attachment create`
22
+
23
+ Attach a URL to an issue
24
+
25
+ Aliases: `new`
26
+
27
+ ```
28
+ linear attachment create [options] <issue>
29
+ ```
30
+
31
+ | Option | Description |
32
+ | ------------------- | ------------------- |
33
+ | `--url <url>` | the URL to attach |
34
+ | `--title <title>` | attachment title |
35
+ | `--subtitle <text>` | attachment subtitle |
36
+
37
+ **Output (`--json`)**: a receipt object
38
+
39
+ ```text
40
+ id: string
41
+ title: string
42
+ url: string
43
+ ```
44
+
45
+ ### `linear attachment delete`
46
+
47
+ Delete an attachment by id
48
+
49
+ Aliases: `rm`
50
+
51
+ ```
52
+ linear attachment delete [options] <id>
53
+ ```
54
+
55
+ **Output (`--json`)**: a receipt object
56
+
57
+ ```text
58
+ id: string
59
+ title: string
60
+ deleted: boolean
61
+ ```
62
+
63
+ ### `linear attachment list`
64
+
65
+ List the attachments on an issue
66
+
67
+ Aliases: `ls`
68
+
69
+ ```
70
+ linear attachment list [options] <issue>
71
+ ```
72
+
73
+ **Output (`--json`)**: a bare array of objects
74
+
75
+ ```text
76
+ id: string
77
+ title: string
78
+ subtitle: string | null
79
+ url: string
80
+ source: string | null
81
+ createdAt: string
82
+ ```