Auto-Patch Guide

Apply AI-suggested fixes with one click. Auto-Patch automatically creates GitHub commits with patch files.

What is Auto-Patch?

Auto-Patch automatically generates and applies fixes for issues detected by SwarmAI. When you approve a patch:

  • A patch file is generated with the suggested fix
  • A GitHub commit is automatically created
  • The commit includes a descriptive message and the patch file
  • You can review and merge the commit through GitHub
How Auto-Patch Works

The Auto-Patch workflow:

  1. Issue Detection: SwarmAI identifies a vulnerability or bug
  2. Fix Generation: AI analyzes the issue and generates a fix
  3. Patch Preview: You review the suggested fix in the dashboard
  4. Approval: Click "Apply Patch" to approve the fix
  5. GitHub Commit: A commit is automatically created in your repository
  6. Review & Merge: Review the commit on GitHub and merge when ready
Using Auto-Patch

Prerequisites:

  • GitHub integration must be connected
  • SwarmAI must have detected issues in your codebase
  • You must have write access to the repository

GitHub token scopes (Classic PAT):

  • repo: required (read code + create commits)
  • workflow: optional (only if touching workflow files)

Steps:

  1. Go to Integration Dashboard → Swarm AI tab
  2. Review detected issues and their suggested fixes
  3. Click "Apply Patch" on any fix you want to apply
  4. Confirm the patch application
  5. Check your GitHub repository for the new commit
  6. Review and merge the commit through GitHub's interface
Patch File Format

Auto-Patch generates standard patch files that can be applied with git apply:

diff --git a/src/utils/validation.js b/src/utils/validation.js
index abc1234..def5678 100644
--- a/src/utils/validation.js
+++ b/src/utils/validation.js
@@ -10,6 +10,7 @@ function validateInput(input) {
     throw new Error('Invalid input');
   }
+  // Sanitize input to prevent XSS
+  input = input.replace(/<script[^>]*>.*?</script>/gi, '');
   return input;
 }
Best Practices
  • Always review patches before applying them
  • Test patches in a development branch before merging to main
  • Review the commit diff on GitHub before merging
  • Run your test suite after applying patches
  • Consider applying patches one at a time for easier review
  • Keep backups of your codebase before applying multiple patches
Limitations

Auto-Patch is designed to assist, not replace, code review:

  • Some fixes may require manual adjustment
  • Complex refactoring may need human intervention
  • Business logic changes should be reviewed carefully
  • Not all issues can be automatically fixed