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:
- Issue Detection: SwarmAI identifies a vulnerability or bug
- Fix Generation: AI analyzes the issue and generates a fix
- Patch Preview: You review the suggested fix in the dashboard
- Approval: Click "Apply Patch" to approve the fix
- GitHub Commit: A commit is automatically created in your repository
- 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:
- Go to Integration Dashboard → Swarm AI tab
- Review detected issues and their suggested fixes
- Click "Apply Patch" on any fix you want to apply
- Confirm the patch application
- Check your GitHub repository for the new commit
- 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