Skip to content
Proud to collaborate with Microsoft for Startups

github.code.delete_branch ​

Delete a branch from a GitHub repository

Delete a branch from a GitHub repository.

Inputs:

  • owner: Repository owner (required).
  • repo: Repository name (required).
  • branch_name: Branch to delete (required).
  • expected_sha: Current branch tip SHA guard (optional).
  • dry_run: Plan without mutating GitHub (optional, default: false).
  • default_branch: Known default branch name (optional). Only a hint: a match refuses without a metadata read; a mismatch is verified against GitHub.
  • allow_default_branch_delete: Permit deleting the default branch (optional, default: false). Founder/human-only; never set it from a Staff or agent tool binding.

Outputs (terminal state_data):

  • status: planned | deleted | not_found
  • applied: bool
  • branch_name: str
  • ref: Full branch ref
  • sha: SHA the branch pointed at before deletion

Compensation: Use github.code.create_branch with the captured sha to restore the ref. Plugin required: context.get_plugin("github") must expose a GitHub App installation.

Overview ​

PropertyValue
Workflow typeAtomic
LibraryApp-github
Version1.0

Input Schema ​

FieldTypeRequiredDefaultDescription
ownerstringYes—Repository owner
repostringYes—Repository name
branch_namestringYes—Branch to delete
expected_shastringNo—Expected current branch tip SHA
dry_runbooleanNo—Plan without mutating GitHub
default_branchstringNo—Known repository default branch (hint; never trusted to allow a delete)
allow_default_branch_deletebooleanNo—Allow deleting the default branch. Founder/human-only override, default false. Never set from Staff or agent tool bindings, and never map it from caller input in a composition.

Output Schema ​

FieldTypeRequiredDefaultDescription
statusstringNo——
appliedbooleanNo——
dry_runbooleanNo——
branch_namestringNo——
refstringNo——
shastringNo——
default_branchstringNo——
allow_default_branch_deletebooleanNo——
expected_shastringNo——
ownerstringNo——
repostringNo——
failure_reasonstringNo——
failure_typestringNo——
failed_actionstringNo——
failed_at_statestringNo——
failed_stepstringNo——
failed_layerstringNo——
errorstringNo——
error_typestringNo——

States ​

StateInitialTerminalSuccessAuto-advanceDescription
pendingYesNo—execute—
completedNoYesYes——
failedNoYesNo——

State Diagram ​

Transitions ​

FromActionToDescription
pendingexecutecompleted—
* (any state)failfailed—

API Usage ​

bash
POST /api/workflows/start
Content-Type: application/json

{
  "workflow_type": "github.code.delete_branch",
  "initial_data": {
    "owner": "value",
    "repo": "value",
    "branch_name": "value"
  }
}