Linear GraphQL Skill
Use this skill to run Linear GraphQL API operations through uxc.
Reuse the uxc skill guidance for discovery, schema inspection, auth lifecycle, and error recovery.
Prerequisites
- -
uxc is installed and available in PATH. - Network access to
https://api.linear.app/graphql. - Linear API key or OAuth credentials available.
Authentication
Linear supports two authentication methods:
Option 1: Personal API Key (Recommended for development)
- 1. Get your API key from Linear: https://linear.app/settings/api
- 2. Set credential with custom Authorization header:
CODEBLOCK0
Or use environment variable:
CODEBLOCK1
- 3. Bind endpoint:
CODEBLOCK2
Important (Personal API Key only): Linear API keys require Authorization: lin_api_XXX format (no Bearer prefix). The --header "Authorization:{{secret}}" configuration above is required for API key auth. For OAuth access tokens, use standard Authorization: Bearer <token> semantics (handled by the OAuth credential flow in uxc).
Credential/binding IDs in this skill use linear-graphql by convention; IDs are local aliases and can be changed if needed.
Option 2: OAuth 2.0 (For production/user-delegated access)
- 1. Create an OAuth app in Linear: https://linear.app/settings/api
- 2. Start OAuth login:
CODEBLOCK3
After approval, complete it with:
CODEBLOCK4
- 3. Bind endpoint:
CODEBLOCK5
Core Workflow
- 1. Use fixed link command by default:
-
command -v linear-graphql-cli
- If the command exists, confirm it is the expected
uxc link for this skill before using it.
- If a command conflict is detected and cannot be safely reused, stop and ask skill maintainers for guidance instead of dynamically renaming the command.
- If missing, create it:
uxc link linear-graphql-cli https://api.linear.app/graphql
- INLINECODE14
- 2. Discover operations:
-
linear-graphql-cli -h
- Returns hundreds of GraphQL operations
- 3. Inspect specific operation:
-
linear-graphql-cli query/issues -h
- INLINECODE17
- 4. Execute queries:
CODEBLOCK6
Available Operations
Queries
- -
query/issues - List and filter issues - INLINECODE19 - Get single issue
- INLINECODE20 - List teams
- INLINECODE21 - Get single team
- INLINECODE22 - List projects
- INLINECODE23 - List workflow states
Mutations
- -
mutation/issueCreate - Create new issue - INLINECODE25 - Update issue
- INLINECODE26 - Archive issue
- INLINECODE27 - Add comment
Usage Examples
List recent issues
CODEBLOCK7
Get issue by ID
CODEBLOCK8
List teams
CODEBLOCK9
Create issue
CODEBLOCK10
Troubleshooting
Authentication Errors
Error: "Bearer token" prefix rejected
- - Linear API does not accept INLINECODE28
- Ensure credential uses INLINECODE29
- Do not use INLINECODE30
Error: "Credential not found"
- - Check credential exists: INLINECODE31
- Verify binding: INLINECODE32
- Create binding if missing (see Authentication section)
OAuth login spans multiple agent turns
- - Prefer
uxc auth oauth start ... and INLINECODE34 - Use
uxc auth oauth login ... --flow authorization_code only when one process can wait for the pasted callback URL
Error: "No binding matched"
- - Check binding exists: INLINECODE36
- If missing, create binding with
uxc auth binding add (see Authentication section)
For detailed authentication troubleshooting, see uxc skill's references/auth-configuration.md.
Common Issues
Daemon issues after credential changes
- - Restart daemon: INLINECODE40
- Check status: INLINECODE41
Environment variable not found
- - Ensure variable is exported in daemon's environment
- Or use
--secret for literal values (less secure) - Or use
--secret-op for 1Password (most secure)
Guardrails
- - Keep automation on JSON output envelope; do not use
--text. - Parse stable fields first:
ok, kind, data, error. - Prefer positional JSON for non-string and typed arguments (for example:
linear-graphql-cli query/issues '{"first":10}' and linear-graphql-cli mutation/issueCreate '{"input":{"teamId":"TEAM_ID","title":"Test"}}'). - Use reserved GraphQL argument
_select (string) when you need explicit return fields, e.g. {"_select":"nodes { identifier title }"}. - Use
linear-graphql-cli as the default command path. - INLINECODE54 is equivalent to
uxc https://api.linear.app/graphql <operation> .... - Prefer read operations first (query/), then write operations (mutation/).
- For write operations, always confirm user intent before execution.
- If auth fails, check credential with
uxc auth credential info linear-graphql.
References
- - Linear API Documentation: https://developers.linear.app
- GraphQL Schema: https://studio.apollographql.com/public/Linear-API
- Invocation patterns: INLINECODE57
Linear GraphQL 技能
使用此技能通过 uxc 运行 Linear GraphQL API 操作。
复用 uxc 技能指南进行发现、模式检查、认证生命周期和错误恢复。
前提条件
- - uxc 已安装并位于 PATH 中。
- 可访问 https://api.linear.app/graphql 网络。
- 拥有 Linear API 密钥或 OAuth 凭据。
认证
Linear 支持两种认证方式:
方式一:个人 API 密钥(推荐用于开发)
- 1. 从 Linear 获取 API 密钥:https://linear.app/settings/api
- 2. 使用自定义 Authorization 标头设置凭据:
bash
uxc auth credential set linear-graphql \
--auth-type api_key \
--header Authorization:{{secret}} \
--secret lin
apiXXX
或使用环境变量:
bash
export LINEARAPIKEY=linapiXXX
uxc auth credential set linear-graphql \
--auth-type api_key \
--header Authorization:{{secret}} \
--secret-env LINEARAPIKEY
- 3. 绑定端点:
bash
uxc auth binding add \
--id linear-graphql \
--host api.linear.app \
--path-prefix /graphql \
--scheme https \
--credential linear-graphql \
--priority 100
重要提示(仅限个人 API 密钥): Linear API 密钥需要 Authorization: linapiXXX 格式(无 Bearer 前缀)。上述 --header Authorization:{{secret}} 配置是 API 密钥认证所必需的。对于 OAuth 访问令牌,请使用标准的 Authorization: Bearer 语义(由 uxc 中的 OAuth 凭据流程处理)。
此技能中的凭据/绑定 ID 按惯例使用 linear-graphql;ID 是本地别名,可根据需要更改。
方式二:OAuth 2.0(用于生产环境/用户委托访问)
- 1. 在 Linear 中创建 OAuth 应用:https://linear.app/settings/api
- 2. 启动 OAuth 登录:
bash
uxc auth oauth start linear-graphql \
--endpoint https://api.linear.app/graphql \
--redirect-uri http://127.0.0.1:8788/callback \
--scope read \
--scope write
批准后,使用以下命令完成:
bash
uxc auth oauth complete linear-graphql \
--session-id \
--authorization-response http://127.0.0.1:8788/callback?code=...&state=...
- 3. 绑定端点:
bash
uxc auth binding add \
--id linear-graphql \
--host api.linear.app \
--path-prefix /graphql \
--scheme https \
--credential linear-graphql \
--priority 100
核心工作流程
- 1. 默认使用固定链接命令:
- command -v linear-graphql-cli
- 如果命令存在,在使用前确认它是此技能预期的 uxc link。
- 如果检测到命令冲突且无法安全复用,请停止并向技能维护者寻求指导,而不是动态重命名命令。
- 如果缺失,创建它:uxc link linear-graphql-cli https://api.linear.app/graphql
- linear-graphql-cli -h
- 2. 发现操作:
- linear-graphql-cli -h
- 返回数百个 GraphQL 操作
- 3. 检查特定操作:
- linear-graphql-cli query/issues -h
- linear-graphql-cli mutation/issueCreate -h
- 4. 执行查询:
bash
# 查询问题(简单)
linear-graphql-cli query/issues {first:10}
# 使用显式选择集查询有用字段的问题
linear-graphql-cli query/issues {first:10,_select:nodes { identifier title url state { name } assignee { name } }}
# 查询团队
linear-graphql-cli query/teams {first:10}
# 创建问题(需要写入权限)
linear-graphql-cli mutation/issueCreate {
input: {
teamId: TEAM_ID,
title: 新问题标题,
description: 问题描述
}
}
可用操作
查询
- - query/issues - 列出和筛选问题
- query/issue - 获取单个问题
- query/teams - 列出团队
- query/team - 获取单个团队
- query/projects - 列出项目
- query/workflowStates - 列出工作流状态
变更
- - mutation/issueCreate - 创建新问题
- mutation/issueUpdate - 更新问题
- mutation/issueArchive - 归档问题
- mutation/commentCreate - 添加评论
使用示例
列出最近问题
bash
linear-graphql-cli query/issues {first:20,_select:nodes { identifier title url state { name } assignee { name } }}
按 ID 获取问题
bash
linear-graphql-cli query/issue id=ISSUE_ID
列出团队
bash
linear-graphql-cli query/teams
创建问题
bash
linear-graphql-cli mutation/issueCreate {input:{teamId:YOUR
TEAMID,title:修复错误}}
故障排除
认证错误
错误:Bearer token 前缀被拒绝
- - Linear API 不接受 Authorization: Bearer linapiXXX
- 确保凭据使用 --auth-type api_key --header Authorization:{{secret}}
- 不要使用 --auth-type bearer
错误:凭据未找到
- - 检查凭据是否存在:uxc auth credential list
- 验证绑定:uxc auth binding list
- 如果缺少绑定,请创建(参见认证部分)
OAuth 登录跨越多个代理轮次
- - 优先使用 uxc auth oauth start ... 和 uxc auth oauth complete ...
- 仅当单个进程可以等待粘贴的回调 URL 时,才使用 uxc auth oauth login ... --flow authorization_code
错误:未匹配到绑定
- - 检查绑定是否存在:uxc auth binding match api.linear.app/graphql
- 如果缺少,使用 uxc auth binding add 创建绑定(参见认证部分)
有关详细的认证故障排除,请参阅 uxc 技能的 references/auth-configuration.md。
常见问题
凭据更改后的守护进程问题
- - 重启守护进程:uxc daemon restart
- 检查状态:uxc daemon status
未找到环境变量
- - 确保变量已在守护进程的环境中导出
- 或使用 --secret 传递字面值(安全性较低)
- 或使用 --secret-op 从 1Password 获取(最安全)
安全护栏
- - 保持自动化使用 JSON 输出格式;不要使用 --text。
- 首先解析稳定字段:ok、kind、data、error。
- 对于非字符串和类型化参数,优先使用位置 JSON(例如:linear-graphql-cli query/issues {first:10} 和 linear-graphql-cli mutation/issueCreate {input:{teamId:TEAMID,title:Test}})。
- 当需要显式返回字段时,使用保留的 GraphQL 参数 select(字符串),例如 {_select:nodes { identifier title }}。
- 使用 linear-graphql-cli 作为默认命令路径。
- linear-graphql-cli ... 等同于 uxc https://api.linear.app/graphql ...。
- 优先执行读取操作(query/),然后执行写入操作(mutation/)。
- 对于写入操作,始终在执行前确认用户意图。
- 如果认证失败,使用 uxc auth credential info linear-graphql 检查凭据。
参考
- - Linear API 文档:https://developers.linear.app
- GraphQL 模式:https://studio.apollographql.com/public/Linear-API
- 调用模式:references/usage-patterns.md