AI-powered build analysis and error diagnosis using Claude. This plugin automatically analyzes build failures, provides root cause analysis, and suggests actionable fixes through Buildkite annotations.
- 🤖 Intelligent Build Analysis: Claude analyzes build logs to identify root causes of failures
- 📋 Buildkite Annotations: Creates rich annotations with analysis results and suggested fixes
- ⚡ Smart Triggering: Configurable triggers (on-failure, always, manual)
- 🔧 Actionable Insights: Provides specific steps to resolve issues and prevent future failures
- 🎯 Context-Aware: Understands build context including branch, commit, and job information
- curl: For API requests
- jq: For JSON processing
- Anthropic API Key: From console.anthropic.com
- Get your Anthropic API key from console.anthropic.com
- Add it to your Buildkite environment variables as
ANTHROPIC_API_KEY
- For Buildkite secrets, create
.buildkite/hooks/pre-command
in your repository:#!/bin/bash export ANTHROPIC_API_KEY=$(buildkite-agent secret get ANTHROPIC_API_KEY) export BUILDKITE_API_TOKEN=$(buildkite-agent secret get BUILDKITE_API_TOKEN)
- Add the plugin to your pipeline using one of these approaches:
steps:
# Option 1: Using environment variable set at upload time
- label: "🧪 Run tests"
command: "npm test"
plugins:
- claude-summarize#v1.1.0:
api_key: "$$ANTHROPIC_API_KEY"
# Option 2: Using Buildkite secrets (recommended)
# First, create .buildkite/hooks/pre-command with:
# export ANTHROPIC_API_KEY=$(buildkite-agent secret get ANTHROPIC_API_KEY)
- label: "🧪 More tests"
command: "npm test"
plugins:
- claude-summarize#v1.1.0:
api_key: "$$ANTHROPIC_API_KEY"
Your Anthropic API key for accessing Claude. Use an environment variable reference:
- Environment variable:
"${ANTHROPIC_API_KEY}"
- References an environment variable set at upload time - Buildkite secrets: Create
.buildkite/hooks/pre-command
withexport ANTHROPIC_API_KEY=$(buildkite-agent secret get ANTHROPIC_API_KEY)
, then use"$$ANTHROPIC_API_KEY"
(recommended)
Custom Anthropic API base URL. Default: https://api.anthropic.com
Use this to point to alternative endpoints like:
- Enterprise/private Claude deployments
- Proxy servers
- Development/testing environments
Claude model to use for analysis. Default: claude-3-7-sonnet-20250219
Buildkite API token for fetching job logs directly from the Buildkite API. This improves analysis by providing the exact failing job logs. If not specified, the plugin will look for BUILDKITE_API_TOKEN
in the environment.
When to trigger Claude analysis. Options: on-failure
, always
, manual
. Default: on-failure
on-failure
: Only analyze when the build step failsalways
: Analyze every build (success or failure)manual
: Only whenCLAUDE_ANALYZE=true
environment variable is set or commit message contains[claude-analyze]
Level at which to analyze logs. Options: step
, build
. These require buildkite_api_token
to be set in order to fetch job logs, else we default to available environment variables. Default: step
step
: Analyze only the current step's logsbuild
: Analyze logs from all jobs in the entire build
Maximum number of log lines to send to Claude for analysis. Default: 1000
Additional context or instructions to include in the analysis prompt.
Timeout in seconds for Claude API requests. Default: 60
Whether to create Buildkite annotations with the analysis results. Default: true
Include project context from an agent file in the analysis. Default: false
true
: IncludeAGENT.md
from the repository rootfalse
: Don't include any agent context"path/to/file.md"
: Include the specified file
The agent file should contain project-specific context like architecture details, common issues, coding standards, or troubleshooting guides that help Claude provide more relevant analysis.
Enable build time comparison analysis. When enabled, Claude will analyze build time trends by comparing the current build duration against recent builds. Default: false
Number of previous builds to compare against for build time analysis. Only used when compare_builds
is true
. Default: 5
steps:
- label: "🧪 Run tests"
command: "npm test"
plugins:
- claude-summarize#v1.1.0:
api_key: "$$ANTHROPIC_API_KEY"
When tests fail, Claude will analyze the output and create an annotation with:
- Root cause analysis
- Key error explanations
- Suggested fixes
- Prevention strategies
steps:
- label: "🔍 Analyze entire build"
command: "npm test"
plugins:
- claude-summarize#v1.1.0:
api_key: "$$ANTHROPIC_API_KEY"
buildkite_api_token: "$$BUILDKITE_API_TOKEN"
analysis_level: "build"
trigger: "always"
With analysis_level: "build"
, Claude will analyze logs from all jobs in the build, providing insights across the entire pipeline.
steps:
- label: "🏗️ Build application"
command: "npm run build"
plugins:
- claude-summarize#v1.1.0:
api_key: "$$ANTHROPIC_API_KEY"
trigger: "always"
custom_prompt: "Focus on build performance and optimization opportunities"
steps:
- label: "🚀 Deploy to staging"
command: "./deploy.sh staging"
env:
CLAUDE_ANALYZE: "true" # Trigger manual analysis
plugins:
- claude-summarize#v1.1.0:
api_key: "$$ANTHROPIC_API_KEY"
trigger: "manual"
custom_prompt: "This is a deployment script. Focus on infrastructure and configuration issues."
max_log_lines: 2000
steps:
- label: "🏗️ Build with performance tracking"
command: "npm run build"
plugins:
- claude-summarize#v1.1.0:
api_key: "$$ANTHROPIC_API_KEY"
compare_builds: true
comparison_range: 10
custom_prompt: "Focus on build performance trends and identify any performance regressions"
When compare_builds
is enabled, Claude will:
- Compare current build time against the last N builds (configurable via
comparison_range
) - Identify performance trends and anomalies
- Suggest optimizations for slow builds
- Highlight significant performance changes
steps:
- label: "🔍 Lint code"
command: "npm run lint"
plugins:
- claude-summarize#v1.1.0:
api_key: "$$ANTHROPIC_API_KEY"
custom_prompt: "Focus on code quality and style issues"
- label: "🧪 Run tests"
command: "npm test"
plugins:
- claude-summarize#v1.1.0:
api_key: "$$ANTHROPIC_API_KEY"
custom_prompt: "Focus on test failures and coverage issues"
- label: "🏗️ Build production"
command: "npm run build:prod"
plugins:
- claude-summarize#v1.1.0:
api_key: "$$ANTHROPIC_API_KEY"
trigger: "always"
custom_prompt: "Focus on build optimization and bundle analysis"
Elastic Stack | Agent Stack K8s | Hosted (Mac) | Hosted (Linux) | Notes |
---|---|---|---|---|
✅ | ✅ | ✅ | ✅ |
- ✅ Fully compatible assuming requirements are met
Run tests with
docker compose run --rm tests
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Please follow the existing code style and include tests for any new features.
The package is available as open source under the terms of the MIT License.