介绍
# Linear
管理问题、检查项目状态,并掌握团队的最新工作动态。
## 设置
```bash export LINEAR_API_KEY="your-api-key" # Optional: default team key used when a command needs a team export LINEAR_DEFAULT_TEAM="TEAM" ```
发现团队密钥:
```bash {baseDir}/scripts/linear.sh teams ```
如果设置了 `LINEAR_DEFAULT_TEAM`,则可以在 `team` 中省略团队密钥并调用:
```bash {baseDir}/scripts/linear.sh create "Title" ["Description"] ```
## 快捷命令
```bash # My stuff {baseDir}/scripts/linear.sh my-issues # Your assigned issues {baseDir}/scripts/linear.sh my-todos # Just your Todo items {baseDir}/scripts/linear.sh urgent # Urgent/High priority across team
# Browse {baseDir}/scripts/linear.sh teams # List available teams {baseDir}/scripts/linear.sh team <TEAM_KEY> # All issues for a team {baseDir}/scripts/linear.sh project <name> # Issues in a project {baseDir}/scripts/linear.sh issue <TEAM-123> # Get issue details {baseDir}/scripts/linear.sh branch <TEAM-123> # Get branch name for GitHub
# Actions {baseDir}/scripts/linear.sh create <TEAM_KEY> "Title" ["Description"] {baseDir}/scripts/linear.sh comment <TEAM-123> "Comment text" {baseDir}/scripts/linear.sh status <TEAM-123> <todo|progress|review|done|blocked> {baseDir}/scripts/linear.sh assign <TEAM-123> <userName> {baseDir}/scripts/linear.sh priority <TEAM-123> <urgent|high|medium|low|none>
# Overview {baseDir}/scripts/linear.sh standup # Daily standup summary {baseDir}/scripts/linear.sh projects # All projects with progress ```
## 常用工作流
### 晨会站会 ```bash {baseDir}/scripts/linear.sh standup ``` 显示内容:你的待办事项、全团队的阻塞项、最近完成的项目、正在审查的项目。
### 快速创建问题(通过聊天) ```bash {baseDir}/scripts/linear.sh create TEAM "Fix auth timeout bug" "Users getting logged out after 5 min" ```
### 分类模式 ```bash {baseDir}/scripts/linear.sh urgent # See what needs attention ```
## Git 工作流(Linear ↔ GitHub 集成)
**请始终使用 Linear 生成的分支名称**,以启用自动问题状态跟踪。
### 获取分支名称 ```bash {baseDir}/scripts/linear.sh branch TEAM-212 # Returns: dev/team-212-fix-auth-timeout-bug ```
### 为问题创建工作树 ```bash # 1. Get the branch name from Linear BRANCH=$({baseDir}/scripts/linear.sh branch TEAM-212)
# 2. Pull fresh main first (main should ALWAYS match origin) cd /path/to/repo git checkout main && git pull origin main
# 3. Create worktree with that branch (branching from fresh origin/main) git worktree add .worktrees/team-212 -b "$BRANCH" origin/main cd .worktrees/team-212
# 4. Do your work, commit, push git push -u origin "$BRANCH" ```
**⚠️ 永远不要修改 main 上的文件。** 所有更改仅在工作树中进行。
### 这一点的重要性 - Linear 的 GitHub 集成通过分支名称模式跟踪 PR - 当你从 Linear 分支创建 PR 时,该问题会**自动移动到“In Review”状态** - 当 PR 合并时,该问题会**自动移动到“Done”状态** - 手动命名分支会破坏这种自动化 - 保持 main 干净 = 避免意外推送,易于清理工作树
### 快速参考 ```bash # Full workflow example ISSUE="TEAM-212" BRANCH=$({baseDir}/scripts/linear.sh branch $ISSUE)
# Always start from fresh main cd ~/workspace/your-repo git checkout main && git pull origin main
# Create worktree (inside .worktrees/) git worktree add .worktrees/${ISSUE,,} -b "$BRANCH" origin/main cd .worktrees/${ISSUE,,}
# ... make changes ... git add -A && git commit -m "fix: implement $ISSUE" git push -u origin "$BRANCH" gh pr create --title "$ISSUE: <title>" --body "Closes $ISSUE" ```
## 优先级
| 级别 | 值 | 用于 | |-------|-------|---------| | urgent | 1 | 生产问题、阻塞项 | | high | 2 | 本周、重要 | | medium | 3 | 本冲刺/周期 | | low | 4 | 锦上添花 | | none | 0 | 待办列表、将来 |
## 团队(缓存)
团队密钥和 ID 通过 API 发现,并在首次查询后缓存在本地。 使用 `linear.sh teams` 刷新并列出可用团队。
## 备注
- 使用 GraphQL API (api.linear.app/graphql) - 需要设置 `LINEAR_API_KEY` 环境变量 - 问题标识符格式为 `TEAM-123`
## 致谢
灵感来源于 Peter Schilling (ISC License) 的 [schpet/linear-cli](https://github.com/schpet/linear-cli)。 这是一个专为 Clawdbot 集成而编写的独立 Bash 实现。