Skip to content

Git Agent

The git agent handles git provider operations within a workflow. Currently it supports creating pull requests on GitHub or Bitbucket. It auto-detects the provider from the repository’s remote URL, or you can set it explicitly in settings.

Use this agent for the finalization phase of a workflow — after implementation and review, create a PR with a single phase declaration. The git agent also supports event-driven PR creation via its notify handler, eliminating the need for a dedicated finalize phase.


- name: finalize
agent: git
action: create_pr
depends_on: [review]

ActionDescription
create_prCreate a pull request on the detected provider. Fails if a PR already exists for the current branch.
FieldTypeRequiredDescription
namestringYesUnique phase name within the workflow
typestringNoDefaults to "standard"
agentstringYesMust be "git"
depends_onstring[]NoUpstream phases that must complete before this phase runs
actionstringYesCurrently only "create_pr" is supported
notifyobjectNoEvent-driven handler (e.g., create PR on pipeline complete)

The git agent supports event-driven PR creation via the notify block. Attach it to any phase to trigger automatic PR creation without a dedicated finalize phase:

notify:
on_complete:
action: create_pr

Supported events: on_complete.


Configure under agents.git in settings.json (via cliq setup or cliq settings):

KeyRequiredDefaultDescription
agents.git.providerNo(auto-detected)Force a provider: "github" or "bitbucket"

Provider auto-detection: URLs containing bitbucket.org use Bitbucket; everything else uses GitHub.

KeyRequiredDefaultDescription
agents.git.github.tokenYesGitHub Personal Access Token
agents.git.github.base_branchNo"main"Branch to create feature branches from
agents.git.github.remoteNo"origin"Git remote name
agents.git.github.branch_prefixNo"cliq/"Prefix for feature branches
agents.git.github.pr_draftNofalseCreate PRs as drafts
agents.git.github.pr_reviewersNo[]GitHub usernames to request review from
agents.git.github.pr_labelsNo["cliq-generated"]Labels to apply to created PRs
KeyRequiredDefaultDescription
agents.git.bitbucket.workspaceYesBitbucket workspace slug
agents.git.bitbucket.emailYesAtlassian account email
agents.git.bitbucket.api_tokenYesBitbucket API token (Repos R/W + PRs R/W)

{
"data": {
"action": "create_pr",
"url": "https://github.com/acme/webapp/pull/42",
"id": 42,
"pr_created": true
},
"text": "PR created: https://github.com/acme/webapp/pull/42"
}
FieldLocationDescription
actiondata.actionThe action that was performed
urldata.urlFull URL to the created pull request
iddata.idPR number (GitHub) or PR ID (Bitbucket)
pr_createddata.pr_createdtrue if a new PR was created
commands:
- name: announce
run: 'echo "PR available at $(handoff.finalize.data.url)"'

Example: Create PR after implementation and review

Section titled “Example: Create PR after implementation and review”

The standard finalization pattern — implement, review, then create a PR.

phases:
- name: implement
agent: cursor
- name: review
type: gate
agent: hug
depends_on: [implement]
review:
reviewer: tech-lead
artifacts:
- src/**/*.ts
- name: finalize
agent: git
action: create_pr
depends_on: [review]

Example: Event-driven PR creation via notify

Section titled “Example: Event-driven PR creation via notify”

Skip the dedicated finalize phase — create a PR automatically when implementation completes.

phases:
- name: implement
agent: cursor
notify:
on_complete:
action: create_pr
- name: review
type: gate
agent: hug
depends_on: [implement]
review:
reviewer: tech-lead

Example: Multi-phase pipeline with Bitbucket

Section titled “Example: Multi-phase pipeline with Bitbucket”

A full pipeline targeting a Bitbucket repository.

phases:
- name: fetch-ticket
agent: jira
action: get_issue
sources:
- name: ticket.json
ref: PROJ-456
- name: implement
agent: cursor
depends_on: [fetch-ticket]
- name: finalize
agent: git
action: create_pr
depends_on: [implement]

  1. Go to https://github.com/settings/tokens
  2. Click Generate new tokenFine-grained token (recommended)
  3. Name it (e.g., cliq), set expiration, and scope to your repositories
  4. Under Permissions → Repository permissions, grant:
PermissionLevelWhy
ContentsRead and writePush commits and branches
Pull requestsRead and writeCreate PRs, add reviewers
  1. Click Generate token and copy it

Classic tokens also work — select the repo scope.

Terminal window
echo $GITHUB_TOKEN | cliq settings agents.git.github.token --stdin --global
cliq settings agents.git.github.base_branch main --global
cliq doctor agent git
  1. Find your workspace slug from your repo URL: https://bitbucket.org/<workspace>/<repo>
  2. Note your Atlassian account email from https://bitbucket.org/account/settings/
  3. Go to https://bitbucket.org/account/settings/app-passwords/ and create a token with:
CategoryLevelWhy
RepositoriesRead + WritePush commits and branches
Pull requestsRead + WriteCreate and merge PRs

In Bitbucket, Write does NOT imply Read. Check both for each category.

Terminal window
cliq settings agents.git.bitbucket.workspace my-workspace --global
cliq settings agents.git.bitbucket.email [email protected] --global
echo $BB_TOKEN | cliq settings agents.git.bitbucket.api_token --stdin --global
cliq doctor agent git

cliq doctor agent git checks:

  • git binary is on PATH
  • Provider credentials are configured
  • Credentials can authenticate against the provider API