使用 linear-cli 代理原生运行时从 Claude Code、Codex 或其他代理读取和变更 Linear。适用于需要默认 JSON 输出的场景。
线性 CLI. 当前 v3 执行模式的代理- 本地线性运行时间, 具有稳定的 JSON 合同, 启动发现, 干运行预览, 超时- 知乎写语义, 源码相邻 i是一项面向实际任务的技能。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。
执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
面向智能体(agent)原生设计的 Linear 运行时,适配当前 v3 执行模型,具备稳定的 JSON 接口契约、启动时能力发现(startup discovery)、预览式执行(dry-run previews)、超时感知的写入语义(timeout-aware write semantics)、源文件邻近式内容摄入(source-adjacent intake),以及对 git / jj 工作流的深度集成。
在智能体运行时中调用本 CLI 时,请优先遵循以下顺序:
linear capabilities 发现命令能力特征;仅当旧版调用方仍依赖裁剪后的遗留接口形状时,才使用 --compat v1--json 读取 Linear 状态--dry-run --json 预览写入操作operation、receipt 和 error.details 字段error.details 判断结果,而非解析带样式的终端文本输出由提示驱动的人工交互或调试流程属于次要路径,且需显式启用。当某命令支持交互式提示(prompt)或编辑器输入时,请传入 --profile human-debug --interactive;否则,缺失必需输入将立即失败(fail fast)。
智能体安全的执行语义现已作为默认运行时行为。--text 与 --profile human-debug 是为维护者保留的显式人工/调试逃逸通道(escape hatches),而 --profile agent-safe 仍被接受,以兼容旧版自动化脚本。
当上游工具向运行时传递已归一化的 Slack 消息、工单(ticket)或其他类似来源信封(source envelope)时,优先使用 --context-file;若该信封已包含确定性的团队/状态/标签等提示信息,则额外添加 --apply-triage;当封装层(wrapper)需要“仅建议”(suggest-only)或“必须预览”(preview-required)的阶段性策略时,请显式指定 --autonomy-policy。
推荐参考文档:
linear 命令须已加入系统 PATH。验证方式如下:
linear --version
如未安装,请参照以下地址的说明进行安装:
https://github.com/kyaukyuai/linear-cli?tab=readme-ov-file#install
在处理含 Markdown 格式的工单描述(issue description)或评论正文(comment body)时,对已有磁盘文件优先使用基于文件的参数标志,对流水线动态生成的内容则优先使用标准输入(stdin):
issue create 与 issue update 命令中使用 --description-filecomment add 与 comment update 命令中使用 --body-filecat description.md | linear issue create --title "My Issue" --team ENG为何避免使用大型内联参数(inline flags):
n 序列意外出现在 Markdown 文本中示例工作流:
# 将 Markdown 写入临时文件 cat > /tmp/description.md <<'EOF' ## Summary - First item - Second item ## Details This is a detailed description with proper formatting. EOF # 使用该文件创建工单 linear issue create --title "My Issue" --description-file /tmp/description.md # 或直接管道传输生成的 Markdown cat /tmp/description.md | linear issue create --title "My Issue" --team ENG # 或用于评论 linear issue comment add ENG-123 --body-file /tmp/comment.md
仅对简单、单行内容 使用内联参数(--description、--body)。
linear auth # 管理 Linear 认证 linear issue # 管理 Linear 工单 linear team # 管理 Linear 团队 linear project # 管理 Linear 项目 linear project-update # 管理项目状态更新 linear cycle # 管理 Linear 团队周期 linear milestone # 管理 Linear 项目里程碑 linear initiative # 管理 Linear 主题(initiatives) linear initiative-update # 管理主题状态更新(时间线帖子) linear label # 管理 Linear 工单标签 linear document # 管理 Linear 文档 linear notification # 管理 Linear 通知 linear webhook # 管理 Linear Webhook linear workflow-state # 管理 Linear 工作流状态 linear user # 管理 Linear 用户 linear project-label # 管理 Linear 项目标签 linear config # 交互式生成 .linear.toml 配置文件 linear schema # 将 GraphQL Schema 输出至 stdout linear api # 发起原始 GraphQL API 请求 linear capabilities # 描述面向智能体的命令接口表面(command surface) linear resolve # 解析引用(references)而不修改 Linear 数据
如需查看组织级功能(如 initiatives、labels、projects、批量操作等)的精选示例,请参阅 organization-features。
要查看任意命令支持的子命令与参数标志,请在其后追加 --help:
linear --help linear issue --help linear issue list --help linear issue create --help
每个命令均提供详尽的帮助输出,完整列出所有可用标志与选项。
如需机器可读的能力发现方式,请优先使用:
linear capabilities linear capabilities --compat v1
所有受支持的操作请优先使用 CLI。api 命令仅应在 CLI 未覆盖的查询场景下作为备用方案使用。
将 Schema 写入临时文件后进行搜索:
linear schema -o "${TMPDIR:-/tmp}/linear-schema.graphql"
grep -i "cycle" "${TMPDIR:-/tmp}/linear-schema.graphql"
grep -A 30 "^type Issue " "${TMPDIR:-/tmp}/linear-schema.graphql"
重要提示: 包含非空类型标记(non-null type markers,例如后跟感叹号的 String!)的 GraphQL 查询,必须通过 heredoc 方式经 stdin 传入,以避免 Shell 转义问题;不含此类标记的简单查询可直接以内联方式传入。
# 简单查询(无类型标记,内联方式即可)
linear api '{ viewer { id name email } }'
# 含变量的查询 — 使用 heredoc 避免转义问题
linear api --variable teamId=abc123 <<'GRAPHQL'
query($teamId: String!) { team(id: $teamId) { name } }
GRAPHQL
# 按文本搜索工单
linear api --variable term=onboarding <<'GRAPHQL'
query($term: String!) { searchIssues(term: $term, first: 20) { nodes { identifier title state { name } } } }
GRAPHQL
# 数值型与布尔型变量
linear api --variable first=5 <<'GRAPHQL'
query($first: Int!) { issues(first: $first) { nodes { title } } }
GRAPHQL
# 通过 JSON 传入复杂变量
linear api --variables-json '{"filter": {"state": {"name": {"eq": "In Progress"}}}}' <<'GRAPHQL'
query($filter: IssueFilter!) { issues(filter: $filter) { nodes { title } } }
GRAPHQL
# 管道至 jq 进行过滤
linear api '{ issues(first: 5) { nodes { identifier title } } }' | jq '.data.issues.nodes[].title'
当需要完全控制 HTTP 请求细节时,可结合 linear auth token 使用 curl:
curl -s -X POST https://api.linear.app/graphql
-H "Content-Type: application/json"
-H "Authorization: $(linear auth token)"
-d '{"query": "{ viewer { id } }"}'
相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 134.3万人学习
共49课时 | 82.7万人学习
最新文章