Method signature
Description
ThecreatePullRequest
method allows you to create a GitHub pull request after code changes have been generated using any supported agent (Codex, Claude, OpenCode, or Gemini). This method streamlines the process of submitting code changes for review by automatically creating a pull request with the generated modifications.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
repository | string | Yes | The GitHub repository in format “owner/repo” |
labelOptions | LabelOptions | No | Optional label configuration for the pull request |
branchPrefix | string | No | Optional prefix for the branch name that will be created |
LabelOptions Interface
Property | Type | Required | Description |
---|---|---|---|
name | string | Yes | The name of the label to create/apply to the pull request |
color | string | Yes | The color of the label in hex format (without #). Examples: “0e8a16” (green), “d73a49” (red), “0366d6” (blue) |
description | string | Yes | A description of what this label represents |
Return type
Type | Description |
---|---|
Promise<PullRequestResponse> | Promise that resolves to a pull request response object |
PullRequestResponse Interface
Property | Type | Required | Description |
---|---|---|---|
id | number | Yes | The unique identifier of the pull request |
number | number | Yes | The pull request number |
state | string | Yes | The state of the pull request (e.g., “open”, “closed”) |
title | string | Yes | The title of the pull request |
body | string | Yes | The body/description of the pull request |
html_url | string | Yes | The URL to view the pull request on GitHub |
head | object | Yes | Information about the head branch of the PR |
base | object | Yes | Information about the base branch of the PR |
user | object | Yes | Information about the user who created the PR |
created_at | string | Yes | ISO timestamp when the PR was created |
updated_at | string | Yes | ISO timestamp when the PR was last updated |
merged | boolean | Yes | Whether the pull request has been merged |
mergeable | boolean | null | Yes | Whether the pull request can be merged |
merge_commit_sha | string | null | Yes | The SHA of the merge commit if merged |
branchName | string | Yes | The name of the branch created for the PR |
commitSha | string | No | The SHA of the commit |
Requirements
- Agent Type: This method is available for all supported agents (Codex, Claude, OpenCode, and Gemini)
- Initialization: The VibeKit instance must be properly initialized with valid agent configuration
- Code Generation: Code changes should be generated before creating a pull request
- GitHub Integration: A valid GitHub token must be configured using
withSecrets({ GH_TOKEN: "your_token" })
- Repository Access: The provided GitHub token must have access to the specified repository
Error handling
The method throws errors in the following scenarios:Initialization Error
- When: The agent is not properly initialized
- Resolution: Verify your VibeKit configuration includes valid agent settings and GitHub configuration
Usage examples
Basic Usage
Advanced Usage with Parameters
Additional Label Examples
Using with Different Agents
Notes
- The pull request is automatically labeled with the agent type (‘codex’, ‘claude’, ‘opencode’, or ‘gemini’) to indicate which agent created it
- Ensure your GitHub token has the necessary permissions to create pull requests in the target repository
- The method creates a new branch for the pull request automatically
- Code changes must be generated before calling this method
- Repository must be explicitly cloned using
cloneRepository()
before generating code - When using
branchPrefix
, the final branch name will be in the format{branchPrefix}/{generated-suffix}
- The
labelOptions
parameter creates a new label if it doesn’t exist in the repository and applies it to the pull request - The response includes the complete GitHub API pull request data, allowing access to detailed information like user details, branch information, timestamps, and merge status
- The
repository
parameter is now required and specifies which repository to create the pull request in