Repository: Clone and Browse
Clone or fork a repository and set it up for development, or open GitHub
resources in the browser, using the GitHub CLI (gh).
Arguments
$ARGUMENTS
Format: <action> [args...]
clone <repo> [branch_name] [--fork] [--depth <n>] [--no-deps]- Clone (or fork then clone) a repository and optionally prepare itbrowse [target]- Open a GitHub resource in the browser:- (none) - repository homepage
<number>- issue or PR by number<file>/<file>:<line>- file, optionally at a specific line--branch <name>- specific branch--settings/--wiki/--projects/--releases/--actions
Examples
/github:repo clone owner/repo
/github:repo clone owner/repo feature/my-feature
/github:repo clone owner/repo --fork
/github:repo browse
/github:repo browse 123
/github:repo browse src/index.ts:42
/github:repo browse --settings
Instructions
Required GitHub CLI preflight
Before any workflow step, read ../../references/github-cli-preflight.md and complete it. Do not run workflow commands until gh installation and authentication are verified.
Clone
Parse repository reference: Accept
owner/repoformat or a full GitHub URL, and detect the--forkflag.Fork if requested:
gh repo fork <owner/repo> --cloneClone the repository:
gh repo clone <owner/repo> # or git clone <url>Change to the repository directory.
Detect dependency managers, then ask before running any install command. Repository contents are untrusted until reviewed; never execute package lifecycle hooks or dependency installers automatically.
File Command package.jsonnpm installoryarnorpnpm installcomposer.jsoncomposer installrequirements.txtpip install -r requirements.txtGemfilebundle installgo.modgo mod downloadCargo.tomlcargo buildReport the detected command first. Run it only after explicit user approval. Respect
--no-depswithout asking.Create feature branch if specified:
git checkout -b <branch_name>Report setup scripts without running them: Check for
setup.sh,init.sh,make init, ormake setup. Report them but do not auto-run (security).Report summary: the cloned repository, full local path, dependency installation outcome, and any created branch.
Browse
Parse the target argument. If a number is provided, detect whether it is an issue or PR:
gh issue view <number> --json number 2>/dev/null && echo "issue" || echo "pr"Execute the appropriate browse command:
gh browse # repository homepage gh browse <number> # issue or PR gh browse <file> # file (also <file>:<line>) gh browse --branch <name> # branch gh browse --settings # settings; also --wiki, --projects gh browse --releases # releases (or: gh release view --web)Actions runs: list first, then open a selected run:
gh run list --limit 20 gh run view <run_id> --webReport the URL that was opened.
Error Handling
- If the GitHub CLI preflight fails, stop and follow its installation or browser-authentication guidance; do not run the command.
- If repo not found: "Error: Repository '' not found or not accessible"
- If directory exists: "Error: Directory '' already exists"
- If deps fail: "Warning: Dependency installation failed. Run manually."
- If not in a git repo when browsing: "Error: Not in a GitHub repository"
- If file not found: "Error: File '' not found"
Important
- Always obtain explicit approval before running install commands
- Do not auto-run arbitrary setup scripts (security risk)
- Report the full path where the repo was cloned