# gh label create: Create Issue Labels in CI

> gh label create adds a label with a color and description, idempotently with --force. Reference for --color, --force, and the already-exists errors in CI.

Source: https://latchkey.dev/learn/command-reference/gh-label-create  
Updated: 2026-06-30

gh label create adds a new issue or pull request label with an optional color and description.

Repo bootstrap and triage automation create the labels they rely on; --force makes the step safe to re-run.

## What it does

gh label create adds a label to the repository. You set the name, an optional hex --color, and a --description. --force updates the label if it already exists instead of failing, making the command idempotent.

## Common usage

```Terminal
gh label create bug --color FF0000 --description "Something is broken"
gh label create needs-review --color "#0E8A16"
gh label create release --color B60205 --force
```

## Flags

| Flag | What it does |
| --- | --- |
| -c, --color <hex> | Label color as a hex code (with or without #) |
| -d, --description <text> | Label description |
| -f, --force | Update the label if it already exists |
| -R, --repo <owner/repo> | Target a specific repository |

## In CI

Set GH_TOKEN and permissions: { issues: write }. Use --force in bootstrap scripts so re-running the job does not error on labels that already exist. Color accepts a bare hex like FF0000 or a quoted #-prefixed value.

## Common errors in CI

"HTTP 422: Validation Failed (label already exists)" means the label is present; add --force to update instead. "Resource not accessible by integration" means the token lacks issues: write. An invalid color string also raises an HTTP 422 validation error.

## Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

```.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### gh label create: Create Issue Labels in CI?

Repo bootstrap and triage automation create the labels they rely on; --force makes the step safe to re-run.

### What it does?

gh label create adds a label to the repository. You set the name, an optional hex --color, and a --description. --force updates the label if it already exists instead of failing, making the command idempotent.

### In CI?

Set GH_TOKEN and permissions: { issues: write }. Use --force in bootstrap scripts so re-running the job does not error on labels that already exist. Color accepts a bare hex like FF0000 or a quoted #-prefixed value.

### Common errors in CI?

"HTTP 422: Validation Failed (label already exists)" means the label is present; add --force to update instead. "Resource not accessible by integration" means the token lacks issues: write. An invalid color string also raises an HTTP 422 validation error.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
