# Connect Github Repo

> Quickly connect a session to a GitHub repo using gh device login (no PAT). Use when the user asks to connect, clone, or work with a specific GitHub repo in this session only, possibly with a different GitHub account.

- Skill: `darikzen/connect-github-repo` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add darikzen/connect-github-repo`
- Raw SKILL.md: https://api.skillmd.com/api/skills/darikzen/connect-github-repo/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Darikzen (https://skillmd.com/u/darikzen)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/darikzen/connect-github-repo

---


# 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)

1. Parse the repo from the user's URL or `owner/repo` slug.
2. Run the connect script (no PAT, device login only if needed):

```bash
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).

3. 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)
4. After they confirm, re-run the script or verify with `gh auth status` and `git push --dry-run origin HEAD`.
5. Do **not** modify repo files unless the user asks.

## Switching GitHub accounts mid-session

```bash
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 `repositoryDependencies` unless the user explicitly asks for long-term setup

## Verify success

```bash
gh auth status -h github.com
git remote -v
git push --dry-run origin HEAD
```

Report: connected account, repo slug, push access yes/no.

