AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How Sweep Turns GitHub Issues into Pull Requests—and the Permissions It Demands

Morgan E. McVickar · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Granting an AI bot write access to your GitHub repository feels reckless. The first time 365Finds connected Sweep to an active repository, the security team winced: read and write access to repository contents, issues, and pull requests. But watching a vague bug ticket transform into a tested, multi-file pull request within four minutes changes how you think about backlog management.

Sweep positions itself as an autonomous junior developer. Instead of requiring you to babysit an IDE chat window, copy-paste snippets, and manually create branches, Sweep lives directly inside GitHub. It listens for issues, searches your codebase, drafts code, checks for syntax errors, and delivers a complete pull request ready for human code review.

Here is an architectural breakdown of how Sweep turns a GitHub issue into a pull request, alongside the exact permissions and security controls required to let it operate safely.


1. The Trigger: Catching the Issue

Sweep operates entirely event-driven through the GitHub Apps API. It doesn't crawl your repository continuously; it waits for clear signals:

The Sweep backend catches GitHub's issues.opened or issue_comment.created webhook payloads. At this moment, Sweep extracts the user's intent, parses the bug description or feature request, and initializes a background task.


2. Codebase Retrieval: Semantic Search Without Plaintext Exposure

An AI cannot fix a bug if it doesn't know where the bug lives. Sweeping an entire repository of 500,000 lines of code into a single LLM context window is neither feasible nor cost-effective. Sweep uses a multi-stage retrieval architecture:

[GitHub Issue]
       │
       ▼
[Tree-sitter AST Parser] ──► Chunks Code by Classes & Functions
       │
       ▼
[Redis Vector Cache]     ──► SHA-256 Hash Matching (Caches 99% of Unchanged Files)
       │
       ▼
[Embedding Pointers]     ──► Retrieves File Paths + Line Ranges (No Plaintext Stored)
       │
       ▼
[Synthesized Context]    ──► Selected Source Files Fed to the LLM Plan
  1. Structural AST Parsing: Using Tree-sitter, Sweep parses code along structural boundaries—classes, methods, and functions—rather than arbitrary 500-token text blocks.
  2. SHA-256 Incremental Caching: Repositories change incrementally. Sweep hashes code blocks with SHA-256 keys in a Redis cache. A typical git merge alters less than 1% of a codebase; Sweep caches the remaining 99%, keeping re-indexing times to mere seconds.
  3. Pointer-Based Security: To prevent proprietary code leaks, Sweep’s vector index stores structural pointers (filename.py:line10:line45) rather than raw source code strings. The actual code snippets are fetched dynamically from repository memory during execution.

3. The Planning & Code Generation Loop

Once the relevant files are isolated, Sweep generates an execution plan before writing a single line of code:


4. Branch Creation, CI Integration, and the Pull Request

When the code is ready, Sweep switches from passive reader to active contributor:

  1. Branch Checkout: Sweep creates an isolated git branch following the convention sweep/<issue-slug>-<id>.
  2. Commit and Push: It commits the modified files with a descriptive git message detailing the changes.
  3. Opening the Pull Request: Sweep opens a pull request referencing the original issue (e.g., Closes #42). The PR description contains a summary of changes, modified file paths, and confidence notes.
  4. Iterating on CI Failures: If gha_enabled: true is set in the repository configuration, Sweep monitors GitHub Actions check runs. If a unit test fails or a linter rejects the code, Sweep parses the CI error logs, generates a patch commit, and pushes it directly to the PR branch.

5. Conversational Code Review

The PR is not a dead end. Sweep supports in-line PR review conversations:

At 365Finds, we consider this iterative review cycle Sweep's strongest asset. It matches how senior engineers mentor junior developers: point out the defect in the PR, let the junior push the fix.


6. GitHub App Permissions Required by Sweep

To automate this entire lifecycle, Sweep requires substantive permissions when installed as a GitHub App.

ScopePermission LevelWhy Sweep Requires It
Repository ContentsRead & WriteRead source files to build context; create new branches and push code commits.
Pull RequestsRead & WriteOpen pull requests, write PR descriptions, and respond to review comments.
IssuesRead & WriteRead issue prompts, post implementation plans, and add labels or status notes.
Workflows / ChecksRead & Write (Optional/Recommended)Monitor GitHub Actions test logs to detect CI failures and push automated bug fixes.
MetadataRead-OnlyBasic GitHub App operational access to repository names and IDs.

Webhook Event Subscriptions

Sweep subscribes to several real-time webhook events:


7. Guardrails: Configuring sweep.yaml

Granting write permissions to an external agent requires strict repository guardrails. Sweep allows repository maintainers to place a sweep.yaml configuration file in the repository root:

# Target base branch for pull requests
branch: "main"

# Automatically run GitHub Actions and iterate on CI failures
gha_enabled: true

# Open PRs as drafts so they cannot be accidentally merged
draft: true

# Block Sweep from touching sensitive files or secret configs
blocked_dirs:
  - ".github/workflows/"
  - "infra/"
  - "config/secrets.json"
  - "sweepai/core/prompts.py"

# Custom coding rules Sweep must follow
rules:
  - "All new public methods must include docstrings and type annotations."
  - "Do not use raw print statements; always use the application logger."
  - "Ensure unit test coverage is added for every new route."

365Finds strongly advises setting draft: true and locking down .github/workflows/ and all environment configuration directories under blocked_dirs. Sweep should never possess the authority to modify CI pipeline scripts or privilege configurations.


The 365Finds Verdict

At 365Finds, we like tools that eliminate boilerplate toil. Sweep tackles the most tedious part of software development: small bug fixes, missing docstrings, minor refactoring, and straightforward feature flags. When an issue is crisp and well-scoped, Sweep delivers a 90% complete pull request before you finish making coffee.

However, Sweep is not a drop-in replacement for engineering judgment. The permission profile—Contents: Write and Workflows: Write—is substantial. For regulated enterprise codebases or teams with strict IP compliance, self-hosting Sweep's open-source stack or restricting it to staging repositories is non-negotiable.

Set up branch protection rules that require human approvals, ban auto-merges on bot PRs, define blocked_dirs on day one, and treat Sweep like an eager intern: give it tasks, check its work, and never hand it the keys to production.

References