AWS CodeBuild Management Skill
Analyze and manage AWS CodeBuild projects, builds, and build environments.
MANDATORY: Discovery-First Pattern
Always list projects before querying specific resources.
Phase 1: Discovery
#!/bin/bash
export AWS_PAGER=""
echo "=== CodeBuild Projects ==="
PROJECT_NAMES=$(aws codebuild list-projects --output text --query 'projects[]')
echo ""
echo "=== Project Details ==="
if [ -n "$PROJECT_NAMES" ]; then
aws codebuild batch-get-projects --names $PROJECT_NAMES --output text \
--query 'projects[].[name,source.type,environment.computeType,environment.image,lastModified]' | head -30
fi
echo ""
echo "=== Source Credentials ==="
aws codebuild list-source-credentials --output text \
--query 'sourceCredentialsInfos[].[serverType,authType,arn]' 2>/dev/null
echo ""
echo "=== Report Groups ==="
aws codebuild list-report-groups --output text \
--query 'reportGroups[]' 2>/dev/null | head -10
Phase 2: Analysis
#!/bin/bash
export AWS_PAGER=""
echo "=== Recent Builds ==="
BUILD_IDS=$(aws codebuild list-builds --max-items 20 --output text --query 'ids[]')
if [ -n "$BUILD_IDS" ]; then
aws codebuild batch-get-builds --ids $BUILD_IDS --output text \
--query 'builds[].[projectName,buildNumber,buildStatus,startTime,endTime,sourceVersion]' | head -20
fi
echo ""
echo "=== Failed Builds (last 20) ==="
if [ -n "$BUILD_IDS" ]; then
aws codebuild batch-get-builds --ids $BUILD_IDS --output text \
--query "builds[?buildStatus=='FAILED'].[projectName,buildNumber,buildStatus,phases[-1].phaseType,phases[-1].phaseStatus]"
fi
echo ""
echo "=== Build Duration Analysis ==="
for project in $(aws codebuild list-projects --output text --query 'projects[]'); do
{
build_ids=$(aws codebuild list-builds-for-project --project-name "$project" --max-items 5 --output text --query 'ids[]')
if [ -n "$build_ids" ]; then
aws codebuild batch-get-builds --ids $build_ids --output text \
--query "builds[].[projectName,buildNumber,buildStatus]" | head -5
fi
} &
done
wait
echo ""
echo "=== Build Environment Summary ==="
PROJECT_NAMES=$(aws codebuild list-projects --output text --query 'projects[]')
if [ -n "$PROJECT_NAMES" ]; then
aws codebuild batch-get-projects --names $PROJECT_NAMES --output text \
--query 'projects[].[name,environment.computeType,environment.type,environment.privilegedMode]' | head -20
fi
Output Format
- Target ≤50 lines per output
- Use
--output text --query and batch-get-* APIs for efficiency
- Tab-delimited fields: ProjectName, BuildNumber, Status, Duration
- Use batch APIs instead of individual describe calls
- Never dump full buildspec -- show source type and environment only
Anti-Hallucination Rules
- NEVER assume resource names — always discover via CLI/API in Phase 1 before referencing in Phase 2.
- NEVER fabricate metric names or dimensions — verify against the service documentation or
--help output.
- NEVER mix CLI commands between service versions — confirm which version/API you are targeting.
- ALWAYS use the discovery → verify → analyze chain — every resource referenced must have been discovered first.
- ALWAYS handle empty results gracefully — an empty response is valid data, not an error to retry.
Counter-Rationalizations
| Shortcut |
Counter |
Why |
| "I'll skip discovery and check known resources" |
Always run Phase 1 discovery first |
Resource names change, new resources appear — assumed names cause errors |
| "The user only asked for a quick check" |
Follow the full discovery → analysis flow |
Quick checks miss critical issues; structured analysis catches silent failures |
| "Default configuration is probably fine" |
Audit configuration explicitly |
Defaults often leave logging, security, and optimization features disabled |
| "Metrics aren't needed for this" |
Always check relevant metrics when available |
API/CLI responses show current state; metrics reveal trends and intermittent issues |
| "I don't have access to that" |
Try the command and report the actual error |
Assumed permission failures prevent useful investigation; actual errors are informative |
Common Pitfalls
- Build status values: SUCCEEDED, FAILED, FAULT, TIMED_OUT, IN_PROGRESS, STOPPED
- Batch APIs: Always use
batch-get-projects and batch-get-builds instead of individual calls
- Build phases: SUBMITTED, QUEUED, PROVISIONING, DOWNLOAD_SOURCE, INSTALL, PRE_BUILD, BUILD, POST_BUILD, UPLOAD_ARTIFACTS, FINALIZING
- Privileged mode: Required for Docker builds -- check
privilegedMode in environment config
- Compute types: BUILD_GENERAL1_SMALL, MEDIUM, LARGE, 2XLARGE -- affects cost and build speed
- Source credentials: Shared across projects per server type -- changing affects all projects
- Cache: Check
cache.type (NO_CACHE, S3, LOCAL) -- caching significantly impacts build times
1---2name: managing-aws-codebuild3description: |4 Use when working with Aws Codebuild — aWS CodeBuild project management and5 build analysis. Covers build project inventory, build history, build phase6 details, environment configurations, source credentials, report groups, and7 build metrics. Use when inspecting build projects, debugging build failures,8 reviewing build environments, or analyzing build performance.9connection_type: aws10preload: false11metadata:12 source: https://skillmd.com/skills/cloudthinker-ai/managing-aws-codebuild13---1415# AWS CodeBuild Management Skill1617Analyze and manage AWS CodeBuild projects, builds, and build environments.1819## MANDATORY: Discovery-First Pattern2021**Always list projects before querying specific resources.**2223### Phase 1: Discovery2425```bash26#!/bin/bash27export AWS_PAGER=""2829echo "=== CodeBuild Projects ==="30PROJECT_NAMES=$(aws codebuild list-projects --output text --query 'projects[]')3132echo ""33echo "=== Project Details ==="34if [ -n "$PROJECT_NAMES" ]; then35 aws codebuild batch-get-projects --names $PROJECT_NAMES --output text \36 --query 'projects[].[name,source.type,environment.computeType,environment.image,lastModified]' | head -3037fi3839echo ""40echo "=== Source Credentials ==="41aws codebuild list-source-credentials --output text \42 --query 'sourceCredentialsInfos[].[serverType,authType,arn]' 2>/dev/null4344echo ""45echo "=== Report Groups ==="46aws codebuild list-report-groups --output text \47 --query 'reportGroups[]' 2>/dev/null | head -1048```4950### Phase 2: Analysis5152```bash53#!/bin/bash54export AWS_PAGER=""5556echo "=== Recent Builds ==="57BUILD_IDS=$(aws codebuild list-builds --max-items 20 --output text --query 'ids[]')58if [ -n "$BUILD_IDS" ]; then59 aws codebuild batch-get-builds --ids $BUILD_IDS --output text \60 --query 'builds[].[projectName,buildNumber,buildStatus,startTime,endTime,sourceVersion]' | head -2061fi6263echo ""64echo "=== Failed Builds (last 20) ==="65if [ -n "$BUILD_IDS" ]; then66 aws codebuild batch-get-builds --ids $BUILD_IDS --output text \67 --query "builds[?buildStatus=='FAILED'].[projectName,buildNumber,buildStatus,phases[-1].phaseType,phases[-1].phaseStatus]"68fi6970echo ""71echo "=== Build Duration Analysis ==="72for project in $(aws codebuild list-projects --output text --query 'projects[]'); do73 {74 build_ids=$(aws codebuild list-builds-for-project --project-name "$project" --max-items 5 --output text --query 'ids[]')75 if [ -n "$build_ids" ]; then76 aws codebuild batch-get-builds --ids $build_ids --output text \77 --query "builds[].[projectName,buildNumber,buildStatus]" | head -578 fi79 } &80done81wait8283echo ""84echo "=== Build Environment Summary ==="85PROJECT_NAMES=$(aws codebuild list-projects --output text --query 'projects[]')86if [ -n "$PROJECT_NAMES" ]; then87 aws codebuild batch-get-projects --names $PROJECT_NAMES --output text \88 --query 'projects[].[name,environment.computeType,environment.type,environment.privilegedMode]' | head -2089fi90```9192## Output Format9394- Target ≤50 lines per output95- Use `--output text --query` and `batch-get-*` APIs for efficiency96- Tab-delimited fields: ProjectName, BuildNumber, Status, Duration97- Use batch APIs instead of individual describe calls98- Never dump full buildspec -- show source type and environment only99100## Anti-Hallucination Rules1011021. **NEVER assume resource names** — always discover via CLI/API in Phase 1 before referencing in Phase 2.1032. **NEVER fabricate metric names or dimensions** — verify against the service documentation or `--help` output.1043. **NEVER mix CLI commands between service versions** — confirm which version/API you are targeting.1054. **ALWAYS use the discovery → verify → analyze chain** — every resource referenced must have been discovered first.1065. **ALWAYS handle empty results gracefully** — an empty response is valid data, not an error to retry.107108## Counter-Rationalizations109110| Shortcut | Counter | Why |111|----------|---------|-----|112| "I'll skip discovery and check known resources" | Always run Phase 1 discovery first | Resource names change, new resources appear — assumed names cause errors |113| "The user only asked for a quick check" | Follow the full discovery → analysis flow | Quick checks miss critical issues; structured analysis catches silent failures |114| "Default configuration is probably fine" | Audit configuration explicitly | Defaults often leave logging, security, and optimization features disabled |115| "Metrics aren't needed for this" | Always check relevant metrics when available | API/CLI responses show current state; metrics reveal trends and intermittent issues |116| "I don't have access to that" | Try the command and report the actual error | Assumed permission failures prevent useful investigation; actual errors are informative |117118## Common Pitfalls119120- **Build status values**: SUCCEEDED, FAILED, FAULT, TIMED_OUT, IN_PROGRESS, STOPPED121- **Batch APIs**: Always use `batch-get-projects` and `batch-get-builds` instead of individual calls122- **Build phases**: SUBMITTED, QUEUED, PROVISIONING, DOWNLOAD_SOURCE, INSTALL, PRE_BUILD, BUILD, POST_BUILD, UPLOAD_ARTIFACTS, FINALIZING123- **Privileged mode**: Required for Docker builds -- check `privilegedMode` in environment config124- **Compute types**: BUILD_GENERAL1_SMALL, MEDIUM, LARGE, 2XLARGE -- affects cost and build speed125- **Source credentials**: Shared across projects per server type -- changing affects all projects126- **Cache**: Check `cache.type` (NO_CACHE, S3, LOCAL) -- caching significantly impacts build times