npm package: @oh-gc/cli
Description: GitCode CLI — manage issues and PRs from the terminal
Author: guozejun
Latest version: 0.7.4

# oh-gc — GitCode CLI

A command-line interface for [GitCode](https://gitcode.com), modeled after GitHub CLI (`gh`). Manage issues, pull requests, and authentication without leaving the terminal.

```
oh-gc issue list
oh-gc issue view 12
oh-gc pr create --title "Fix login bug" --base main
oh-gc pr merge 5 --method squash
```

---

## Installation

### npm (Recommended)

```bash
npm install -g @oh-gc/cli
oh-gc --help
```

### From Source

```bash
git clone https://gitcode.com/guozejun/ohos_gitcode_cli.git
cd ohos_gitcode_cli
npm install
npm run build
npm link
```

---

## AI Skill

`oh-gc` ships with a skill file that teaches AI assistants (Claude Code, OpenCode) how to use the CLI.

### Claude Code

Two commands to install:

```
/plugin marketplace add https://gitcode.com/guozejun/ohos_gitcode_cli.git
/plugin install gitcode-cli@oh-gc
```

To update to the latest version:

```
/plugin marketplace update oh-gc
```

### OpenCode

Tell OpenCode:

```
Fetch and follow instructions from https://raw.gitcode.com/guozejun/ohos_gitcode_cli/raw/master/skills/gitcode-cli/INSTALL.md
```

---

## Quick Start

**1. Log in with your GitCode personal access token:**

```bash
oh-gc auth login
# Enter your GitCode personal access token: ••••••••••
# Logged in as yourname (Your Name)
```

Get a token at: **GitCode → Settings → Access Tokens**

**2. Navigate to a GitCode repository:**

```bash
cd your-project   # must be a git repo with a gitcode.com remote
oh-gc issue list
```

If your remote is not named `origin`, configure it:

```bash
oh-gc repo set-remote upstream
```

---

## Command Index

### Authentication

| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc auth login` | Log in with a personal access token | [→ Details](docs/commands/en/auth.md#oh-gc-auth-login) |
| `oh-gc auth logout` | Remove stored token | [→ Details](docs/commands/en/auth.md#oh-gc-auth-logout) |
| `oh-gc auth status` | Show currently logged-in user | [→ Details](docs/commands/en/auth.md#oh-gc-auth-status) |

### Issues
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc issue list` | List issues | [→ Details](docs/commands/en/issue.md#oh-gc-issue-list) |
| `oh-gc issue view` | View issue details | [→ Details](docs/commands/en/issue.md#oh-gc-issue-view) |
| `oh-gc issue create` | Create an issue | [→ Details](docs/commands/en/issue.md#oh-gc-issue-create) |
| `oh-gc issue update` | Update an issue | [→ Details](docs/commands/en/issue.md#oh-gc-issue-update) |
| `oh-gc issue close` | Close an issue | [→ Details](docs/commands/en/issue.md#oh-gc-issue-close) |
| `oh-gc issue reopen` | Reopen a closed issue | [→ Details](docs/commands/en/issue.md#oh-gc-issue-reopen) |
| `oh-gc issue comment` | Add a comment | [→ Details](docs/commands/en/issue.md#oh-gc-issue-comment) |
| `oh-gc issue history` | View modification history | [→ Details](docs/commands/en/issue.md#oh-gc-issue-history) |
| `oh-gc issue labels` | Add or remove labels | [→ Details](docs/commands/en/issue.md#oh-gc-issue-labels) |
| `oh-gc issue reactions` | List reactions | [→ Details](docs/commands/en/issue.md#oh-gc-issue-reactions) |
| `oh-gc issue prs` | List linked pull requests | [→ Details](docs/commands/en/issue.md#oh-gc-issue-prs) |
| `oh-gc issue branches` | List or set related branches | [→ Details](docs/commands/en/issue.md#oh-gc-issue-branches) |
| `oh-gc issue comment-get` | Get a comment | [→ Details](docs/commands/en/issue.md#oh-gc-issue-comment-get) |
| `oh-gc issue comment-edit` | Edit a comment | [→ Details](docs/commands/en/issue.md#oh-gc-issue-comment-edit) |
| `oh-gc issue comment-delete` | Delete a comment | [→ Details](docs/commands/en/issue.md#oh-gc-issue-comment-delete) |
| `oh-gc issue comment-history` | View comment history | [→ Details](docs/commands/en/issue.md#oh-gc-issue-comment-history) |
| `oh-gc issue comment-reactions` | View comment reactions | [→ Details](docs/commands/en/issue.md#oh-gc-issue-comment-reactions) |

### Pull Requests
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc pr list` | List pull requests | [→ Details](docs/commands/en/pr.md#oh-gc-pr-list) |
| `oh-gc pr view` | View PR details | [→ Details](docs/commands/en/pr.md#oh-gc-pr-view) |
| `oh-gc pr create` | Create a pull request | [→ Details](docs/commands/en/pr.md#oh-gc-pr-create) |
| `oh-gc pr update` | Update a pull request | [→ Details](docs/commands/en/pr.md#oh-gc-pr-update) |
| `oh-gc pr close` | Close a pull request | [→ Details](docs/commands/en/pr.md#oh-gc-pr-close) |
| `oh-gc pr reopen` | Reopen a closed PR | [→ Details](docs/commands/en/pr.md#oh-gc-pr-reopen) |
| `oh-gc pr merge` | Merge a pull request | [→ Details](docs/commands/en/pr.md#oh-gc-pr-merge) |
| `oh-gc pr diff` | View PR changes | [→ Details](docs/commands/en/pr.md#oh-gc-pr-diff) |
| `oh-gc pr comment` | Add a comment | [→ Details](docs/commands/en/pr.md#oh-gc-pr-comment) |
| `oh-gc pr comments` | List or delete comments | [→ Details](docs/commands/en/pr.md#oh-gc-pr-comments) |
| `oh-gc pr commits` | List commits in a PR | [→ Details](docs/commands/en/pr.md#oh-gc-pr-commits) |
| `oh-gc pr logs` | View operation logs | [→ Details](docs/commands/en/pr.md#oh-gc-pr-logs) |
| `oh-gc pr reactions` | List reactions | [→ Details](docs/commands/en/pr.md#oh-gc-pr-reactions) |
| `oh-gc pr reviewers` | Manage reviewers | [→ Details](docs/commands/en/pr.md#oh-gc-pr-reviewers) |
| `oh-gc pr testers` | Manage testers | [→ Details](docs/commands/en/pr.md#oh-gc-pr-testers) |
| `oh-gc pr review` | Approve a PR review | [→ Details](docs/commands/en/pr.md#oh-gc-pr-review) |
| `oh-gc pr test` | Mark test as passed | [→ Details](docs/commands/en/pr.md#oh-gc-pr-test) |
| `oh-gc pr labels` | Add or remove labels | [→ Details](docs/commands/en/pr.md#oh-gc-pr-labels) |
| `oh-gc pr link` | Link or unlink issues | [→ Details](docs/commands/en/pr.md#oh-gc-pr-link) |
| `oh-gc pr files` | List changed files | [→ Details](docs/commands/en/pr.md#oh-gc-pr-files) |
| `oh-gc pr history` | View modification history | [→ Details](docs/commands/en/pr.md#oh-gc-pr-history) |
| `oh-gc pr linked-issues` | List linked issues | [→ Details](docs/commands/en/pr.md#oh-gc-pr-linked-issues) |
| `oh-gc pr assignees` | Manage assignees | [→ Details](docs/commands/en/pr.md#oh-gc-pr-assignees) |
| `oh-gc pr settings` | View PR settings | [→ Details](docs/commands/en/pr.md#oh-gc-pr-settings) |
| `oh-gc pr settings-update` | Update PR settings | [→ Details](docs/commands/en/pr.md#oh-gc-pr-settings-update) |
| `oh-gc pr option-reviewers` | List eligible reviewers | [→ Details](docs/commands/en/pr.md#oh-gc-pr-option-reviewers) |
| `oh-gc pr comment-get` | Get a PR comment | [→ Details](docs/commands/en/pr.md#oh-gc-pr-comment-get) |
| `oh-gc pr comment-edit` | Edit a PR comment | [→ Details](docs/commands/en/pr.md#oh-gc-pr-comment-edit) |
| `oh-gc pr comment-delete` | Delete a PR comment | [→ Details](docs/commands/en/pr.md#oh-gc-pr-comment-delete) |
| `oh-gc pr comment-history` | View comment history | [→ Details](docs/commands/en/pr.md#oh-gc-pr-comment-history) |
| `oh-gc pr comment-reactions` | View comment reactions | [→ Details](docs/commands/en/pr.md#oh-gc-pr-comment-reactions) |

### Repository
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc repo list` | List repositories | [→ Details](docs/commands/en/repo.md#oh-gc-repo-list) |
| `oh-gc repo create` | Create a new repository | [→ Details](docs/commands/en/repo.md#oh-gc-repo-create) |
| `oh-gc repo delete` | Delete a repository | [→ Details](docs/commands/en/repo.md#oh-gc-repo-delete) |
| `oh-gc repo fork` | Fork a repository | [→ Details](docs/commands/en/repo.md#oh-gc-repo-fork) |
| `oh-gc repo forks` | List repository forks | [→ Details](docs/commands/en/repo.md#oh-gc-repo-forks) |
| `oh-gc repo settings` | View or update repo settings | [→ Details](docs/commands/en/repo.md#oh-gc-repo-settings) |
| `oh-gc repo languages` | Show languages used in a repo | [→ Details](docs/commands/en/repo.md#oh-gc-repo-languages) |
| `oh-gc repo contributors` | List contributors | [→ Details](docs/commands/en/repo.md#oh-gc-repo-contributors) |
| `oh-gc repo events` | List repository events | [→ Details](docs/commands/en/repo.md#oh-gc-repo-events) |
| `oh-gc repo stats` | Show commit/download statistics | [→ Details](docs/commands/en/repo.md#oh-gc-repo-stats) |
| `oh-gc repo archive` | Archive or unarchive a repository | [→ Details](docs/commands/en/repo.md#oh-gc-repo-archive) |
| `oh-gc repo transition` | View or update permission mode | [→ Details](docs/commands/en/repo.md#oh-gc-repo-transition) |
| `oh-gc repo module` | Enable or disable repo modules | [→ Details](docs/commands/en/repo.md#oh-gc-repo-module) |
| `oh-gc repo roles` | List customized roles | [→ Details](docs/commands/en/repo.md#oh-gc-repo-roles) |
| `oh-gc repo view` | View repository info | [→ Details](docs/commands/en/repo.md#oh-gc-repo-view) |
| `oh-gc repo update` | Update repository settings | [→ Details](docs/commands/en/repo.md#oh-gc-repo-update) |
| `oh-gc repo transfer` | Transfer repository ownership | [→ Details](docs/commands/en/repo.md#oh-gc-repo-transfer) |
| `oh-gc repo set-remote` | Set which remote oh-gc uses | [→ Details](docs/commands/en/repo.md#oh-gc-repo-set-remote) |
| `oh-gc repo get-remote` | Show current remote | [→ Details](docs/commands/en/repo.md#oh-gc-repo-get-remote) |

### Branches
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc branch list` | List branches | [→ Details](docs/commands/en/branch.md#oh-gc-branch-list) |
| `oh-gc branch get` | View branch details | [→ Details](docs/commands/en/branch.md#oh-gc-branch-get) |
| `oh-gc branch create` | Create a branch | [→ Details](docs/commands/en/branch.md#oh-gc-branch-create) |
| `oh-gc branch delete` | Delete a branch | [→ Details](docs/commands/en/branch.md#oh-gc-branch-delete) |
| `oh-gc branch protect` | Set branch protection | [→ Details](docs/commands/en/branch.md#oh-gc-branch-protect) |
| `oh-gc branch protect-rules` | List protection rules | [→ Details](docs/commands/en/branch.md#oh-gc-branch-protect-rules) |
| `oh-gc branch protect-rule-create` | Create protection rule | [→ Details](docs/commands/en/branch.md#oh-gc-branch-protect-rule-create) |
| `oh-gc branch protect-rule-update` | Update protection rule | [→ Details](docs/commands/en/branch.md#oh-gc-branch-protect-rule-update) |
| `oh-gc branch protect-rule-delete` | Delete protection rule | [→ Details](docs/commands/en/branch.md#oh-gc-branch-protect-rule-delete) |

### Commits
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc commit list` | List commits | [→ Details](docs/commands/en/commit.md#oh-gc-commit-list) |
| `oh-gc commit get` | View commit details | [→ Details](docs/commands/en/commit.md#oh-gc-commit-get) |
| `oh-gc commit diff` | View commit diff | [→ Details](docs/commands/en/commit.md#oh-gc-commit-diff) |
| `oh-gc commit compare` | Compare two refs | [→ Details](docs/commands/en/commit.md#oh-gc-commit-compare) |
| `oh-gc commit comments` | List commit comments | [→ Details](docs/commands/en/commit.md#oh-gc-commit-comments) |
| `oh-gc commit comment` | Create a commit comment | [→ Details](docs/commands/en/commit.md#oh-gc-commit-comment) |

### Files
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc file get` | Get file contents (base64) | [→ Details](docs/commands/en/file.md#oh-gc-file-get) |
| `oh-gc file raw` | Get raw file contents | [→ Details](docs/commands/en/file.md#oh-gc-file-raw) |
| `oh-gc file list` | List directory contents | [→ Details](docs/commands/en/file.md#oh-gc-file-list) |
| `oh-gc file create` | Create a file | [→ Details](docs/commands/en/file.md#oh-gc-file-create) |
| `oh-gc file update` | Update a file | [→ Details](docs/commands/en/file.md#oh-gc-file-update) |
| `oh-gc file delete` | Delete a file | [→ Details](docs/commands/en/file.md#oh-gc-file-delete) |

### Labels
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc label list` | List repository labels | [→ Details](docs/commands/en/label.md#oh-gc-label-list) |
| `oh-gc label create` | Create a label | [→ Details](docs/commands/en/label.md#oh-gc-label-create) |
| `oh-gc label update` | Update a label | [→ Details](docs/commands/en/label.md#oh-gc-label-update) |
| `oh-gc label delete` | Delete a label | [→ Details](docs/commands/en/label.md#oh-gc-label-delete) |

### Milestones
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc milestone list` | List milestones | [→ Details](docs/commands/en/milestone.md#oh-gc-milestone-list) |
| `oh-gc milestone get` | View milestone details | [→ Details](docs/commands/en/milestone.md#oh-gc-milestone-get) |
| `oh-gc milestone create` | Create a milestone | [→ Details](docs/commands/en/milestone.md#oh-gc-milestone-create) |
| `oh-gc milestone update` | Update a milestone | [→ Details](docs/commands/en/milestone.md#oh-gc-milestone-update) |
| `oh-gc milestone delete` | Delete a milestone | [→ Details](docs/commands/en/milestone.md#oh-gc-milestone-delete) |

### Collaborators
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc collaborator list` | List collaborators | [→ Details](docs/commands/en/collaborator.md#oh-gc-collaborator-list) |
| `oh-gc collaborator add` | Add a collaborator | [→ Details](docs/commands/en/collaborator.md#oh-gc-collaborator-add) |
| `oh-gc collaborator remove` | Remove a collaborator | [→ Details](docs/commands/en/collaborator.md#oh-gc-collaborator-remove) |
| `oh-gc collaborator permission` | Get permission level | [→ Details](docs/commands/en/collaborator.md#oh-gc-collaborator-permission) |

### Webhooks
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc hook list` | List webhooks | [→ Details](docs/commands/en/hook.md#oh-gc-hook-list) |
| `oh-gc hook get` | View webhook details | [→ Details](docs/commands/en/hook.md#oh-gc-hook-get) |
| `oh-gc hook create` | Create a webhook | [→ Details](docs/commands/en/hook.md#oh-gc-hook-create) |
| `oh-gc hook delete` | Delete a webhook | [→ Details](docs/commands/en/hook.md#oh-gc-hook-delete) |

### Tags
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc tag list` | List repository tags | [→ Details](docs/commands/en/tag.md#oh-gc-tag-list) |
| `oh-gc tag create` | Create a tag | [→ Details](docs/commands/en/tag.md#oh-gc-tag-create) |
| `oh-gc tag delete` | Delete a tag | [→ Details](docs/commands/en/tag.md#oh-gc-tag-delete) |
| `oh-gc tag protect` | Protect or unprotect a tag | [→ Details](docs/commands/en/tag.md#oh-gc-tag-protect) |
| `oh-gc tag protect-get` | Get protected tag details | [→ Details](docs/commands/en/tag.md#oh-gc-tag-protect-get) |
| `oh-gc tag protect-create` | Create protected tag rule | [→ Details](docs/commands/en/tag.md#oh-gc-tag-protect-create) |
| `oh-gc tag protect-update` | Update protected tag rule | [→ Details](docs/commands/en/tag.md#oh-gc-tag-protect-update) |
| `oh-gc tag protect-delete` | Delete protected tag rule | [→ Details](docs/commands/en/tag.md#oh-gc-tag-protect-delete) |

### Release
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc release create` | Create a release | [→ Details](docs/commands/en/release.md#oh-gc-release-create) |

### Organizations
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc org list` | List your organizations | [→ Details](docs/commands/en/org.md#oh-gc-org-list) |
| `oh-gc org view` | View organization details | [→ Details](docs/commands/en/org.md#oh-gc-org-view) |
| `oh-gc org members` | List organization members | [→ Details](docs/commands/en/org.md#oh-gc-org-members) |

### User
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc user view` | View user profile | [→ Details](docs/commands/en/user.md#oh-gc-user-view) |
| `oh-gc user edit` | Update your profile | [→ Details](docs/commands/en/user.md#oh-gc-user-edit) |
| `oh-gc user emails` | List your email addresses | [→ Details](docs/commands/en/user.md#oh-gc-user-emails) |
| `oh-gc user followers` | List user followers | [→ Details](docs/commands/en/user.md#oh-gc-user-followers) |
| `oh-gc user following` | List followed users | [→ Details](docs/commands/en/user.md#oh-gc-user-following) |
| `oh-gc user events` | List user activity events | [→ Details](docs/commands/en/user.md#oh-gc-user-events) |
| `oh-gc user search` | Search users | [→ Details](docs/commands/en/user.md#oh-gc-user-search) |
| `oh-gc user namespace` | Get namespace by path | [→ Details](docs/commands/en/user.md#oh-gc-user-namespace) |
| `oh-gc user namespaces` | List all namespaces | [→ Details](docs/commands/en/user.md#oh-gc-user-namespaces) |
| `oh-gc user keys` | List SSH keys | [→ Details](docs/commands/en/user.md#oh-gc-user-keys) |
| `oh-gc user key-add` | Add an SSH key | [→ Details](docs/commands/en/user.md#oh-gc-user-key-add) |
| `oh-gc user key-delete` | Delete an SSH key | [→ Details](docs/commands/en/user.md#oh-gc-user-key-delete) |
| `oh-gc user starred` | List starred repositories | [→ Details](docs/commands/en/user.md#oh-gc-user-starred) |
| `oh-gc user subscriptions` | List watched repositories | [→ Details](docs/commands/en/user.md#oh-gc-user-subscriptions) |
| `oh-gc user issues` | List your issues (all repos) | [→ Details](docs/commands/en/user.md#oh-gc-user-issues) |
| `oh-gc user prs` | List your PRs (all repos) | [→ Details](docs/commands/en/user.md#oh-gc-user-prs) |
| `oh-gc user orgs` | List user's organizations | [→ Details](docs/commands/en/user.md#oh-gc-user-orgs) |
| `oh-gc user membership` | View org membership | [→ Details](docs/commands/en/user.md#oh-gc-user-membership) |
| `oh-gc user leave-org` | Leave an organization | [→ Details](docs/commands/en/user.md#oh-gc-user-leave-org) |

### Search
| Command | Description | Docs |
|---------|-------------|------|
| `oh-gc search repos` | Search repositories | [→ Details](docs/commands/en/search.md#oh-gc-search-repos) |
| `oh-gc search issues` | Search issues and PRs | [→ Details](docs/commands/en/search.md#oh-gc-search-issues) |
| `oh-gc search code` | Search code | [→ Details](docs/commands/en/search.md#oh-gc-search-code) |

---

## Repository Flag

Most commands that operate on a repository support the `--repo` flag, which allows you to specify a target repository without being inside a git clone:

| Flag | Description |
|------|-------------|
| `--repo owner/repo` | Target repository in OWNER/REPO format |

Examples:
```bash
oh-gc issue list --repo openharmony/arkui_ace_engine
oh-gc issue create --repo owner/repo --title "Bug report"
oh-gc pr view 123 --repo owner/repo
```

## Global Flags

All commands support:

| Flag | Description |
|------|-------------|
| `--json` | Output raw JSON instead of formatted table |
| `--help` | Show command help |

---

## Configuration

### Token

Stored at `~/.config/gitcode-cli/config.json`. Set via `oh-gc auth login`, removed via `oh-gc auth logout`.

### Remote

By default `oh-gc` uses the `origin` remote. To use a different remote for run `oh-gc repo set-remote <name>`. This writes a `.gitcode/oh-gc-config.json` file in the repo root:

 ```json
{ "remote": "upstream" }
```

You can commit or gitignore the `.gitcode/` directory — `oh-gc` never modifies `.gitignore`.

### Proxy

`oh-gc` automatically picks up the standard `https_proxy` / `HTTPS_PROXY` environment variables. No extra configuration needed.

---

## Exit Codes

- `0` — success
- `1` — error (authentication failure, network error, invalid input, etc.)

---

## License

MIT