| name | repo |
| description | Clone or fork a GitHub repository with optional local setup, or open repository resources such as files, branches, issues, and settings in the browser. Use when the user wants a new local checkout or the web UI, not a Codespace or an existing pull-request checkout. |
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 it
browse [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/repo format or a full GitHub
URL, and detect the --fork flag.
-
Fork if requested:
gh repo fork <owner/repo> --clone
-
Clone the repository:
gh repo clone <owner/repo>
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.json | npm install or yarn or pnpm install |
composer.json | composer install |
requirements.txt | pip install -r requirements.txt |
Gemfile | bundle install |
go.mod | go mod download |
Cargo.toml | cargo build |
Report the detected command first. Run it only after explicit user approval.
Respect --no-deps without 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, or make 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
gh browse <number>
gh browse <file>
gh browse --branch <name>
gh browse --settings
gh browse --releases
Actions runs: list first, then open a selected run:
gh run list --limit 20
gh run view <run_id> --web
-
Report 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