pr-cleaner-ai
v1.4.1
Published
Cursor + GitHub PR cleanup assistant. Local dev tool (install as devDependency).
Maintainers
Readme
🧹 pr-cleaner-ai
Clean up your pull request in one command — directly in Cursor.
pr-cleaner-ai pulls review comments from a GitHub Pull Request, updates your local code, and walks you through resolving the threads — so after review you can get to merge without doing the boring cleanup loop.
Everything runs locally. pr-cleaner-ai talks to GitHub through your local gh auth login. Your code never leaves your machine, no personal access tokens are stored in the repo, and nothing is uploaded to any external service.
🚀 Quick Start (3 steps):
1️⃣ Authenticate GitHub CLI:
gh auth login2️⃣ Install and initialize in your project:
npm install -D pr-cleaner-ai
npx pr-cleaner-ai init3️⃣ Use it in Cursor:
Simply mention the PR number:
fix PR 123Or any of these formats:
PR 123
PR#123
#123
resolve PR comments for 123That's it. No tokens, no bot PRs, no complex setup.
How does Cursor know what to do?
Thepr-cleaner-ai.mdcrule teaches Cursor how to react when you mention a PR number.
You don't have to copy/paste comments or tell it what to do — it already knows to fetch the PR, group the comments, and start applying fixes.
✨ Features
- ✅ Fetch all comments from any GitHub Pull Request
- ✅ Run directly in Cursor — just type
fix PR 123 - ✅ Groups review comments by file/line so you see exactly what needs to change
- ✅ Optional auto-fix mode (
autoFix: true) to apply fixes automatically - ✅ Stays in your branch — no bot PRs, no detached workspaces
- ✅ Uses GitHub CLI for authentication – no token management needed!
- ✅ Works with any language (Java, Python, Go, JavaScript, etc.)
- ✅ Non-intrusive setup – you control what gets configured
🤯 Why this matters
Before:
- 12 unresolved review comments
- jumping file to file fixing nitpicks ("rename this", "add null check", "please add test", "typo here")
- push, wait, repeat
After:
fix PR 2146pr-cleaner-aifetches all comments from the PR- shows what each reviewer asked for, file by file
- proposes the actual code change
- you just confirm
[y/n]
Result: branch is mergeable in minutes instead of an hour of cleanup.
📦 Installation
npm install -D pr-cleaner-ai
# or
yarn add -D pr-cleaner-ai
# or
pnpm add -D pr-cleaner-aiRequires Node.js >=16 (runtime only — your repo can be any language).
Note: This is a development tool for PR review workflow. Install as devDependency (
-Dflag).
⚡ Setup
1. Dependencies
GitHub CLI is required. If you don't have it:
macOS:
brew install ghWindows:
winget install --id GitHub.cliLinux:
See: https://github.com/cli/cli/blob/trunk/docs/install_linux.md
Then authenticate:
gh auth login2. Initialize the package
⚠️ REQUIRED: After installation, you MUST run:
npx pr-cleaner-ai initThis will:
- Copy
.cursor/rules/pr-cleaner-ai.mdcfrom npm package (Cursor AI integration) - Add
.pr-cleaner-ai-output/and.cursor/rules/pr-cleaner-ai.mdcto.gitignore - Ensure generated files are properly ignored by Git
Important: Without running init, generated files may appear in your Git changes.
Optional: add npm scripts to package.json:
npx pr-cleaner-ai init --with-scripts3. Commit configuration files (for team)
git add .gitignore
git commit -m "chore: configure pr-cleaner-ai"Important:
.cursor/rules/pr-cleaner-ai.mdcis automatically gitignored (added byinit)- To update rules file to match new package version, run
npx pr-cleaner-ai initagain - No need to commit
.cursor/rules/pr-cleaner-ai.mdcor.pr-cleaner-ai-output/- they're generated files - Each team member needs GitHub CLI authenticated (
gh auth login)
4. Use in Cursor
In any file or chat inside Cursor, mention the PR number:
fix PR 2146Or any of these formats:
PR 2146
PR#2146
#2146
resolve PR comments for 2146
apply fixes from PR 2146How it works: Cursor automatically detects PR references and activates the pr-cleaner-ai workflow from .cursor/rules/pr-cleaner-ai.mdc.
💡 Tip: If Cursor doesn't activate the rule automatically, you can add
.cursor/rules/pr-cleaner-ai.mdcto your chat context manually, and make sure you're in Agent mode (not Composer mode) for full workflow support.
You'll get something like:
🔎 PR #2146 found (12 comments)
📂 Affected files:
- src/auth/login.ts (5)
- src/auth/utils/formatError.ts (2)
- tests/login.spec.ts (1)
⚙ Mode: interactive (autoFix: false)
login.ts:42
Reviewer: "rename tmp → sessionToken"
→ Apply this change? [y/n]
formatError.ts:18
Reviewer: "handle null case"
→ Apply this change? [y/n]Cursor will walk you through each comment and propose code updates.
5. Or run from terminal
Specify the PR number:
npx pr-cleaner-ai fetch --pr=2146This will fetch and group PR comments locally without going through Cursor.
🔧 Commands
# Initialize pr-cleaner-ai (run once per project)
npx pr-cleaner-ai init
# Initialize with package.json scripts
npx pr-cleaner-ai init --with-scripts
# Fetch PR comments
npx pr-cleaner-ai fetch --pr=2146
# Check environment (Cursor rules present, gh authenticated, etc.)
npx pr-cleaner-ai check⚙️ Configuration (optional, power users)
Create .pr-cleaner-ai.config.json if you want to change how fixes are applied:
{
"autoFix": false,
"additionalRules": [
".cursor/rules/coding-standards.mdc",
".cursor/rules/testing-requirements.mdc"
],
"commitBatch": {
"threshold": {
"comments": 2
}
}
}Options:
autoFix: false(default) – interactive mode, asks before each patchautoFix: true– hands-free mode, applies all fixes automaticallyadditionalRules(optional) – array of rule file paths that Cursor should consider when resolving PR comments. These files will be automatically referenced in the generated markdown output.commitBatch.threshold.comments(optional) – after fixing this many comments, Cursor will:- ✅ Stop and show what was fixed
- 💡 Suggest a commit message (never auto-commits!)
- ⏸️ Wait for your approval before continuing
- 🔄 Show brief summary of what's done vs what's remaining
2and there are 10 comments, Cursor will fix 2 comments, suggest a commit, wait for you to commit, then continue with the next batch.
📋 Requirements
- Node.js >= 16.0.0 (runtime only)
- Git
- GitHub CLI (
gh) – installed and authenticated - Intended to be installed as a devDependency – this is a development tool, not a production runtime library
pr-cleaner-ai talks to GitHub only through gh api, using your existing gh auth login.
🔒 Security
pr-cleaner-ai never asks for a personal access token and never uploads your code anywhere.
We take your repo security seriously:
What this means:
- ✅ No cloud processing – runs on your laptop
- ✅ No token management – uses GitHub CLI
- ✅ No data collection – zero telemetry
- ✅ Built with security best practices
- ✅ Published with provenance –
npm publish --provenancefor supply chain security - ✅ 2FA enabled – required for package maintainers
File Protection
- ✅ Output folder (
.pr-cleaner-ai-output/) is gitignored - ✅ Cursor rules file (
.cursor/rules/pr-cleaner-ai.mdc) is gitignored
Security Features
- ✅ Path validation – all file operations use
path.resolve()to prevent directory traversal - ✅ Input validation – PR numbers, owner/repo names validated before API calls
- ✅ Command injection prevention – uses
spawn()with array arguments, never string concatenation - ✅ No network calls in postinstall – respects
PR_CLEANER_AI_SKIP_POSTINSTALL=1
See SECURITY.md for detailed security information and vulnerability reporting.
🌍 Supported Languages
pr-cleaner-ai works with any language supported by Cursor AI, including but not limited to:
- Java, Kotlin, Scala
- Python, JavaScript, TypeScript
- Go, Rust, C, C++, C#
- Ruby, PHP, Swift
- ...and more
You can run pr-cleaner-ai in polyglot monorepos.
🤔 Why This Approach?
Unlike other tools that automatically modify your files during installation, pr-cleaner-ai gives you control:
✅ You choose when to initialize
✅ No surprises in git status
✅ Team-friendly – explicit configuration commits
✅ Optional scripts – add to package.json only if you want
✅ No token management – uses GitHub CLI for secure authentication
pr-cleaner-ai never creates its own bot branch or opens PRs on your behalf — it works in your current branch, with your code, under your name.
What gets created after pr-cleaner-ai init:
Files NOT to commit (gitignored automatically):
.pr-cleaner-ai-output/– Temporary PR comment files.cursor/rules/pr-cleaner-ai.mdc– Auto-updated Cursor rules (gitignored)
Optional configuration:
- Create
.pr-cleaner-ai.config.jsonmanually if you want to customize behavior:
This enables auto-apply fixes without asking (default is{ "autoFix": true }false- interactive mode)
🤝 Contributing
Issues and pull requests are welcome.
If you hit an edge case in comment parsing or patch generation, please open an issue with:
- PR number
- example comment
- expected vs actual behavior
📄 License
MIT
❓ FAQ
What happens when I switch branches?
When you leave a branch:
.pr-cleaner-ai-output/is gitignored (won't follow you).cursor/rules/pr-cleaner-ai.mdcis gitignored (will be recreated if needed)
When you come back to that branch:
- if
pr-cleaner-aiis still innode_modules, the Cursor rule file is automatically recreated - if it's not installed anymore, just run
npm installagain
Cursor doesn't activate the rule when I mention a PR number
If fix PR 123 doesn't trigger the workflow automatically:
Add the rule file to context manually:
- Click
@in Cursor chat - Select
.cursor/rules/pr-cleaner-ai.mdc - Then try
fix PR 123again
- Click
Make sure you're in Agent mode:
- Use Cursor's Agent mode (not Composer mode) for full workflow support
- Agent mode allows multi-step actions and file execution
Verify the rule file exists:
ls .cursor/rules/pr-cleaner-ai.mdcIf missing, run
npx pr-cleaner-ai initagain.
🔗 Links
Made with ❤️ for developers who are tired of babysitting pull request feedback.
Author: Szesnasty (Łukasz Jakubowski)
