Labels.io
Agent skills

Set up GitHub backup

Use this when the user says "back up my project to GitHub", "set up GitHub", "I want a Git remote", or "I do not have version control yet". The goal: a private GitHub repo that mirrors the local project, with a clean first commit pushed.

Rules of engagement

  • Always confirm before pushing if the user has any existing .git history; do not force-overwrite.
  • Default to a private repo unless the user explicitly says public.
  • Never commit secrets — verify .env is in .gitignore before the first push.
  • Do not store the user's GitHub token; rely on gh auth login interactive flow.

1. Check the basics

Run these and read the output:

git --version
gh --version
gh auth status

If git is missing, point the user at git-scm.com/downloads. If gh is missing, install via brew install gh (macOS), winget install GitHub.cli (Windows), or follow cli.github.com. If gh auth status shows logged out, run gh auth login and walk the user through the interactive prompts (HTTPS, browser auth).

2. Verify .gitignore

Open .gitignore. Confirm it contains at least:

node_modules
.output
.tanstack
.vinxi
.nitro
.vite
dist
build
.env
.env.local
.env.*.local
.DS_Store
app/routeTree.gen.ts

If .env is missing, add it before any commit. If the project has any other secret files (API keys, certificates), add those too.

3. Initialize git and the first commit

If the project is not yet a git repo:

git init -b main
git add .
git status

Inspect git status output with the user. Confirm no .env or secret-looking files are staged. Then:

git commit -m "initial commit from vibecoder kit"

If the project already has commits, skip the init and proceed to step 4.

4. Create the GitHub repo and push

Ask the user for the repo name (default: the project folder name). Then:

gh repo create <repo-name> --private --source=. --remote=origin --push

This single command creates the private repo on GitHub, sets it as the origin remote, and pushes the local main branch. Confirm the resulting URL with the user.

If the user wants the repo public, swap --private for --public.

5. Verify

git remote -v
git branch -vv
gh repo view --web

The last command opens the repo in their browser. Confirm with the user that they see the project files there.

6. Tell the user the daily flow

Tell them:

Your project is backed up. From now on, when you make changes:

  • In your AI chat, say: "Save my changes to GitHub."
  • The AI will run git add, commit with a sensible message, and push.

If your laptop dies, you can clone the repo on a new machine and pick up where you left off.

When something fails

  • Push rejected (non-fast-forward): Someone or something already pushed to the remote. Ask the user, then git pull --rebase origin main and retry.
  • Authentication failed: Run gh auth status again. If still logged out, gh auth login.
  • .env accidentally committed before being added to .gitignore: This is a real problem (history leak). Tell the user to rotate any keys that were exposed, then ask if they want to use git filter-repo to scrub history. Do not run git filter-repo without explicit confirmation; it rewrites history.

On this page