Connect GitHub Repo (Session-Only)
Use when the user asks to connect to a GitHub repo for this session only, possibly with a different GitHub account than other sessions. Do not explore auth paths first — run the script immediately.
Fast path (do this first)
- Parse the repo from the user's URL or
owner/reposlug. - Run the connect script (no PAT, device login only if needed):
bash "$HOME/.cursor/skills/my-cursor-skills/connect-github-repo/scripts/connect.sh" "<owner/repo-or-url>" "<workspace-root>"
Use the current workspace directory for <workspace-root> (often /workspace in Cloud Agents, or the project root locally).
- If device login is required, tell the user immediately in your first reply:
- Link: https://github.com/login/device
- The one-time code printed by the script
- Which GitHub account to sign in as (if they named one)
- After they confirm, re-run the script or verify with
gh auth statusandgit push --dry-run origin HEAD. - Do not modify repo files unless the user asks.
Switching GitHub accounts mid-session
gh auth logout -h github.com
bash "$HOME/.cursor/skills/connect-github-repo/scripts/connect.sh" "<repo>" "<workspace-root>"
Each Cloud Agent session is a fresh VM — credentials do not persist across runs. Local sessions persist until logout.
Why not Cursor long-term GitHub integration?
Cursor's managed GitHub token only applies when an agent is started from a connected repo. For ad-hoc "work on this repo this session" requests (especially with varying accounts), gh device login is the right tool: no PAT, no dashboard setup, ~30 seconds of user action.
Do not waste time on
- Searching for GitHub tokens in environment variables (there aren't any for github.com in New Project sessions)
- Probing the Cursor agent socket for GitHub credentials
- Editing README or other repo files during connect
- Setting up Cloud Agent environments or
repositoryDependenciesunless the user explicitly asks for long-term setup
Verify success
gh auth status -h github.com
git remote -v
git push --dry-run origin HEAD
Report: connected account, repo slug, push access yes/no.