PluginWorks in Claude CodeCurrent
Buildkite
Official Buildkite skills for Claude Code, Cursor, and other AI coding agents — pipelines, migration, preflight, agent runtime, CLI, and API
0
Try it
See what this would do for you. No sign-up needed.
Install in Claude Code
Run these in Claude Code, in order. The first adds the marketplace, the second installs the plugin.
Step 1
/plugin marketplace add anthropics/claude-plugins-official
Step 2
/plugin install buildkite@claude-plugins-official
Review commands before running them. Promptu never runs code on your machine or pushes changes to your repo.
What's inside
7 skills
- buildkite-agent-runtime
- buildkite-api
- buildkite-cache
- buildkite-cli
- buildkite-migration
- buildkite-pipelines
- buildkite-preflight
Security scan
Flagged
Promptu's text scan flagged something in this plugin. Read its files before you install it.
credential-access in skills/buildkite-cli/SKILL.md:62
Details
# Buildkite Skills
The official Buildkite skills for Claude Code, Cursor, and other AI coding
agents. Install them into your agent of choice so it can generate correct
pipeline YAML, run `bk` and `buildkite-agent` CLI commands, call the API,
configure agents, and run preflight builds.
## Installation
```bash
npx skills add buildkite/skills
```
See [skills.sh](https://skills.sh) for supported agents and options.
### Claude Code
Add the marketplace and install the plugin:
```
/plugin marketplace add buildkite/skills
/plugin install buildkite@buildkite-skills
```
### Cursor
Search for **Buildkite Skills** in the Cursor Marketplace, or run `/add-plugin` and search for "Buildkite".
### Kiro
Recommended (one install): add the Buildkite **power** in the Powers panel, pointing at
`github.com/buildkite/skills`. The root `POWER.md`, `mcp.json`, and `steering/`
together give Kiro the Buildkite MCP server plus all seven workflows (pipelines,
migration, preflight, agent-runtime, cache, CLI, API), loaded automatically when relevant.
Alternatively, install individual workflows as Kiro **skills** via the Skills panel —
each `skills/buildkite-*/` directory already conforms to the open Agent Skills standard.
### Manual
Copy skill directories into your agent's skills folder:
```bash
# Claude Code
mkdir -p .claude/skills
cp -r skills/buildkite-pipelines .claude/skills/
cp -r skills/buildkite-preflight .claude/skills/
cp -r skills/buildkite-agent-runtime .claude/skills/
cp -r skills/buildkite-cache .claude/skills/
cp -r skills/buildkite-cli .claude/skills/
cp -r skills/buildkite-api .claude/skills/
cp -r skills/buildkite-migration .claude/skills/
# Cursor
mkdir -p .cursor/skills
cp -r skills/buildkite-pipelines .cursor/skills/
cp -r skills/buildkite-preflight .cursor/skills/
cp -r skills/buildkite-agent-runtime .cursor/skills/
cp -r skills/buildkite-cache .cursor/skills/
cp -r skills/buildkite-cli .cursor/skills/
cp -r skills/buildkite-api .cursor/skills/
cp -r skills/buildkite-migration .cursor/skills/
```
## Skills
### Journey Skills
Skills organized by what you are trying to accomplish.
| Skill | Directory | Description |
|-------|-----------|-------------|
| **Pipelines** | [skills/buildkite-pipelines/](skills/buildkite-pipelines/SKILL.md) | Pipeline YAML, step types, plugins, caching, parallelism, dynamic pipelines, matrix builds, artifacts, hooks |
| **Migration** | [skills/buildkite-migration/](skills/buildkite-migration/SKILL.md) | CI migration planning, converting from GitHub Actions, Jenkins, CircleCI, Bitbucket Pipelines, GitLab CI using `bk pipeline convert` |
### Cross-Cutting Skills
Skills needed across all journeys.
| Skill | Directory | Description |
|-------|-----------|-------------|
| **Preflight** | [skills/buildkite-preflight/](skills/buildkite-preflight/SKILL.md) | `bk preflight` runs a CI build against local uncommitted changes |
| **Agent Runtime** | [skills/buildkite-agent-runtime/](skills/buildkite-agent-runtime/SKILL.md) | `buildkite-agent` subcommands inside running job steps — annotate, artifact, meta-data, pipeline upload, OIDC, locks |
| **Cache** | [skills/buildkite-cache/](skills/buildkite-cache/SKILL.md) | Buildkite Cache (preview) — `buildkite-agent cache save/restore`, `.buildkite/cache.yml`, cache keys, fallbacks, registries |
| **CLI** | [skills/buildkite-cli/](skills/buildkite-cli/SKILL.md) | `bk` commands for builds, jobs, pipelines, secrets, artifacts, and auth |
| **API** | [skills/buildkite-api/](skills/buildkite-api/SKILL.md) | REST API, GraphQL API, webhooks, authentication, pagination |
## How Skills Differ from Docs
Buildkite docs at [buildkite.com/docs](https://buildkite.com/docs) are the canonical
reference for what Buildkite features exist and how they work.
Skills serve a different purpose: they encode **expertise**. Where docs explain every
option, skills teach agents the right defaults, common patterns, and mistakes to avoid.
A skill captures the judgment an experienced Buildkite user applies — which step type to
reach for, how to structure a dynamic pipeline, when to use OIDC instead of static tokens.
In practice this means:
- Skills assume the agent already understands YAML, CI/CD concepts, and general programming
- SKILL.md files focus on quick starts, recommended patterns, and pitfall tables — not exhaustive option lists
- Detailed reference material lives in `references/` subdirectories, loaded only when needed
- Skills link to Buildkite docs rather than reproducing them
For more on content strategy, see [CONVENTIONS.md](CONVENTIONS.md).
## Contributing
1. Read [CONVENTIONS.md](CONVENTIONS.md) — frontmatter format, section order, style rules, skill boundaries, quality checklist
2. Review an existing complete skill as a quality benchmark (e.g. `skills/buildkite-pipelines/SKILL.md`)
3. Check the boundary table in CONVENTIONS.md — each topic is owned by exactly one skill
4. Write your skill following the section order and style rules
## Documentation
Full Buildkite docs at [buildkite.com/docs](https://buildkite.com/docs).
## License
[MIT](LICENSE)
## skills/buildkite-agent-runtime/SKILL.md
---
name: buildkite-agent-runtime
description: >
This skill should be used when the user asks to "add an annotation",
"upload artifacts from a step", "share data between steps", "upload pipeline
dynamically", "request an OIDC token inside a step", "acquire a distributed lock",
"get or update a step attribute", "redact a secret from logs", "retrieve a cluster
secret at runtime", or "debug environment variables in hooks".
Also use when the user mentions buildkite-agent annotate, buildkite-agent artifact
upload/download, buildkite-agent meta-data set/get, buildkite-agent pipeline upload,
buildkite-agent oidc request-token, buildkite-agent step, buildkite-agent lock,
buildkite-agent env, buildkite-agent secret get, buildkite-agent redactor add,
buildkite-agent tool sign/keygen, buildkite:webhook, raw webhook payloads, or
any buildkite-agent subcommand used inside a running job step.
---
# Buildkite Agent Runtime
The `buildkite-agent` binary provides subcommands for interacting with Buildkite from within running job steps — creating annotations, uploading artifacts, sharing state between jobs, generating dynamic pipelines, requesting OIDC tokens, and more. This skill covers the command syntax, flags, and patterns for every in-job subcommand.
## Quick Start
A step that runs tests, annotates failures, uploads coverage, and stores a result flag for downstream jobs:
```yaml
steps:
- label: ":test_tube: Tests"
command: |
if ! make test 2>&1 | tee test-output.txt; then
buildkite-agent annotate --style "error" --context "test-failures" < test-output.txt
buildkite-agent meta-data set "tests-passed" "false"
exit 1
fi
buildkite-agent annotate "All tests passed :white_check_mark:" --style "success" --context "test-results"
buildkite-agent artifact upload "coverage/**/*"
buildkite-agent meta-data set "tests-passed" "true"
```
A downstream step reading that state:
```yaml
- label: ":rocket: Deploy"
command: |
PASSED=$(buildkite-agent meta-data get "tests-passed")
if [[ "$PASSED" != "true" ]]; then
echo "Tests did not pass, skipping deploy"
exit 0
fi
scripts/deploy.sh
depends_on: "test-step"
```
## Annotations
Surface build results directly on the build page. Annotations support Markdown and HTML.
### Creating annotations
```bash
# Simple text annotation
buildkite-agent annotate "Deploy completed successfully" --style "success" --context "deploy"
# Pipe from a file
buildkite-agent annotate --style "error" --context "test-failures" < test-output.md
```
### Key flags
| Flag | Short | Default | Description |
|------|-------|---------|-------------|
| `--style` | `-s` | `default` | Visual style: `default`, `info`, `warning`, `error`, `success` |
| `--context` | `-c` | random UUID | Unique ID — reusing a context replaces the annotation |
| `--append` | — | `false` | Append to existing annotation with same context instead of replacing |
| `--priority` | — | `3` | Display priority (1-10). Higher numbers appear first |
| `--job` | — | current job | Job ID to annotate (rarely needed) |
### Replacing vs appending
- **Same `--context` without `--append`** replaces the annotation; **with `--append`** appends below existing content.
- Always use a stable `--context` value so reruns update the same annotation instead of creating duplicates.
> For pipeline-level `notify:` configuration, see the **buildkite-pipelines** skill.
## Artifacts
Upload files as build artifacts, download them in later steps or other builds, and search by glob.
### Upload
```bash
# Upload a single file
buildkite-agent artifact upload "pkg/release.tar.gz"
# Upload with glob pattern
buildkite-agent artifact upload "dist/**/*"
```
### Download
```bash
# Download to current directory
buildkite-agent artifact download "pkg/release.tar.gz" .
# Download from a specific step
buildkite-agent artifact download "dist/*" . --step "build-step"
```
### Search
```bash
# List matching artifacts
buildkite-agent artifact search "pkg/*.tar.gz" --build "$BUILDKITE_BUILD_ID"
```
For complete flag tables, see `references/flag-reference.md`.
> For the declarative `artifact_paths:` YAML key, see the **buildkite-pipelines** skill. For `bk artifact` CLI commands, see the **buildkite-cli** skill.
## Meta-data
A build-wide key-value store for sharing state between jobs. Set a value in one job, read it in any other job in the same build.
### Set
```bash
buildkite-agent meta-data set "release-version" "1.4.2"
```
### Get
```bash
VERSION=$(buildkite-agent meta-data get "release-version")
```
Use `--default` to return a fallback value instead of a non-zero exit when the key is missing: `buildkite-agent meta-data get "deploy-env" --default "staging"`.
### Check existence
```bash
# Returns exit code 0 if exists, 100 if not
if buildkite-agent meta-data exists "release-version"; then
echo "Version already set"
fi
```
### Common patterns
**Block step field values** are stored automatically as meta-data. Retrieve them by field key:
```bash
# After a block step with fields: [{key: "release-name", text: "Release Name"}]
RELEASE_NAME=$(buildkite-agent meta-data get "release-name")
```
**Raw webhook payloads** are available in webhook-triggered builds, while the webhook data remains cached. Read the special `buildkite:webhook` key when automation needs fields that are not promoted to first-class environment variables, such as the original pull request comment body.
```bash
WEBHOOK="$(buildkite-agent meta-data get "buildkite:webhook")"
COMMENT_BODY="$(jq -r '.comment.body' <<< "$WEBHOOK")"
```
## Pipeline Upload
Dynamically add steps to a running build. The core mechanism behind dynamic pipelines — generate YAML at runtime and upload it.
### Basic usage
```bash
# Upload a specific file
buildkite-agent pipeline upload .buildkite/deploy-steps.yml
# Pipe generated YAML from stdin
./scripts/generate-pipeline.sh | buildkite-agent pipeline upload
```
### Replace mode
By default, uploaded steps are **appended** after the current step. Use `--replace` to replace the entire remaining pipeline:
```bash
# Replace all remaining steps with the uploaded ones
buildkite-agent pipeline upload --replace .buildkite/new-pipeline.yml
```
### Key flags
| Flag | Default | Description |
|------|---------|-------------|
| `--replace` | `false` | Replace remaining pipeline steps instead of appending |
| `--no-interpolation` | `false` | Skip environment variable interpolation in the uploaded YAML |
| `--dry-run` | `false` | Validate and output the pipeline without uploading |
> For pipeline YAML syntax and step types, see the **buildkite-pipelines** skill.
## OIDC Tokens
Request short-lived OpenID Connect tokens from within a job step for authenticating to external services (cloud providers, package registries) without static credentials.
### Basic token request
```bash
# Request a token for a specific audience
TOKEN=$(buildkite-agent oidc request-token --audience "https://packages.buildkite.com/my-org/my-registry")
```
### Cloud provider authentication
```bash
# AWS — request token with STS audience
TOKEN=$(buildkite-agent oidc request-token --audience "sts.amazonaws.com")
```
### Key flags
| Flag | Default | Description |
|------|---------|-------------|
| `--audience` | Buildkite endpoint | Target service URL — must match the OIDC provider audience configuration |
| `--lifetime` | `0` (API default) | Token lifetime in seconds. When 0 or omitted, the API chooses a default lifetime |
| `--claim` | — | Optional claims to include (e.g., `organization_id,pipeline_id`). Repeatable |
| `--aws-session-tag` | — | Claims to map as AWS session tags. Repeatable |
> For end-to-end OIDC auth flows, cloud provider setup, and token claim details, see the **buildkite-secure-delivery** skill.
## Step Management
Read or modify step attributes at runtime. Useful for conditional logic within steps and build automation.
### Get step attributes
```bash
# Get a step's label (--step is required)
LABEL=$(buildkite-agent step get "label" --step "$BUILDKITE_STEP_KEY")
# Get another step's state
STATE=$(buildkite-agent step get "state" --step "deploy-step")
# Get the entire step as JSON
buildkite-agent step get --step "test-step" --format json
```
### Update step attributes
```bash
# Update a step's label dynamically
buildkite-agent step update "label" ":rocket: Deploying v${VERSION}" --step "$BUILDKITE_STEP_KEY"
# Append to an existing label
buildkite-agent step update "label" " (retried)" --step "build-step" --append
```
### Cancel a step
```bash
# Cancel all unfinished jobs for a step
buildkite-agent step cancel --step "optional-step"
# Force-cancel a running step
buildkite-agent step cancel --step "stuck-step" --force
```
### Key flags
| Flag | Default | Description |
|------|---------|-------------|
| `--step` | — | Step key or UUID to target (**required** — uses `$BUILDKITE_STEP_ID` env var if set) |
| `--build` | current build | Build UUID (for cross-build operations) |
| `--format` | — | Output format for `get` (use `json` for complex attributes) |
| `--append` | `false` | Append to existing value instead of replacing (`step update` only) |
| `--force` | `false` | Force cancel even if the step is running (`step cancel` only) |
## Distributed Locks
Coordinate parallel jobs within a build using distributed mutex locks. Prevents race conditions when multiple jobs access shared resources.
### Acquire / release pattern
```bash
#!/bin/bash
set -euo pipefail
# Acquire lock — blocks until available, returns a token
token=$(buildkite-agent lock acquire "database-migration")
trap 'buildkite-agent lock release "database-migration" "${token}"' EXIT
# Critical section — only one job runs this at a time
bundle exec rails db:migrate
```
### Do / done pattern (one-time setup)
Run a setup task exactly once across all parallel jobs:
```bash
#!/bin/bash
echo "+++ Setting up shared test environment"
if [[ $(buildkite-agent lock do "test-env-setup") == "do" ]]; then
echo "Downloading test assets..."
curl -o /tmp/test-data.zip https://releases.example.com/data.zip
unzip /tmp/test-data.zip -d /tmp/shared-test-files/
buildkite-agent lock done "test-env-setup"
else
echo "Assets already prepared by another job"
fi
# All jobs continue here
run-tests.sh
```
### Key flags
| Subcommand | Flags | Description |
|------------|-------|-------------|
| `lock acquire <name>` | `--lock-wait-timeout` | Maximum wait duration (e.g. `30s`, `5m`). Default: wait forever |
| `lock release <name> <token>` | — | Release with the token from `acquire` |
| `lock do <name>` | — | Returns `do` if lock acquired, `done` if already completed |
| `lock done <name>` | — | Mark a `do` lock as completed |
## Environment
Inspect and modify the job's environment variables. Primarily useful for debugging lifecycle hooks and understanding what environment changes hooks made.
```bash
# Dump all environment variables as JSON
buildkite-agent env dump | jq .
# Get a specific variable
buildkite-agent env get "BUILDKITE_BRANCH"
# Set variables for subsequent hooks and the command (KEY=value format)
buildkite-agent env set DEPLOY_TARGET=production "APP_NAME=My App"
```
### Key flags
| Subcommand | Description |
|------------|-------------|
| `env dump` | Dump all environment variables (JSON format by default) |
| `env get <keys...>` | Get one or more specific variables. Use `--format` for output format (`plain`, `json`, `json-pretty`) |
| `env set KEY=value [...]` | Set variables for subsequent phases. Accepts multiple `KEY=value` pairs |
| `env unset <key>` | Remove a variable from subsequent phases |
### Debugging hooks
The `env dump` command is particularly useful in lifecycle hooks to see what prior hooks changed:
```bash
#!/bin/bash
# .buildkite/hooks/pre-command
echo "--- Environment after environment hook:"
buildkite-agent env dump | jq 'keys'
```
> For agent lifecycle hooks and `buildkite-agent.cfg` configuration, see the [agent hooks](https://buildkite.com/docs/agent/hooks) and [agent configuration](https://buildkite.com/docs/agent/self-hosted/configure) documentation.
## Secrets
Retrieve cluster secrets at runtime from within job steps. Secrets retrieved this way are automatically added to the log redactor.
### Basic usage
```bash
# Get a secret value
SECRET_VAR=$(buildkite-agent secret get "deploy-key")
# Pass directly to a tool
cli-tool --token "$(buildkite-agent secret get "api-token")"
```
### Key flags
| Flag | Default | Description |
|------|---------|-------------|
| `--format` | `default` | Output format: `default` (single secret prints value, multiple prints JSON), `json`, or `env` (KEY="value" pairs) |
| `--skip-redaction` | `false` | Do not add the secret value to the log redactor |
| `--job` | current job | Job ID context |
Multiple secret keys can be requested at once: `buildkite-agent secret get KEY1 KEY2 KEY3`.
By default, `secret get` automatically registers retrieved values with the log redactor, masking them as `[REDACTED]` in subsequent output.
> For setting up cluster secrets, see the [Buildkite Secrets documentation](https://buildkite.com/docs/pipelines/security/secrets/buildkite-secrets). For the declarative `secrets:` pipeline YAML key, see the **buildkite-pipelines** skill.
## Log Redaction
Add values to the build log redactor at runtime so they are masked in all subsequent output. Use this for dynamically-retrieved secrets that were not declared via `secrets:` or `buildkite-agent secret get`.
### Basic usage
```bash
# Fetch a token from an external source
DYNAMIC_TOKEN=$(curl -s https://vault.example.com/token)
# Register it with the redactor before using it
echo "$DYNAMIC_TOKEN" | buildkite-agent redactor add
# Now any log output containing the token value shows [REDACTED]
echo "Using token: $DYNAMIC_TOKEN"
# Output: Using token: [REDACTED]
```
### Multiple values
```bash
# Redact multiple values
echo "$SECRET1" | buildkite-agent redactor add
echo "$SECRET2" | buildkite-agent redactor add
```
### When to use redactor vs secret get
| Scenario | Use |
|----------|-----|
| Secret stored in Buildkite cluster secrets | `buildkite-agent secret get` (auto-redacts) |
| Secret from external vault (HashiCorp Vault, AWS SSM, etc.) | Fetch externally, then `buildkite-agent redactor add` |
| Computed sensitive value (temporary token, derived key) | `buildkite-agent redactor add` |
## Tool Signing
Sign pipeline YAML so that agents can verify step integrity before execution. The `tool sign` command takes a pipeline file (not individual steps) and annotates it with signatures.
### Sign a pipeline from a file
```bash
# Sign a pipeline YAML file using a local JWKS key
buildkite-agent tool sign pipeline.yml \
--jwks-file /path/to/private-key.json \
--repo "git@github.com:org/repo.git"
```
### Sign via the GraphQL API
```bash
# Retrieve, sign, and update a pipeline via the Buildkite GraphQL API
buildkite-agent tool sign \
--graphql-token "$BUILDKITE_GRAPHQL_TOKEN" \
--organization-slug my-org \
--pipeline-slug my-pipeline \
--jwks-file /path/to/private-key.json \
--update
```
### Generate a signing key pair
```bash
# Generate a new JWS key pair (private + public JWKS files)
buildkite-agent tool keygen
```
### Key flags
| Command | Flag | Description |
|---------|------|-------------|
| `tool sign` | `--jwks-file` | Path to JWKS private key file for signing |
| `tool sign` | `--jwks-key-id` | Key ID to use from the JWKS file |
| `tool sign` | `--repo` | Repository URL (required when signing from a file) |
| `tool sign` | `--signing-aws-kms-key` | AWS KMS key ID for signing (alternative to JWKS) |
| `tool sign` | `--signing-gcp-kms-key` | GCP KMS key ID for signing (alternative to JWKS) |
| `tool sign` | `--graphql-token` | Token for retrieving/updating pipeline via GraphQL API |
| `tool sign` | `--update` | Update the pipeline in Buildkite after signing (requires `--graphql-token`) |
| `tool keygen` | `--alg` | JWS signing algorithm (default: `EdDSA`) |
| `tool keygen` | `--key-id` | Key ID for the generated pair (default: random) |
> **Note:** There is no `tool verify` command. Signature verification is handled internally by the agent when it receives a job.
> For pipeline signing configuration and rollout strategy, see the **buildkite-secure-delivery** skill.
## Common Mistakes
| Mistake | What happens | Fix |
|---------|-------------|-----|
| Missing `--context` on `annotate` | Each call creates a new annotation instead of updating | Always pass `--context` with a stable identifier |
| Using `--append` without matching `--context` | Append has no effect — creates a new annotation | Ensure `--context` matches the annotation to append to |
| Forgetting to quote artifact glob patterns | Shell expands globs before `buildkite-agent` sees them | Always quote: `"dist/**/*"` not `dist/**/*` |
| Reading `meta-data get` before the writing job completes | Key does not exist, command fails with non-zero exit | Use `depends_on` or `wait` to enforce ordering, or use `--default` |
| Using `pipeline upload --replace` unintentionally | Removes all remaining steps in the build | Only use `--replace` when intentionally rebuilding the entire pipeline |
| Not releasing locks on script failure | Lock held indefinitely, blocking other jobs | Use `trap ... EXIT` to release locks on any exit |
| Passing `--audience` that doesn't match OIDC provider config | Token rejected by the target service | Audience must exactly match the provider's configured audience URL |
| Using `--skip-redaction` with actual secrets | Secret values appear in plain text in build logs | Only use `--skip-redaction` for non-sensitive configuration values |
| Calling `env set` expecting it to affect the current shell | Variable is set for subsequent hooks/phases, not the current script | Use `export VAR=value` for current-script variables; `env set` for cross-phase |
| Passing large values via environment variables | OS-level env size limits cause silent truncation or job failure | Switch to file-based approaches (artifacts, meta-data with files) for payloads larger than a few KB |
| Uploading pipeline YAML with unescaped `$` in `--no-interpolation` mode off | Variables interpolated unexpectedly, producing malformed YAML | Use `--no-interpolation` when YAML contains literal `$` characters |
## Additional Resources
### Reference Files
- **`references/flag-reference.md`** — Complete flag tables for all subcommands including upload, download, search, shasum, annotate, meta-data, pipeline upload, oidc, step, lock, env, secret, redactor, and tool
- **`references/patterns-and-recipes.md`** — Advanced multi-subcommand patterns: test failure annotation pipelines, cross-job state machines, OIDC-authenticated Docker push, parallel job coordination with locks, environment debugging
## Further Reading
- [Buildkite Docs for LLMs](https://buildkite.com/docs/llms.txt)
- [Agent CLI — annotate](https://buildkite.com/docs/agent/v3/cli-annotate.md)
- [Agent CLI — artifact](https://buildkite.com/docs/agent/v3/cli-artifact.md)
- [Agent CLI — meta-data](https://buildkite.com/docs/agent/v3/cli-meta-data.md)
- [Agent CLI — pipeline](https://buildkite.com/docs/agent/v3/cli-pipeline.md)
- [Agent CLI — OIDC](https://buildkite.com/docs/agent/v3/cli-oidc.md)
- [Agent CLI — lock](https://buildkite.com/docs/agent/v3/cli-lock.md)
- [Managing secrets with Buildkite secrets](https://buildkite.com/docs/pipelines/security/secrets/buildkite-secrets.md)
- [Dynamic pipelines](https://buildkite.com/docs/pipelines/configure/dynamic-pipelines.md)
## skills/buildkite-api/SKILL.md
---
name: buildkite-api
description: >
This skill should be used when the user asks to "call the Buildkite API",
"use the REST API", "write a GraphQL query", "set up webhooks",
"automate Buildkite", "integrate with Buildkite programmatically",
"write a script that calls Buildkite", "handle webhook events",
"paginate API results", or "authenticate with the Buildkite API".
Also use when the user mentions api.buildkite.com, graphql.buildkite.com,
Buildkite REST endpoints, GraphQL mutations, webhook payloads,
API tokens, or asks about programmatic access to Buildkite data.
---
# Buildkite API
Do not treat REST as read-only and GraphQL as the write API. Default to REST for builds, pipelines, organization administration, hosted resources, diagnostics, and notification-service writes. Use GraphQL when typed nested reads avoid several requests or for GraphQL-only mutations.
> To execute API calls interactively from the terminal, see the **buildkite-cli** skill for `bk api` commands. With the Buildkite MCP server, prefer purpose-built tools for supported reads and actions.
## Quick Start
List lightweight build records with REST:
```bash
curl -sS -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
"https://api.buildkite.com/v2/organizations/my-org/pipelines/my-pipeline/builds?exclude_jobs=true&exclude_pipeline=true&per_page=5" \
| jq '.[] | {number, state, branch}'
```
Query selected nested fields with GraphQL:
```bash
curl -sS -X POST "https://graphql.buildkite.com/v1" \
-H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query":"{ pipeline(slug: \"my-org/my-pipeline\") { builds(first: 5) { edges { node { number state message } } } } }"}' \
| jq '.data.pipeline.builds.edges[].node'
```
## Authentication and access
Pass a personal API access token as a bearer token. Scope tokens to the required organizations and grant the minimum scopes. Treat an HTTP `404` as potentially meaning either absent or unavailable: several permission-gated and feature-gated resources deliberately do not disclose existence.
```bash
curl -sS -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
"https://api.buildkite.com/v2/organizations"
```
For short-lived credentials, public-key API access tokens (preview) can authenticate REST API access with an RS256-signed JWT. Set the access token UUID as `iss`, keep `iat` within 10 seconds of the current time, and set `exp` no more than five minutes after `iat`. The JWT inherits the token's organization access and scopes.
Common scopes include:
| Capability | Scopes |
|------------|--------|
| Builds, pipelines, and artifacts | `read_builds`/`write_builds`, `read_pipelines`/`write_pipelines`, `read_artifacts`/`write_artifacts` |
| Job logs, environments, and agents | `read_build_logs`/`write_build_logs`, `read_job_env`, `read_agents`/`write_agents` |
| Organization members | `read_organizations`/`write_organizations` |
| Organization settings | `read_organization_settings`/`write_organization_settings` |
| Audit events | `read_audit_events` |
| Repository connections and discovery | `read_organization_repository_connections` |
| Notification services | `read_notification_services`/`write_notification_services` |
| Organization invitations | `read_organization_invitations`/`write_organization_invitations` |
| Teams | `read_teams`/`write_teams` |
| Hosted and cluster resources | `read_clusters`/`write_clusters` |
Scopes are necessary but not always sufficient. Treat `403` and permission-gated `404` responses as access or availability boundaries, not evidence that another payload or endpoint should be tried. Use observable organization state and known caller context when available; otherwise report the required role, permission, or feature and ask an administrator to verify it. See [API token scopes](https://buildkite.com/docs/apis/managing-api-tokens#token-scopes) for the full catalogue.
## REST API
Use `https://api.buildkite.com/v2` as the base URL and `Content-Type: application/json` for JSON request bodies. Most organization-scoped resources begin with `/organizations/{org.slug}`; user, organization-list, and other top-level resources do not.
For build metadata and status reads, default to `exclude_jobs=true&exclude_pipeline=true`. Fetch jobs from the Jobs API only when job details are required.
### Capability map
Use this map to select a resource family, then open the linked reference for exact schemas and response behavior.
| Family | Protocol and access | Scope, permission, or gate | Key boundary and docs |
|--------|---------------------|----------------------------|-----------------------|
| Organization settings | REST read/write | `read_organization_settings`/`write_organization_settings`; organization admin; field gates | Read before writing; API allowlist changes can lock out the caller. [API settings](https://buildkite.com/docs/apis/rest-api/organizations/api-settings) and [pipeline settings](https://buildkite.com/docs/apis/rest-api/organizations/pipeline-settings) |
| Audit events | REST read-only | `read_audit_events`; organization admin; Enterprise | Cursor-paginated independently of settings. [Audit events](https://buildkite.com/docs/apis/rest-api/organizations/audit-events) |
| Members and invitations | REST read/write | `read_organizations`/`write_organizations`, `read_organization_invitations`/`write_organization_invitations`; organization admin for member updates and all invitation operations | Member `PATCH` changes only `role` and `sso_mode` and cannot target the caller; pending invitations are not memberships. [Members](https://buildkite.com/docs/apis/rest-api/organizations/members) and [invitations](https://buildkite.com/docs/apis/rest-api/organizations/invitations) |
| Teams activation | REST enable-only; GraphQL `Organization.isTeamsEnabled` state read | `write_teams`; organization access; `change_teams_enabled`; plan gate when disabled | Idempotent `POST /organizations/{org.slug}/teams/enable`; may create Everyone when no teams exist; no REST read or disable route. [Teams](https://buildkite.com/docs/apis/rest-api/teams) |
| Repository connections | REST read-only | `read_organization_repository_connections`; organization admin; provider support | Connections have no API mutations; unsupported discovery providers return `422`. [Connections](https://buildkite.com/docs/apis/rest-api/organizations/repository-connections) and [discovery](https://buildkite.com/docs/apis/rest-api/repository-connections) |
| Pipeline setup | REST read/write | `read_pipelines`/`write_pipelines`; pipeline access | Create validates and mutates together; there is no REST dry run. [Pipelines](https://buildkite.com/docs/apis/rest-api/pipelines) |
| Notification services | REST read/write lifecycle | `read_notification_services`/`write_notification_services`; organization admin or **Manage Notification Services** | OAuth Slack Workspace and Linear require initial browser authorization; preserve omitted secrets. [Notification services](https://buildkite.com/docs/apis/rest-api/organizations/notification-services) |
| Inbound GitHub processing | REST read/write | `read_pipelines`/`write_pipelines`; Full Access; provider and feature gates | Processing controls do not register a repository webhook or configure the GitHub App. [Pipelines](https://buildkite.com/docs/apis/rest-api/pipelines) |
| Build lifecycle | REST read/write | `read_builds`/`write_builds`; pipeline access | Rebuild replays the original context instead of fetching current source-control state. Build cancel stops every unfinished job; job cancel stops one. [Builds](https://buildkite.com/docs/apis/rest-api/builds) and [jobs](https://buildkite.com/docs/apis/rest-api/jobs) |
| Hosted resources | REST mixed access | `read_clusters`/`write_clusters`; manage-cluster permission; hosted-agent and resource gates | Cluster read/update exposes hosted Git mirror and container cache settings only to cluster managers; image creation is asynchronous with no update; cache deletion is explicit. [Clusters](https://buildkite.com/docs/apis/rest-api/clusters), [images](https://buildkite.com/docs/apis/rest-api/clusters/agent-images), [network ranges](https://buildkite.com/docs/apis/rest-api/clusters/network-ranges), and [cache volumes](https://buildkite.com/docs/apis/rest-api/clusters/cache-volumes) |
| Diagnostics | REST read-only | `read_builds`, `read_agents` | Signal and agent lifecycle fields are evidence, not proof that retry is safe. [Jobs](https://buildkite.com/docs/apis/rest-api/jobs) and [agents](https://buildkite.com/docs/apis/rest-api/agents) |
| Artifacts | REST read/write; GraphQL deletion | `read_artifacts`/`write_artifacts` for REST; GraphQL API access; **Build & Read** access or higher on the artifact's pipeline for deletion | Filter before pagination and confirm deletion explicitly. [Artifacts](https://buildkite.com/docs/apis/rest-api/artifacts) |
### Pagination
Most REST list responses return arrays and HTTP `Link` headers. Follow the URL marked `rel="next"` rather than constructing page numbers. Keep query filters on the initial request and use the server-provided next URL thereafter.
The Jobs API, invitations, notification services, and audit events use cursor-oriented bodies. Read records from `.items` and follow `.links.next` until it is `null`. Audit events also expose a `Link` header. Do not run array-only `jq` filters against these body shapes.
REST requests consume both organization and per-user quotas. On `429`, stop requests until the matching `RateLimit-Reset` or `RateLimit-User-Reset` window expires; do not retry in a tight loop. Remote Buildkite MCP server requests use a separate per-user limit, while local MCP server requests consume the organization REST quota.
### Pipeline creation
Default to pipeline YAML in the REST `configuration` string. Include `cluster_id` when a cluster has been selected. Omission is valid when the organization allows unclustered pipelines; otherwise the server returns `422` with `Cluster must be specified`. Do not reject a create client-side solely because `cluster_id` is absent. Use `pipeline_template_uuid` when the user or organization workflow has selected a template. Send a visual `steps` array only for a known legacy visual-step workflow; no public organization field reliably identifies that mode before creation.
The create request performs server validation and mutation together. Validate YAML locally first when useful, but do not describe local schema validation as proof that repository access, provider setup, permissions, or server-side create constraints will pass. Report a `422` validation response instead of silently retrying with a different step source.
### Organization administration
Read settings before mutation, compare only managed fields, and send the smallest supported update. Preserve unknown or feature-gated fields. For API settings, model an allowlist change as a lockout-sensitive operation: verify the caller's source address, retain a rollback path, and avoid concurrent settings writes.
Treat invitations and memberships as different states. List invitations to reconcile pending requests, use show for any invitation state, and use `DELETE` only to revoke a pending invitation. Bulk invitation creation supports role, SSO mode, and team assignments, but validates the entire request atomically. A failure creates none of the requested invitations.
Update an existing member with `PATCH /organizations/{org.slug}/members/{user.uuid}` only after reading that membership. The request accepts only `role` (`admin` or `member`) and `sso_mode` (`optional` or `required`), requires `write_organizations` and organization-admin permission, and cannot update the caller's own membership. Send only the fields intended to change; use invitations for people who are not yet members.
Enable Teams only when the requested outcome explicitly requires team-based permissions. Do not use the mutation to probe availability. Read `Organization.isTeamsEnabled` through GraphQL when the current state is needed; when Teams is disabled, explain the plan and permission requirements before enabling it.
### Hosted resources
Read a cluster with `read_clusters` before changing hosted cache behavior. For callers with manage-cluster permission, cluster show responses include `hosted_git_mirror_enabled` and `hosted_container_cache_enabled`; callers without that permission do not receive these fields, so do not interpret absence as `false`. Update either boolean with `PUT /organizations/{org.slug}/clusters/{id}` using `write_clusters` and manage-cluster permission. Changing either value is supported only for hosted clusters; a non-hosted cluster returns `422`.
### Artifact filtering
Apply `state` and `path` before pagination on build-level and job-level artifact lists. A path without `*` is exact; include `*` only when glob matching is intended. URL-encode paths and state filters rather than filtering a single page locally.
Download by artifact ID with `curl -L` because the download endpoint redirects. REST deletion requires `write_artifacts`; both REST and GraphQL deletion also require **Build & Read** access or higher on the artifact's pipeline. REST accepts the artifact UUID at either `/organizations/{org.slug}/jobs/{job.id}/artifacts/{id}` or the fully qualified pipeline/build/job route. The build-level artifact-list route has no corresponding delete operation. GraphQL `artifactDelete` accepts the artifact global ID and requires GraphQL API access. Require explicit confirmation for either path, and never turn filtered discovery into an automatic deletion loop.
If the organization uses customer-managed artifact storage, deleting the Buildkite artifact does not remove the underlying object. Do not infer the storage backend or delete external objects automatically; consult the organization's artifact-storage configuration and deletion runbook.
### Job and agent diagnostics
Query jobs directly once the build number is known. Prefer server-side `state`, `step_key`, and `group_key` filters to fetching every job and filtering locally. A step key matches every job for that step, including parallel jobs; a group key matches every job in that group. Follow each `.links.next` URL as returned so filters remain applied across cursor pages.
Use `signal` and `signal_reason` to distinguish signal termination from an ordinary nonzero exit. Inspect the embedded agent's `os_id`, `arch`, `queue`, `connected_at`, `disconnected_at`, `lost_at`, and `stopped_at` to correlate platform, routing, and lifecycle timing.
Treat this context as diagnostic evidence, not proof that retry is safe. Before retrying, inspect logs, side effects, retry history, and whether the command is idempotent. A lost agent can explain interruption without establishing that an external deployment or write did not complete.
### Job cancellation
Cancel one command job with `PUT /organizations/{org.slug}/jobs/{job.id}/cancel`, or the nested `PUT /organizati

