Basic Commands
GitHub Labels CLI offers a set of simple commands to help you manage labels in your GitHub repositories.
Command Overview
| Command | Description |
|---|---|
pnpm dev | Run in interactive mode (default) |
pnpm dev add-labels | Add predefined labels to a repository |
pnpm dev get-labels | Get all labels from a repository in JSON |
pnpm dev remove-labels | Remove labels from a repository |
pnpm dev suggest-labels | Analyze a pull request and suggest labels |
pnpm dev suggest-issue-labels | Analyze an issue and suggest labels |
pnpm dev help | Display help information |
Interactive Mode
Running the CLI without any specific command will start the interactive mode:
pnpm devIn interactive mode, you'll be guided through a series of prompts to:
- Enter your GitHub token (if not already provided)
- Select a command to execute
- Select a repository to work with
- Choose specific labels or options depending on the command
Adding Labels
To add predefined labels to a repository:
pnpm dev add-labelsThis command will:
- Prompt for your GitHub token (if not already provided)
- Display a list of your repositories for selection
- If multiple label templates are available in the
src/labelsdirectory, prompt you to select a template - Show the available labels from the selected template for you to choose from
- Add the selected labels to the chosen repository
The default label template is located at src/labels/default.json, but you can use labels from repositories you've previously exported with the get-labels command.
Getting Labels
To retrieve all labels from a repository in JSON format:
pnpm dev get-labelsThis command will:
- Prompt for your GitHub token (if not already provided)
- Display a list of your repositories for selection
- Fetch all labels from the selected repository
- Save the labels to a JSON file in the
src/labelsdirectory, named after the repository (e.g.,src/labels/owner-repo.json)
The output file will contain all labels with their names, colors, and descriptions in JSON format. These saved labels can then be used as templates when adding labels to other repositories.
Removing Labels
To remove labels from a repository:
pnpm dev remove-labelsThis command will:
- Prompt for your GitHub token (if not already provided)
- Display a list of your repositories for selection
- Fetch all labels from the selected repository
- Display a checklist of labels for you to select which ones to remove
- Remove the selected labels from the repository
This is useful for cleaning up repositories by removing outdated, duplicate, or unwanted labels.
Suggesting Labels with AI
For Pull Requests
To analyze a pull request and get AI-powered label suggestions:
pnpm dev suggest-labelsThis command will:
- Prompt for your GitHub token (if not already provided)
- Require your OpenAI API key from the
OPENAI_API_KEYenvironment variable - Display a list of your repositories for selection
- Fetch open pull requests from the selected repository
- Let you choose a pull request to analyze
- Analyze the pull request content, including title, description, and changed files
- Generate label suggestions with confidence scores and explanations
- Generate comprehensive descriptions in English and Polish
- Let you choose whether to apply the suggested labels and/or description
Command Options:
# Apply only labels
pnpm dev suggest-labels --labels-only
# Apply only description
pnpm dev suggest-labels --description-only
# Skip labels
pnpm dev suggest-labels --no-labels
# Skip description
pnpm dev suggest-labels --no-descriptionFor Issues
To analyze an issue and get AI-powered label suggestions:
pnpm dev suggest-issue-labelsThis command will:
- Prompt for your GitHub token (if not already provided)
- Require your OpenAI API key from the
OPENAI_API_KEYenvironment variable - Display a list of your repositories for selection
- Fetch open issues from the selected repository
- Let you choose an issue to analyze
- Analyze the issue content, including title, description, and metadata
- Classify the issue type (bug, feature request, question, etc.)
- Generate label suggestions with confidence scores and explanations
- Generate comprehensive descriptions in English and Polish
- Let you choose whether to apply the suggested labels and/or description
Command Options:
# Apply only labels
pnpm dev suggest-issue-labels --labels-only
# Apply only description
pnpm dev suggest-issue-labels --description-only
# Skip labels
pnpm dev suggest-issue-labels --no-labels
# Skip description
pnpm dev suggest-issue-labels --no-descriptionBenefits
These AI-powered features use OpenAI's API to intelligently analyze pull requests and issues, making it easier to:
- Keep repositories organized without manually reviewing each item
- Maintain consistent labeling across your project
- Generate comprehensive, well-formatted descriptions
- Save time on documentation and categorization
- Ensure important changes and issues are properly documented
Creating Custom Label Templates
You can create your own label templates to use with the CLI:
- Create a JSON file in the
src/labels/directory with a descriptive name (e.g.,my-project.json) - Structure your file as an array of label objects with the following format:
[
{
"name": "bug",
"color": "d73a4a",
"description": "Something isn't working"
},
{
"name": "feature",
"color": "0366d6",
"description": "New feature or request"
}
]Your custom template will automatically appear in the template selection list when you run the add-labels command.
Help
To display available commands and options:
pnpm dev helpThis shows a list of all available commands and their descriptions.