# GitHub Agent

### What Can You Do?

Once connected, the GitHub Agent lets you:

* **Browse Repositories**: List and explore your personal and organization repositories, view files and branches
* **Manage Pull Requests**: List, review, and create pull requests — including viewing comments, reviews, and commit history
* **Handle Issues**: Manage issue assignees and labels across your projects
* **Monitor Workflows**: List, trigger, and track GitHub Actions CI/CD workflows
* **Search Code**: Find specific code across your repositories and organizations

### Quick Setup

#### Step 1: Select GitHub Agent

In any Blockbrain chat, click the AI Models selection dropdown. Click **Show detailed AI model list**. Find and click **GitHub Agent**. Look for **Configure** under the Status column.

#### Step 2: Connect to GitHub

Click **Configure**. Click the **Connect** button. Sign in with your GitHub account when prompted. Review the permissions Blockbrain is requesting and click **Authorize** to grant access.

#### Step 3: Start Using GitHub

You're ready! Now you can ask Blockbrain to help with your repositories, pull requests, issues, and workflows.

### What You Can Ask

#### Browsing Repositories

```
"List all my GitHub repositories"
"Show me the repositories in our organization"
"What branches exist in the main project repo?"
"Show me the contents of the README file in the docs repo"
```

#### Pull Request Management

```
"List all open pull requests in the backend repo"
"Show me the review comments on PR #42"
"What's the commit history for PR #15?"
"Create a pull request from feature-branch to main"
```

#### Issue Assignees and Labels

```
"Who can be assigned to issues in the frontend repo?"
"Assign the login bug issue to Maria"
"Add the 'urgent' label to issue #7"
"Remove the 'wontfix' label from issue #12"
```

#### Workflow Monitoring

```
"What CI/CD workflows are set up in the backend repo?"
"Show me the recent workflow runs for the deploy pipeline"
"What's the status of the latest build?"
"Trigger the staging deployment workflow"
```

#### Code Search

```
"Search for 'authentication' across all our repositories"
"Find where the API key validation is implemented"
"Search for files containing 'database migration' in the backend repo"
```

### How It Works

**Your Account = Blockbrain's Access**

* Blockbrain uses your GitHub permissions — you can only access repositories and data you normally have access to
* Actions like creating pull requests or triggering workflows are performed under your GitHub identity

**Smart Assistance**

* The AI helps navigate complex repositories and find relevant information quickly
* Automatically retries if a request fails, adjusting parameters as needed
* Confirms actions before executing write operations like creating PRs or triggering workflows

### Tips for Better Results

#### Repository Tips

* Be specific about which repository: *"List PRs in the **backend** repo"* instead of just *"List PRs"*
* Include the organization name if needed: *"Show repos in the **acme-corp** organization"*
* Specify branches when relevant: *"Show me the contents of config.yaml on the **develop** branch"*

#### Pull Request Tips

* Include the PR number when asking about a specific PR: *"Show comments on **PR #42**"*
* Mention the repository: *"Create a PR in the **frontend repo** from feature-login to main"*
* Specify what you want to see: *"Show me the **reviews** for PR #15"* vs. *"Show me the **commits** for PR #15"*

#### Workflow Tips

* Name the workflow: *"Trigger the **deploy-staging** workflow"*
* Ask for status with context: *"What's the status of the **last 5 runs** of the CI pipeline?"*
* The agent will check workflow inputs before triggering and ask for your confirmation

### Troubleshooting

#### "Can't see my repositories"

* Check if you can access the repository directly on GitHub
* Verify your GitHub connection is active under the agent settings
* Try reconnecting by clicking **Configure** again

#### "Permission denied" errors

* Your GitHub permissions may not include the requested action
* Some organizations require admin approval for OAuth apps — check with your GitHub organization admin
* Verify you're connected with the correct GitHub account

#### "Workflow trigger failed"

* Make sure the workflow supports manual dispatch (`workflow_dispatch` trigger)
* Check that you have permission to trigger workflows in the repository
* Verify the required inputs for the workflow are provided correctly

#### "Can't find code or files"

* Try using more specific search terms
* Verify the repository exists and you have access to it
* Check if the file path or branch name is correct

### Privacy and Security

#### What Blockbrain Can Do

* Read your repositories, branches, and file contents
* List and create pull requests on your behalf
* View and manage issue assignees and labels
* List and trigger GitHub Actions workflows
* Search code across your accessible repositories

#### What Blockbrain Cannot Do

* Access private repositories you don't have permission to view
* Delete repositories, branches, or files
* Change repository settings, webhooks, or GitHub Apps
* Access other users' private data or repositories
* Bypass organization-level access restrictions

#### Safety Features

* Pull requests and actions are performed under your GitHub identity
* Workflow triggers require your explicit confirmation
* You can revoke access anytime under the GitHub Agent settings

### Common Use Cases

#### Development Workflow

* **PR Reviews**: Quickly check the status and feedback on your pull requests
* **Code Discovery**: Find implementations or patterns across multiple repositories
* **Branch Management**: View branches and create references for new features

#### Project Oversight

* **Repository Browsing**: Navigate organization repos and understand project structure
* **Issue Management**: Assign team members to issues and organize work with labels
* **CI/CD Monitoring**: Track build and deployment status across workflows

#### Team Collaboration

* **Pull Request Creation**: Create PRs with proper base and head branches
* **Review Tracking**: See who reviewed what and what feedback was given
* **Workflow Automation**: Trigger deployments or test runs directly from the chat

### Example Conversation

**You:** "Show me all open pull requests in the backend repository"

**Blockbrain:** "Here are the open pull requests in the backend repository:

| #      | Title                              | Author | Status                       |
| ------ | ---------------------------------- | ------ | ---------------------------- |
| PR #42 | Add user authentication middleware | sarah  | 2 reviews, changes requested |
| PR #38 | Update database migration scripts  | tom    | 1 review, approved           |
| PR #35 | Fix rate limiting on API endpoints | maria  | Awaiting review              |

Would you like to see details, reviews, or comments for any of these?"

**You:** "Show me the reviews for PR #42"

**Blockbrain:** "PR #42 has 2 reviews:

1. **John** (Changes Requested): 'The middleware looks good overall, but the token validation should handle expired tokens gracefully. See my inline comments on auth.ts.'
2. **Lisa** (Commented): 'Nice approach! One suggestion — could we add rate limiting to the auth endpoint as well?'

Would you like me to show the commit history or the inline comments?"

### Next Steps

Want to connect more services? Try the [Salesforce Agent](/for-users/agents/salesforce-agent.md)  to manage your leads contacts, and accounts directly through Blockbrain.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.blockbrain.ai/for-users/agents/github-agent.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
