Linear Git Autopilot
Goal
Run a fully automated workflow from a Linear initiative + project to completed PRs, using:
- Linear MCP for task discovery and status updates
- Git for branching/commits
gh for PR creation
Default behavior: proceed without asking questions unless blocked by missing access, missing required tools, or ambiguous project/initiative matching.
Prerequisites (assume true; stop only if missing)
- Linear MCP server
linear enabled and authenticated (OAuth).
- GitHub CLI
gh authenticated with PR create permissions.
- Repo present and on a valid branch (usually
main).
- Branch prefix must be
codex/.
If any prerequisite is missing, stop and ask for the single missing item.
Inputs (only)
- Initiative name (string)
- Project name (string)
Defaults (do not ask)
- Process all open tasks in the project.
- Order by priority (if available), then by
createdAt ascending.
- Status mapping: use
In Progress for active work, Done when PR is opened.
- Branch naming:
codex/fix/KEY-slug or codex/feature/KEY-slug.
fix vs feature: use fix if issue looks like a defect/bug (labels or title contains: bug, fix, error, errore, broken, non, crash). Otherwise feature.
- PR base:
main.
- Tests: if none run, write “Not run (not available)” in PR.
Linear MCP Workflow (no questions unless blocked)
1) Resolve initiative + project
- Use
list_initiatives with query = initiative name, includeProjects = true.
- Use
list_projects with query = project name, includeArchived = true.
- Match project to initiative; if multiple matches, pick exact name match. If still ambiguous, stop and ask for clarification.
2) Get issues
- Use
list_issues with project = project name (or ID), includeArchived = false.
- Filter out
Done/Canceled/Duplicate.
- Sort by priority (desc) then
createdAt (asc).
3) For each issue
- Set status to
In Progress via update_issue.
- Proceed with Git workflow below.
- When PR is created: add Linear comment with PR URL + testing line via
create_comment.
- Set status to
Done via update_issue.
- Attach PR link if supported (attachments auto-link from comment is OK).
Git Workflow (commands)
Preflight (do not block)
git status -sb
- If there are unrelated local changes:
- Do not discard.
- Keep them unstaged.
- Only stage files you edit for the current issue.
Branch creation
- Format slug: lowercase, hyphenated, short (3–6 words).
- Create branch:
git switch -c codex/fix/KEY-slug
- or
git switch -c codex/feature/KEY-slug
If branch creation fails due to permissions or lock:
- Request permission to proceed (Git needs write access to
.git/refs).
Commit
- Stage only files relevant to the issue:
- Commit message:
fix(KEY): <summary>
feat(KEY): <summary>
Push
git push -u origin <branch>
PR creation (gh)
gh pr create --base main --head <branch> --title "<type>(KEY): <summary>" --body "<body>"
- Default PR body template:
## Summary
- <bullet 1>
- <bullet 2>
## Testing
- Not run (not available)
## Linear
- KEY
Implementation Guidance (no-ask mode)
- Prefer minimal, targeted changes.
- If UI change is requested, search in
src/ui/src.
- Use
rg for fast searching.
- If task is ambiguous, infer from title/description and proceed.
Error Handling
- If Linear MCP calls fail: stop and ask to reconnect Linear MCP.
- If
gh fails: stop and ask to authenticate.
- If repo has merge conflicts: stop and ask whether to resolve now or skip the task.
Completion Output
After finishing all tasks:
- Provide a summary:
- Each issue key → branch → PR URL → status
- Mention any tests not run.
- Mention any unrelated local changes detected.
Non-goals
- Do not refactor unrelated code.
- Do not change API contracts unless the issue explicitly requires it.
- Do not close Linear tasks without creating a PR (unless explicitly told to skip PRs).
1---2name: linear3description: Linear Git Autopilot4---56# Linear Git Autopilot78## Goal910Run a fully automated workflow from a Linear initiative + project to completed PRs, using:11- Linear MCP for task discovery and status updates12- Git for branching/commits13- `gh` for PR creation1415Default behavior: proceed without asking questions unless blocked by missing access, missing required tools, or ambiguous project/initiative matching.1617## Prerequisites (assume true; stop only if missing)18- Linear MCP server `linear` enabled and authenticated (OAuth).19- GitHub CLI `gh` authenticated with PR create permissions.20- Repo present and on a valid branch (usually `main`).21- Branch prefix must be `codex/`.2223If any prerequisite is missing, stop and ask for the single missing item.2425## Inputs (only)26- Initiative name (string)27- Project name (string)2829## Defaults (do not ask)30- Process **all open tasks** in the project.31- Order by priority (if available), then by `createdAt` ascending.32- Status mapping: use `In Progress` for active work, `Done` when PR is opened.33- Branch naming: `codex/fix/KEY-slug` or `codex/feature/KEY-slug`.34- `fix` vs `feature`: use `fix` if issue looks like a defect/bug (labels or title contains: `bug`, `fix`, `error`, `errore`, `broken`, `non`, `crash`). Otherwise `feature`.35- PR base: `main`.36- Tests: if none run, write “Not run (not available)” in PR.3738## Linear MCP Workflow (no questions unless blocked)3940### 1) Resolve initiative + project41- Use `list_initiatives` with query = initiative name, includeProjects = true.42- Use `list_projects` with query = project name, includeArchived = true.43- Match project to initiative; if multiple matches, pick exact name match. If still ambiguous, stop and ask for clarification.4445### 2) Get issues46- Use `list_issues` with project = project name (or ID), includeArchived = false.47- Filter out `Done`/`Canceled`/`Duplicate`.48- Sort by priority (desc) then `createdAt` (asc).4950### 3) For each issue51- Set status to `In Progress` via `update_issue`.52- Proceed with Git workflow below.53- When PR is created: add Linear comment with PR URL + testing line via `create_comment`.54- Set status to `Done` via `update_issue`.55- Attach PR link if supported (attachments auto-link from comment is OK).5657## Git Workflow (commands)5859### Preflight (do not block)60- `git status -sb`61- If there are unrelated local changes:62 - Do not discard.63 - Keep them unstaged.64 - Only stage files you edit for the current issue.6566### Branch creation67- Format slug: lowercase, hyphenated, short (3–6 words).68- Create branch:69 - `git switch -c codex/fix/KEY-slug`70 - or `git switch -c codex/feature/KEY-slug`7172If branch creation fails due to permissions or lock:73- Request permission to proceed (Git needs write access to `.git/refs`).7475### Commit76- Stage only files relevant to the issue:77 - `git add <files>`78- Commit message:79 - `fix(KEY): <summary>`80 - `feat(KEY): <summary>`8182### Push83- `git push -u origin <branch>`8485### PR creation (gh)86- `gh pr create --base main --head <branch> --title "<type>(KEY): <summary>" --body "<body>"`87- Default PR body template:8889```90## Summary91- <bullet 1>92- <bullet 2>9394## Testing95- Not run (not available)9697## Linear98- KEY99```100101## Implementation Guidance (no-ask mode)102103- Prefer minimal, targeted changes.104- If UI change is requested, search in `src/ui/src`.105- Use `rg` for fast searching.106- If task is ambiguous, infer from title/description and proceed.107108## Error Handling109110- If Linear MCP calls fail: stop and ask to reconnect Linear MCP.111- If `gh` fails: stop and ask to authenticate.112- If repo has merge conflicts: stop and ask whether to resolve now or skip the task.113114## Completion Output115116After finishing all tasks:117- Provide a summary:118 - Each issue key → branch → PR URL → status119- Mention any tests not run.120- Mention any unrelated local changes detected.121122## Non-goals123124- Do not refactor unrelated code.125- Do not change API contracts unless the issue explicitly requires it.126- Do not close Linear tasks without creating a PR (unless explicitly told to skip PRs).