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 format |
pnpm dev remove-labels | Remove labels from a repository |
pnpm dev suggest-labels | Analyze a pull request and suggest labels using AI |
pnpm dev help | Display help information |
Interactive Mode
Running the CLI without any specific command will start the interactive mode:
pnpm dev
In 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-labels
This 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/labels
directory, 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-labels
This 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/labels
directory, 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-labels
This 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
To analyze a pull request and get AI-powered label suggestions:
pnpm dev suggest-labels
This command will:
- Prompt for your GitHub token (if not already provided)
- Ask for your OpenAI API key if the
OPENAI_API_KEY
environment variable is not set - 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 based on the analysis, with confidence scores and explanations
- Let you choose whether to apply the suggested labels to the pull request
This feature uses OpenAI's API to intelligently analyze pull requests and suggest the most appropriate labels, making it easier to keep your repositories organized without manually reviewing each PR for labeling.
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 help
This shows a list of all available commands and their descriptions.