Empty repo bundle preflight

From ychampion/cskill-agents · View interactive version

Empty repo bundle preflight is an AI agent skill from the GitHub repository ychampion/cskill-agents. Fail fast when the repository has no refs so downstream bundling never triggers empty Git bundles.

How to use this skill

Skill file

SKILL: Empty Repo Bundle Preflight

Domain: safety-worktrees

Trigger: Apply before running git bundle create to ensure the repository actually has refs, avoiding the 128 exit code and providing a clearer error path.

Source Pattern: Distilled from reviewed repo-safety, packaging, and worktree-management patterns.

Core Method

Run git for-each-ref --count=1 refs/ from the repository root; if the output is empty, report that the repo has no commits, record an analytics metric with the empty_repo outcome, and abort with a helpful message instead of invoking git bundle create, which would exit 128 on an empty repo. Sweep stale temporary refs first so the check reflects the true repo state, and treat the empty case as a known failure reason with a dedicated fail reason identifier that consumers can react to.

Key Rules

Example Application

When building a git bundle upload helper, call this skill before _bundleWithFallback; if it signals an empty repo, stop and surface “Repository has no commits yet” to the UI and telemetry instead of letting git bundle create crash.

Anti-Patterns (What NOT to do)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.