← Back to Pull requests

feat(builtins): add xcodebuild builtin formatted by xcbeautify #2009

Closed
unknown closed this pull request without merging on Dec 04, 2026 02:23 UTC
View on GitHub
unknown unknown commented on Dec 04, 2026 01:41 UTC
Author

Adds Builtins.xcodebuild, which builds or tests an Xcode scheme and formats the output with xcbeautify. Requested in https://github.com/jdx/hk/discussions/2008.

It is named for xcodebuild because xcbeautify only formats output piped into it.

["xcodebuild"] = (Builtins.xcodebuild) {
  scheme = "MyApp"
}

This runs xcodebuild -scheme 'MyApp' 'build' 2>&1 | xcbeautify when a Swift, C-family or Xcode project file is selected. A failed build fails the step (pipefail).

| Option | Default | Meaning |
| --- | --- | --- |
| scheme | none, required | scheme to build |
| action | "build" | for example "test" |
| destination | unset | value for -destination |
| extra_args | List() | more xcodebuild arguments, such as -workspace |
| xcbeautify_args | List() | arguments for xcbeautify |

  • Without scheme, the config still loads and hk validate accepts it; the step fails when it runs, with set scheme on Builtins.xcodebuild. A load-time error isn't possible today: hk's Pkl evaluator drops a command that reads an unset property, and raises a throw even when a config sets the property.

  • xcodebuild comes with Xcode, so the step needs macOS. hk init does not auto-detect this builtin, since it can't know the scheme.

  • The step needs bash.
  • Validation

    test/builtin_xcodebuild.bats covers option quoting, failure propagation and the missing-scheme error using stand-in xcodebuild and xcbeautify scripts. It has not been run against a real Xcode project or the real xcbeautify, so the builtin has no hk test cases.

    cargo test passes. Locally, "builtins tests run" has 11 failures in rubocop, rubocop_server, standard_rb and gh_actions_lock, which this change doesn't touch.

    AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: unavailable.

    🤖 Generated with Claude Code

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Low Risk

    Isolated new builtin, docs, and tests; no changes to auth, core runtime, or existing builtins beyond documentation.

    > Overview

    Adds Builtins.xcodebuild, a new hk step that runs xcodebuild for a configured scheme and pipes output through xcbeautify. scheme is mandatory at runtime (missing values fail with a clear error without breaking config load/validate). Options cover action, destination, extra_args, and xcbeautify_args; the command uses bash pipefail so build failures propagate, and globs target Swift/C-family and Xcode project files.

    > Documentation gains a “Builtins that need options” section (standard and pirate docs) explaining setup and macOS/Xcode requirements. test/builtin_xcodebuild.bats uses fake xcodebuild/xcbeautify to verify argument passing, exit codes, and the missing-scheme behavior.

    > <sup>Reviewed by Cursor Bugbot for commit d887770b1967748dfae0adfc01ab532dc05cae3c. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Documentation
    Documented the xcodebuild builtin, including its required scheme, configurable build options, and macOS requirement.
    Clarified when builds run and documented support for xcbeautify arguments.
    Tests
    Added coverage for build option handling, including argument order, error-code reporting, and behavior when a scheme is missing.
    Verified that a missing scheme does not produce beautified output.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 477 lines (+357 / -120) across 5 files Reviewer: jdx Review duration: 41m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.46) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 477 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.369
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2009"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.8% (MEDIUM) · Higher = larger blast radius
    45.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.8% · Safe to merge
    19.8%
    Repository