Skip to content

workspace: bootstrap main first on empty repos#91

Merged
jbragg merged 3 commits into
mainfrom
workspace-empty-repo-bootstrap
Jul 17, 2026
Merged

workspace: bootstrap main first on empty repos#91
jbragg merged 3 commits into
mainfrom
workspace-empty-repo-bootstrap

Conversation

@gas2own

@gas2own gas2own commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Why

While scaffolding a Quarto project into a brand-new empty repo, the workspace skill's headless-save flow pushed the scaffold to a feature branch first. On an uninitialized repo, GitHub makes the first pushed branch the default branch — so the feature branch wrongly became the default, and there was no main to open the scaffold PR against. The run got stuck: it couldn't follow the normal branch→PR flow, and flipping the default branch back to main afterward needs Admin.

Fix

Add an explicit empty-repo bootstrap step to the workspace skill's Save section: before the first save, detect whether the repo has a main yet (git ls-remote --heads origin main), and if not, establish the default branch before proceeding.

The step now offers two paths, preferred first:

  • Preferred — create the repo with an initial commit (GitHub UI "Add a README file" checkbox, or gh repo create --add-readme) so main exists from the start. This is the most robust path and works for every agent regardless of harness restrictions on pushing to a default branch — no seed push is ever needed. When guiding a user, the agent can point them at this.
  • Fallback — seed main directly (git push -u origin HEAD:main) if the repo already exists empty and can't be recreated. Seeding main on an empty repo is a legitimate direct push (no prior state to review-gate).

Subsequent iterations use the existing feature-branch + PR flow unchanged. This makes the skill robust to the empty-repo case so the wrong-default-branch state can't recur, and gives agents a harness-agnostic recommendation to hand users.

🤖 Generated with Claude Code

…w has a base branch

On a brand-new repo, GitHub makes the first pushed branch the default. Pushing
the scaffold to a feature branch first made that the default branch and left no
main to open the scaffold PR against. Instruct the skill to detect an
uninitialized repo and seed main directly before using the feature-branch+PR
flow.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gas2own added a commit that referenced this pull request Jul 16, 2026
…ct URL on private repos)

Two latent bugs in the reusable Quarto deploy workflow made a freshly
scaffolded repo's first PR look broken (red deploy check, no/wrong preview
link) even when the site published fine:

1. The preview-comment gh api read was unguarded under set -e; a transient
   5xx HTML body breaks --jq and abORTS the deploy after publish. Now the
   block runs under set +e and closes on a guaranteed-success command.
2. The preview URL was hardcoded to <owner>.github.io/<repo>, dead on
   private/internal repos that serve from an obfuscated *.pages.github.io
   domain. Now resolved from the Pages API with fallback; deploy job and
   scaffold docs.yml template grant pages: read.

Supersedes #91, #92, #93.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gas2own and others added 2 commits July 17, 2026 01:25
Make repo-created-with-initial-commit the preferred empty-repo bootstrap
path, with direct seed-to-main as a fallback. Creating the repo with a
README (GitHub UI checkbox or gh repo create --add-readme) means main
exists from the start, needs no seed push, and works for every agent
regardless of harness restrictions on pushing to a default branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collapse the ~6-line bootstrap block into two terse bullets matching the
file's house style — keep the check, the preferred create-with-README path,
and the seed fallback; drop the repeated review-gate justification and the
harness-specific parenthetical.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jbragg
jbragg merged commit 3aa711c into main Jul 17, 2026
7 checks passed
@jbragg
jbragg deleted the workspace-empty-repo-bootstrap branch July 17, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants