A Buildkite pipeline that uses Claude Code and Buildkite model providers to diagnose and fix Linear issues.
Make sure you have access to a Linear workspace that allows you to create and manage webhooks.
- Create a new GitHub repository using this repository as a template.
- Create a new Buildkite pipeline for your newly templated repository with a Linux hosted agents cluster.
- Create a new pipeline trigger for the pipeline, then copy the generated webhook URL to your clipboard.
- On the Settings > API page of your Linear workspace, add a new Linear webhook, paste your Buildkite webhook URL into the URL field, choose Issues (under Data change events), and save.
- Create three new Buildkite secrets with the following names:
GITHUB_TOKEN: A GitHub personal access token withrepoandpull_requestread/write scopes.LINEAR_API_TOKEN: A Linear API key with "Read" permissions.API_TOKEN_BUILDKITE: A Buildkite API access token withread_builds,read_build_logs, andread_pipelinespermissions.
- Create a new issue Linear describing the work to be done. Label the issue with
buildkite-analyze. (This label is configurable in.buildkite/pipeline.yml.) - In a few moments, you should see a new comment appear on the issue confirming the agent's picked up the task. Follow the link to the Buildkite dashboard to have a look.
- Once the agent determines a fix, you should see a new PR submitted on the associated GitHub repository explaining what was done. Have a look at that PR, and if it looks good, approve and merge.
That's it! Your issue should now be addressed. 🎉
The pipeline listens for webhooks originating from Linear issue events. When a new issue is detected, the pipeline runs the handler script, which adds a step to the running pipeline that uses Claude to diagnose and fix the issue, annotating the Buildkite build as it goes. When the work is complete, Claude commits the changes to a new feature branch on the associated GitHub repository, submits a new PR, and reports back on the Linear issue with a summary.
The following diagram shows the high-level flow, beginning with the Linear issue label:
sequenceDiagram
participant User
participant Linear
participant Buildkite
participant Agent as AI Agent
participant GitHub
User->>Linear: Apply label to issue
Linear->>Buildkite: Send webhook with issue details
Buildkite->>Buildkite: Validate payload and generate pipeline
Buildkite->>Agent: Start agent in Docker container
Agent->>Linear: Acknowledge issue with build link
Agent->>Linear: Read issue details
Agent->>GitHub: Analyze codebase
Agent->>Agent: Determine complexity
alt Low/medium complexity
Agent->>GitHub: Create PR with fix
Agent->>Linear: Post PR link
User->>GitHub: Review and merge PR
else Higher complexity
Agent->>Linear: Post detailed analysis
User->>Linear: Review findings
User->>GitHub: Implement fix manually
end
- User applies a
buildkite-analyzelabel to a Linear issue. - Linear sends a webhook notification to Buildkite with issue details, triggering the pipeline.
- Pipeline evaluates the webhook payload and conditionally adds a step to the running pipeline to launch Claude. pipeline dynamically.
- In a Docker containerm Claude reads the issue, analyzes the codebase, and determines a course of action:
- For simpler issues, it creates a fix and submits a PR to GitHub.
- For more complex issues, it documents its findings and posts an analysis back to Linear.