overkill 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. overkill-0.2.1/.github/workflows/publish.yml +26 -0
  2. overkill-0.2.1/.github/workflows/test.yml +33 -0
  3. overkill-0.2.1/.gitignore +35 -0
  4. overkill-0.2.1/.python-version +1 -0
  5. overkill-0.2.1/.refactorsuggestrc.example +50 -0
  6. overkill-0.2.1/.reviewlooprc.example +36 -0
  7. overkill-0.2.1/AGENTS.md +46 -0
  8. overkill-0.2.1/CLAUDE.md +1 -0
  9. overkill-0.2.1/GEMINI.md +1 -0
  10. overkill-0.2.1/LICENSE +21 -0
  11. overkill-0.2.1/PKG-INFO +405 -0
  12. overkill-0.2.1/README.md +383 -0
  13. overkill-0.2.1/bin/lib/check-claude-limit.sh +256 -0
  14. overkill-0.2.1/bin/lib/check-codex-limit.sh +202 -0
  15. overkill-0.2.1/bin/lib/common.sh +511 -0
  16. overkill-0.2.1/bin/lib/retry.sh +306 -0
  17. overkill-0.2.1/bin/lib/self-review.sh +527 -0
  18. overkill-0.2.1/bin/refactor-suggest.sh +748 -0
  19. overkill-0.2.1/bin/review-loop.sh +593 -0
  20. overkill-0.2.1/install.sh +53 -0
  21. overkill-0.2.1/prompts/active/claude-fix-execute.prompt.md +13 -0
  22. overkill-0.2.1/prompts/active/claude-fix.prompt.md +20 -0
  23. overkill-0.2.1/prompts/active/claude-refactor-fix-execute.prompt.md +22 -0
  24. overkill-0.2.1/prompts/active/claude-refactor-fix.prompt.md +27 -0
  25. overkill-0.2.1/prompts/active/claude-refactor-full.prompt.md +115 -0
  26. overkill-0.2.1/prompts/active/claude-refactor-layer.prompt.md +115 -0
  27. overkill-0.2.1/prompts/active/claude-refactor-micro.prompt.md +116 -0
  28. overkill-0.2.1/prompts/active/claude-refactor-module.prompt.md +114 -0
  29. overkill-0.2.1/prompts/active/claude-review.prompt.md +72 -0
  30. overkill-0.2.1/prompts/active/claude-self-review.prompt.md +66 -0
  31. overkill-0.2.1/prompts/active/codex-refactor-full.prompt.md +115 -0
  32. overkill-0.2.1/prompts/active/codex-refactor-layer.prompt.md +115 -0
  33. overkill-0.2.1/prompts/active/codex-refactor-micro.prompt.md +116 -0
  34. overkill-0.2.1/prompts/active/codex-refactor-module.prompt.md +114 -0
  35. overkill-0.2.1/prompts/active/codex-review.prompt.md +72 -0
  36. overkill-0.2.1/prompts/reference/claude-code-review-plugin.md +105 -0
  37. overkill-0.2.1/prompts/reference/claude-security-review.md +195 -0
  38. overkill-0.2.1/prompts/reference/codex-review-original.md +90 -0
  39. overkill-0.2.1/pyproject.toml +67 -0
  40. overkill-0.2.1/src/mr_overkill/__init__.py +3 -0
  41. overkill-0.2.1/src/mr_overkill/__main__.py +116 -0
  42. overkill-0.2.1/src/mr_overkill/agents.py +497 -0
  43. overkill-0.2.1/src/mr_overkill/budget/__init__.py +109 -0
  44. overkill-0.2.1/src/mr_overkill/budget/claude.py +353 -0
  45. overkill-0.2.1/src/mr_overkill/budget/codex.py +118 -0
  46. overkill-0.2.1/src/mr_overkill/budget_report.py +98 -0
  47. overkill-0.2.1/src/mr_overkill/classify.py +63 -0
  48. overkill-0.2.1/src/mr_overkill/cli.py +643 -0
  49. overkill-0.2.1/src/mr_overkill/data/__init__.py +0 -0
  50. overkill-0.2.1/src/mr_overkill/git_ops.py +258 -0
  51. overkill-0.2.1/src/mr_overkill/init.py +142 -0
  52. overkill-0.2.1/src/mr_overkill/json_extract.py +205 -0
  53. overkill-0.2.1/src/mr_overkill/loop_engine.py +659 -0
  54. overkill-0.2.1/src/mr_overkill/models.py +293 -0
  55. overkill-0.2.1/src/mr_overkill/refactor_suggest.py +426 -0
  56. overkill-0.2.1/src/mr_overkill/reporting.py +203 -0
  57. overkill-0.2.1/src/mr_overkill/resume.py +143 -0
  58. overkill-0.2.1/src/mr_overkill/retry.py +302 -0
  59. overkill-0.2.1/src/mr_overkill/review_loop.py +56 -0
  60. overkill-0.2.1/src/mr_overkill/self_review.py +345 -0
  61. overkill-0.2.1/src/mr_overkill/time_utils.py +38 -0
  62. overkill-0.2.1/src/mr_overkill/two_step_fix.py +112 -0
  63. overkill-0.2.1/test/refactor-suggest.bats +159 -0
  64. overkill-0.2.1/test/test_helper.bash +117 -0
  65. overkill-0.2.1/tests/__init__.py +0 -0
  66. overkill-0.2.1/tests/conftest.py +120 -0
  67. overkill-0.2.1/tests/test_agents.py +385 -0
  68. overkill-0.2.1/tests/test_budget_claude.py +91 -0
  69. overkill-0.2.1/tests/test_budget_codex.py +106 -0
  70. overkill-0.2.1/tests/test_budget_policy.py +275 -0
  71. overkill-0.2.1/tests/test_budget_report.py +118 -0
  72. overkill-0.2.1/tests/test_classify.py +100 -0
  73. overkill-0.2.1/tests/test_cli.py +458 -0
  74. overkill-0.2.1/tests/test_git_ops.py +128 -0
  75. overkill-0.2.1/tests/test_init.py +110 -0
  76. overkill-0.2.1/tests/test_integration.py +201 -0
  77. overkill-0.2.1/tests/test_json_extract.py +193 -0
  78. overkill-0.2.1/tests/test_loop_engine.py +428 -0
  79. overkill-0.2.1/tests/test_refactor_suggest.py +226 -0
  80. overkill-0.2.1/tests/test_reporting.py +137 -0
  81. overkill-0.2.1/tests/test_resume.py +159 -0
  82. overkill-0.2.1/tests/test_retry.py +222 -0
  83. overkill-0.2.1/tests/test_review_loop.py +66 -0
  84. overkill-0.2.1/tests/test_self_review.py +451 -0
  85. overkill-0.2.1/tests/test_time_utils.py +67 -0
  86. overkill-0.2.1/tests/test_two_step_fix.py +234 -0
  87. overkill-0.2.1/uninstall.sh +100 -0
  88. overkill-0.2.1/uv.lock +344 -0
@@ -0,0 +1,26 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ id-token: write
9
+ contents: read
10
+
11
+ jobs:
12
+ publish:
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - uses: astral-sh/setup-uv@v5
19
+ with:
20
+ python-version: "3.12"
21
+
22
+ - name: Build package
23
+ run: uv build
24
+
25
+ - name: Publish to PyPI
26
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,33 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ pull_request:
7
+ branches: [main, develop]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - uses: astral-sh/setup-uv@v5
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+
23
+ - name: Install dependencies
24
+ run: uv sync --group dev
25
+
26
+ - name: Ruff check
27
+ run: uv run ruff check
28
+
29
+ - name: Mypy
30
+ run: uv run mypy src
31
+
32
+ - name: Pytest
33
+ run: uv run pytest
@@ -0,0 +1,35 @@
1
+ # review-loop runtime logs (bin/../logs → repo-root /logs/)
2
+ /logs/
3
+
4
+ # Legacy log directory from previous versions
5
+ .ai-review-logs/
6
+ # review-loop self-hosted install
7
+ .review-loop/
8
+
9
+ # Python
10
+ __pycache__/
11
+ *.py[cod]
12
+ *$py.class
13
+ *.so
14
+ .venv/
15
+ *.egg-info/
16
+ *.egg
17
+ dist/
18
+ build/
19
+ .eggs/
20
+
21
+ # Testing / Coverage
22
+ .coverage
23
+ .coverage.*
24
+ htmlcov/
25
+ .tox/
26
+ .nox/
27
+ .pytest_cache/
28
+ test/tmp/
29
+
30
+ # mypy / ruff / type checkers
31
+ .mypy_cache/
32
+ .ruff_cache/
33
+
34
+ # Distribution / packaging
35
+ *.whl
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,50 @@
1
+ # .refactorsuggestrc — project-level configuration for refactor-suggest.sh
2
+ # Copy this file to your project root as ".refactorsuggestrc" and customize.
3
+ # CLI arguments always take precedence over these values.
4
+
5
+ # Refactoring scope: auto | micro | module | layer | full (default: auto)
6
+ # auto = pick largest feasible scope based on token budget at startup
7
+ # <75% used → module, 75-89% → micro, >=90% → error
8
+ # SCOPE="auto"
9
+
10
+ # Target branch to base the refactoring branch from (default: develop)
11
+ # TARGET_BRANCH="develop"
12
+
13
+ # Maximum analysis-fix iterations (default: unset, required via CLI)
14
+ # MAX_LOOP=3
15
+
16
+ # Maximum self-review sub-iterations per fix (default: 4, set 0 to disable)
17
+ # MAX_SUBLOOP=4
18
+
19
+ # Run analysis only, do not apply fixes (default: false)
20
+ # DRY_RUN=false
21
+
22
+ # Skip interactive confirmation for layer/full scope (default: false)
23
+ # AUTO_APPROVE=false
24
+
25
+ # Create a draft PR after completing all iterations (default: false)
26
+ # CREATE_PR=false
27
+
28
+ # Run review-loop automatically after PR creation (default: false)
29
+ # WITH_REVIEW=false
30
+
31
+ # Number of review-loop iterations when WITH_REVIEW=true (default: 4)
32
+ # REVIEW_LOOPS=4
33
+
34
+ # Path to active prompt templates (default: <script_dir>/../prompts/active)
35
+ # PROMPTS_DIR="./custom-prompts"
36
+
37
+ # ── Retry / Rate-Limit Settings ──────────────────────────────────────
38
+ # Max total wait (seconds) for a single CLI call to recover from rate limits (default: 7200)
39
+ # RETRY_MAX_WAIT=7200
40
+
41
+ # Initial backoff delay (seconds); doubles each retry, capped at 300s (default: 30)
42
+ # RETRY_INITIAL_WAIT=30
43
+
44
+ # Pre-flight budget check scope: micro (<90%) or module (<75%) (default: module)
45
+ # BUDGET_SCOPE="module"
46
+
47
+ # ── Diagnostic Logging ──────────────────────────────────────────────
48
+ # Save full Claude event stream (tool calls, reasoning) to .stream.jsonl files.
49
+ # Useful for debugging missed findings. (default: false)
50
+ # DIAGNOSTIC_LOG=false
@@ -0,0 +1,36 @@
1
+ # .reviewlooprc — project-level configuration for review-loop.sh
2
+ # Copy this file to your project root as ".reviewlooprc" and customize.
3
+ # CLI arguments always take precedence over these values.
4
+
5
+ # Target branch to diff against (default: develop)
6
+ # TARGET_BRANCH="main"
7
+
8
+ # Maximum review-fix iterations (default: unset, required via CLI)
9
+ # MAX_LOOP=5
10
+
11
+ # Maximum self-review sub-iterations per fix (default: 4, set 0 to disable)
12
+ # MAX_SUBLOOP=4
13
+
14
+ # Run review only, do not fix (default: false)
15
+ # DRY_RUN=false
16
+
17
+ # Enable auto-commit of fixes (default: true)
18
+ # AUTO_COMMIT=true
19
+
20
+ # Path to active prompt templates (default: <script_dir>/../prompts/active)
21
+ # PROMPTS_DIR="./custom-prompts"
22
+
23
+ # ── Retry / Rate-Limit Settings ──────────────────────────────────────
24
+ # Max total wait (seconds) for a single CLI call to recover from rate limits (default: 7200)
25
+ # RETRY_MAX_WAIT=7200
26
+
27
+ # Initial backoff delay (seconds); doubles each retry, capped at 300s (default: 30)
28
+ # RETRY_INITIAL_WAIT=30
29
+
30
+ # Pre-flight budget check scope: micro (<90%) or module (<75%) (default: module)
31
+ # BUDGET_SCOPE="module"
32
+
33
+ # ── Diagnostic Logging ──────────────────────────────────────────────
34
+ # Save full Claude event stream (tool calls, reasoning) to .stream.jsonl files.
35
+ # Useful for debugging missed findings. (default: false)
36
+ # DIAGNOSTIC_LOG=false
@@ -0,0 +1,46 @@
1
+ ## Project Identity
2
+
3
+ - **Repo**: `modocai/mr-overkill` (GitHub)
4
+ - **PyPI package name**: `overkill` (pending publisher registered)
5
+ - **Python import**: `mr_overkill` (source in `src/mr_overkill/`)
6
+ - **CLI entrypoint**: `overkill` (subcommands: `review-loop`, `refactor-suggest`, `init`, `check-budget`)
7
+ - **Version**: managed in `pyproject.toml` → `[project] version`
8
+ - **CI/CD**: GitHub Actions — `publish.yml` triggers PyPI publish
9
+
10
+ ## Pull Request Rules
11
+
12
+ Every PR must pass the review loop (`review-loop.sh --dry-run`) before merging. No exceptions. We eat our own dog food — if Mr. Overkill can't approve it, neither can you.
13
+
14
+ ## Branch Rules
15
+
16
+ Always commit and push before ending work on any branch other than develop.
17
+ Never commit directly to `main` or `develop`. All changes must go through branch → PR → review before merge.
18
+ Never rebase or force-push `main` or `develop` — this destroys shared history.
19
+
20
+ ## PR Merge Process
21
+
22
+ Before merging a PR, always fetch the target branch and check for new commits:
23
+
24
+ ```
25
+ git fetch origin <target-branch>
26
+ git log HEAD..origin/<target-branch> --oneline
27
+ ```
28
+
29
+ **A) Target branch has new commits:**
30
+ 1. Merge the target branch into your feature branch (`git merge origin/<target-branch>`)
31
+ 2. Resolve conflicts if any
32
+ 3. Push the merge commit
33
+ 4. Re-run the review loop — the merged code must pass review again
34
+
35
+ **B) Target branch is up to date:**
36
+ 1. Merge the PR:
37
+ - Feature branch → target: `gh pr merge --merge --delete-branch`
38
+ - `develop` → `main`: `gh pr merge --merge` (**never** `--delete-branch` — `develop` is a long-lived branch)
39
+ 2. Switch to the target branch, pull, and delete the local feature branch (if applicable)
40
+
41
+ ## Commit Messages
42
+
43
+ Principles:
44
+ - Write the subject in English, capturing the motivation/context of the change
45
+ - Keep conventional commit prefixes (fix, feat, refactor, etc.)
46
+ - Add a detailed body after a blank line if needed
@@ -0,0 +1 @@
1
+ AGENTS.md
@@ -0,0 +1 @@
1
+ AGENTS.md
overkill-0.2.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ModocAI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,405 @@
1
+ Metadata-Version: 2.4
2
+ Name: overkill
3
+ Version: 0.2.1
4
+ Summary: AI-powered code review loop — automates Codex review + Claude fix cycles
5
+ Project-URL: Repository, https://github.com/modocai/mr-overkill
6
+ Project-URL: Issues, https://github.com/modocai/mr-overkill/issues
7
+ Author: ModocAI
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Keywords: ai,automation,claude,code-review,codex,refactoring
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Requires-Python: >=3.12
21
+ Description-Content-Type: text/markdown
22
+
23
+ # :tophat: Mr. Overkill
24
+
25
+ > **"Refactoring is not a task. It's a lifestyle."**
26
+
27
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) [![Token Cost](https://img.shields.io/badge/Token%20Cost-Bankrupt-red)](#) [![Efficiency](https://img.shields.io/badge/Efficiency-0%25-orange)](#) [![Over-Engineering](https://img.shields.io/badge/Over--Engineering-Max-blueviolet)](#)
28
+
29
+ <img width="1024" height="1024" alt="image" src="https://github.com/user-attachments/assets/930a88d3-1224-47fc-bf5f-d9b367a8f29a" />
30
+
31
+
32
+ **Mr. Overkill** is an automated loop that forces **Codex** (the pedantic reviewer) and **Claude** (the tired developer) into a locked room. They will not stop refactoring your code until it is "perfectly over-engineered" or your API credit runs out.
33
+
34
+ ## :warning: WARNING: FINANCIAL HAZARD
35
+
36
+ **Do not run this script if you value your money.**
37
+
38
+ This tool is designed to:
39
+
40
+ 1. :fire: **Burn Tokens:** It ignores "good enough" and strives for "unnecessarily complex."
41
+ 2. :money_with_wings: **Drain Wallets:** Requires OpenAI (Paid) AND Anthropic (Pro/Max) simultaneously.
42
+ 3. :infinity: **Loop Forever:** It might turn your "Hello World" into a Microservices Architecture.
43
+
44
+ ---
45
+
46
+ ## Quick Install (If you dare)
47
+
48
+ ```bash
49
+ # Install the package
50
+ pip install overkill # or: uv tool install overkill / pipx install overkill
51
+
52
+ # Initialize your project
53
+ overkill init /path/to/your-project
54
+ ```
55
+
56
+ Or use the convenience script from the source repo:
57
+
58
+ ```bash
59
+ git clone --depth 1 https://github.com/modocai/mr-overkill.git /tmp/overkill \
60
+ && /tmp/overkill/install.sh /path/to/your-project \
61
+ && rm -rf /tmp/overkill
62
+ ```
63
+
64
+ ## :hammer_and_wrench: Prerequisites (The "Rich Dev" Starter Pack)
65
+
66
+ You need these to participate in the madness:
67
+
68
+ **Accounts** (yes, you need both — that's the point):
69
+
70
+ - [OpenAI](https://platform.openai.com/) account (paid plan) — because free tier is for weak code
71
+ - [Anthropic](https://console.anthropic.com/) account (Pro/Max plan or API credits) — because Claude needs to think *deeply* about your variable names
72
+
73
+ **Runtime**:
74
+
75
+ - [Python](https://www.python.org/) 3.12+ — for the `overkill` CLI
76
+ - [Node.js](https://nodejs.org/) v18+ — Codex and Claude Code CLI are npm packages, so yes, you need this
77
+ - A fast credit card — essential
78
+
79
+ **CLI Tools**:
80
+
81
+ ```bash
82
+ npm install -g @openai/codex # Codex CLI
83
+ npm install -g @anthropic-ai/claude-code # Claude Code CLI
84
+ ```
85
+
86
+ - [jq](https://jqlang.github.io/jq/) — JSON processor
87
+ - [gh](https://cli.github.com/) — GitHub CLI (optional, for PR comments)
88
+ - [envsubst](https://www.gnu.org/software/gettext/) — part of GNU gettext (macOS: `brew install gettext`)
89
+ - [perl](https://www.perl.org/) — used for JSON extraction and deduplication (pre-installed on macOS and most Linux)
90
+ - git
91
+
92
+ ## Quick Start
93
+
94
+ ```bash
95
+ # In your project directory (after install):
96
+
97
+ # Review loop — review and fix diffs against target branch
98
+ overkill review-loop -n 3
99
+
100
+ # Refactor suggest — analyze full codebase for refactoring opportunities
101
+ overkill refactor-suggest -n 1 --dry-run
102
+ ```
103
+
104
+ ## Usage: overkill review-loop
105
+
106
+ ```
107
+ overkill review-loop [OPTIONS]
108
+
109
+ Options:
110
+ -t, --target <branch> Target branch to diff against (default: develop)
111
+ -n, --max-loop <N> Maximum review-fix iterations (required, unless --resume)
112
+ --max-subloop <N> Maximum self-review sub-iterations per fix (default: 4)
113
+ --no-self-review Disable self-review (equivalent to --max-subloop 0)
114
+ --dry-run Run review only, do not fix
115
+ --no-auto-commit Fix but do not commit/push (single iteration)
116
+ --resume Resume from a previously interrupted run (reuses existing logs)
117
+ --reviewer-backend <be> Reviewer backend: claude|codex (default: codex)
118
+ --diagnostic-log Save full Claude event stream to sidecar files
119
+
120
+ Examples:
121
+ overkill review-loop -t main -n 3 # diff against main, max 3 loops
122
+ overkill review-loop -n 5 # diff against develop, max 5 loops
123
+ overkill review-loop -n 1 --dry-run # single review, no fixes
124
+ overkill review-loop -n 3 --no-self-review # disable self-review sub-loop
125
+ overkill review-loop --resume # resume an interrupted run
126
+ overkill review-loop -n 2 --reviewer-backend claude # use Claude as reviewer
127
+ ```
128
+
129
+ ## Usage: overkill refactor-suggest
130
+
131
+ Unlike `review-loop` which reviews diffs, `refactor-suggest` analyzes the **entire codebase** for refactoring opportunities at a chosen scope level.
132
+
133
+ ```
134
+ overkill refactor-suggest [OPTIONS]
135
+
136
+ Options:
137
+ --scope <scope> Refactoring scope: auto|micro|module|layer|full (default: auto)
138
+ -t, --target <branch> Target branch to base from (default: develop)
139
+ -n, --max-loop <N> Maximum analysis-fix iterations (default: 1)
140
+ --max-subloop <N> Maximum self-review sub-iterations per fix (default: 4)
141
+ --no-self-review Disable self-review (equivalent to --max-subloop 0)
142
+ --dry-run Run analysis only, do not apply fixes
143
+ --no-dry-run Force fixes even if .refactorsuggestrc sets DRY_RUN=true
144
+ --auto-approve Skip interactive confirmation for layer/full scope
145
+ --create-pr Create a draft PR after completing all iterations
146
+ --resume Resume from a previously interrupted run (reuses existing logs)
147
+ --with-review Run review-loop after PR creation (default: 4 iterations)
148
+ --with-review-loops <N> Set review-loop iteration count (implies --with-review)
149
+ --reviewer-backend <be> Reviewer backend: claude|codex (default: codex)
150
+ --diagnostic-log Save full Claude event stream to sidecar files
151
+
152
+ Examples:
153
+ overkill refactor-suggest -n 3 # auto scope (budget-aware)
154
+ overkill refactor-suggest --scope micro -n 3 # function/file-level fixes
155
+ overkill refactor-suggest --scope module -n 2 --dry-run # analyze module duplication
156
+ overkill refactor-suggest --scope layer -n 1 --auto-approve # cross-cutting concerns
157
+ overkill refactor-suggest --scope full -n 1 --create-pr # architecture redesign + PR
158
+ overkill refactor-suggest -n 2 --with-review # auto scope + auto review
159
+ overkill refactor-suggest --scope module -n 3 --with-review-loops 6 # custom review
160
+ ```
161
+
162
+ ## Usage: overkill init
163
+
164
+ Initialize `.review-loop/` in a project directory. Safe to re-run — prompts are refreshed, user-edited configs are preserved.
165
+
166
+ ```
167
+ overkill init [TARGET_DIR] # default: current directory
168
+ ```
169
+
170
+ Creates:
171
+
172
+ ```
173
+ .review-loop/
174
+ ├── prompts/active/ # 10 prompt templates
175
+ ├── .reviewlooprc # review-loop config
176
+ ├── .refactorsuggestrc # refactor-suggest config
177
+ ├── logs/ # runtime logs
178
+ │ └── refactor/ # refactor-suggest logs
179
+ └── .install-manifest # tracks tool-owned files
180
+ ```
181
+
182
+ ### Scopes
183
+
184
+ | Scope | What it looks for | Blast radius |
185
+ |-------|-------------------|--------------|
186
+ | `auto` | Budget-aware automatic selection (default) | Varies — picks the highest scope your token budget allows |
187
+ | `micro` | Complex functions, dead code, in-file duplication | Low — single file |
188
+ | `module` | Cross-file duplication, module boundary issues | Low-medium — within a module |
189
+ | `layer` | Inconsistent error handling, logging, config patterns | Medium-high — across modules |
190
+ | `full` | Wrong abstractions, inverted dependencies, layer violations | High-critical — project-wide |
191
+
192
+ ### How refactor-suggest works
193
+
194
+ ```
195
+ 1. Collect source file list (git ls-files)
196
+ 2. Reviewer (Codex or Claude) analyzes the full codebase for scope-specific refactoring opportunities
197
+ 3. (layer/full) Display refactoring plan and wait for confirmation
198
+ 4. Claude applies refactoring (two-step: opinion → execute)
199
+ 5. Claude self-reviews changes, re-fixes if needed
200
+ 6. Auto-commit & push to refactoring branch
201
+ 7. Repeat until clean or max iterations reached
202
+ 8. (--create-pr) Create draft PR
203
+ 9. (--with-review) Run review-loop on the new PR
204
+ ```
205
+
206
+ Recommended workflow: start with `--dry-run` to review findings, then re-run without it to apply.
207
+
208
+ ## Configuration
209
+
210
+ After running `overkill init`, config files live in `.review-loop/`:
211
+
212
+ ### .review-loop/.reviewlooprc
213
+
214
+ ```bash
215
+ TARGET_BRANCH="main"
216
+ MAX_LOOP=5
217
+ MAX_SUBLOOP=4
218
+ AUTO_COMMIT=true
219
+ REVIEWER_BACKEND="codex" # or "claude"
220
+ PROMPTS_DIR="./custom-prompts"
221
+ ```
222
+
223
+ See `.review-loop/.reviewlooprc` for all available options.
224
+
225
+ ### .review-loop/.refactorsuggestrc
226
+
227
+ ```bash
228
+ SCOPE="auto"
229
+ TARGET_BRANCH="develop"
230
+ MAX_LOOP=3
231
+ MAX_SUBLOOP=4
232
+ # DRY_RUN: safe default — remove to apply fixes (script default: false)
233
+ DRY_RUN=true
234
+ AUTO_APPROVE=false
235
+ CREATE_PR=false
236
+ WITH_REVIEW=false
237
+ REVIEW_LOOPS=4
238
+ REVIEWER_BACKEND="codex" # or "claude"
239
+ PROMPTS_DIR="./custom-prompts"
240
+ ```
241
+
242
+ ## How review-loop works
243
+
244
+ ```
245
+ 1. Check prerequisites (git, codex, claude, jq, envsubst, target branch)
246
+ 2. Create .review-loop/logs/ directory
247
+ 3. Loop (iteration 1..N):
248
+ a. Generate diff: git diff $TARGET...$CURRENT
249
+ b. Empty diff → exit
250
+ c. Reviewer (Codex or Claude, via --reviewer-backend) reviews the diff → JSON with findings
251
+ d. No findings + "patch is correct" → exit
252
+ e. Claude fixes all issues (P0-P3)
253
+ f. Sub-loop (1..MAX_SUBLOOP):
254
+ - Claude self-reviews the uncommitted fixes (git diff)
255
+ - If clean → break
256
+ - Claude re-fixes based on self-review findings
257
+ g. Auto-commit all fixes + re-fixes to branch
258
+ h. Push to remote (updates PR)
259
+ i. Post review/fix/self-review summary as PR comment
260
+ j. Next iteration reviews the updated committed state
261
+ 4. Write summary to .review-loop/logs/summary.md
262
+ ```
263
+
264
+ ## Output Files
265
+
266
+ All logs are git-ignored by default (inside `.review-loop/`).
267
+
268
+ ### review-loop logs (`.review-loop/logs/`)
269
+
270
+ | File | Description |
271
+ |------|-------------|
272
+ | `review-N.json` | Codex review output for iteration N |
273
+ | `opinion-N.md` | Claude's opinion on review findings (iteration N) |
274
+ | `fix-N.md` | Claude fix log for iteration N |
275
+ | `self-review-N-M.json` | Claude self-review output (iteration N, sub-iteration M) |
276
+ | `refix-opinion-N-M.md` | Claude's opinion on self-review findings (iteration N, sub M) |
277
+ | `refix-N-M.md` | Claude re-fix log (iteration N, sub-iteration M) |
278
+ | `summary.md` | Final summary with status and per-iteration results |
279
+
280
+ ### refactor-suggest logs (`.review-loop/logs/refactor/`)
281
+
282
+ | File | Description |
283
+ |------|-------------|
284
+ | `source-files.txt` | List of files analyzed (from `git ls-files`) |
285
+ | `review-N.json` | Codex refactoring analysis for iteration N |
286
+ | `opinion-N.md` | Claude's opinion on refactoring findings (iteration N) |
287
+ | `fix-N.md` | Claude fix log for iteration N |
288
+ | `self-review-N-M.json` | Claude self-review (iteration N, sub-iteration M) |
289
+ | `refix-opinion-N-M.md` | Claude's opinion on self-review findings |
290
+ | `refix-N-M.md` | Claude re-fix log (iteration N, sub-iteration M) |
291
+ | `summary.md` | Final summary with scope, status, and per-iteration results |
292
+
293
+ ## Token Budget Checker
294
+
295
+ The budget checker verifies Claude Code's 5-hour rate limit **before** starting expensive loops.
296
+
297
+ ### How it estimates usage
298
+
299
+ | Mode | Data source | Accuracy |
300
+ |------|-------------|----------|
301
+ | **OAuth** (primary) | macOS Keychain → `security find-generic-password` → Anthropic OAuth API (`/oauth/usage`) | Exact — returns `five_hour.utilization` and `seven_day.utilization` directly from Anthropic |
302
+ | **Local** (fallback) | `~/.claude/projects/**/*.jsonl` session files — sums `input_tokens + output_tokens + cache_creation_input_tokens + cache_read_input_tokens` from `message.usage` of assistant messages in the last 5 hours | Estimated — actual server-side limits are opaque; weekly usage (`seven_day_used_pct`) is unavailable (`null`) |
303
+
304
+ **Tier detection** reads `rateLimitTier` from `~/.claude/telemetry/*.json` (field `event_data.user_attributes`). Mapping: `default` → pro, `default_claude_max_5x` → max5, `default_claude_max_20x` → max20.
305
+
306
+ ### Scope thresholds
307
+
308
+ Go/no-go decision based on current usage percentage:
309
+
310
+ | Scope | Go if used < | Typical use |
311
+ |-------|-------------|-------------|
312
+ | `micro` | 90% | Small single-file fix |
313
+ | `module` | 75% | Multi-file refactoring |
314
+ | `layer` | TBD | Cross-cutting changes |
315
+ | `full` | TBD | Full architecture review |
316
+
317
+ ## Customizing Prompts
318
+
319
+ Edit the templates in `.review-loop/prompts/active/`.
320
+
321
+ ### review-loop prompts
322
+
323
+ - **`codex-review.prompt.md`** — Review prompt sent to Codex. Uses variables: `${CURRENT_BRANCH}`, `${TARGET_BRANCH}`, `${ITERATION}`.
324
+ - **`claude-review.prompt.md`** — Review prompt for Claude reviewer (symlink to codex-review by default).
325
+ - **`claude-fix.prompt.md`** — Opinion prompt: Claude evaluates review findings. Uses: `${REVIEW_JSON}`, `${CURRENT_BRANCH}`, `${TARGET_BRANCH}`.
326
+ - **`claude-fix-execute.prompt.md`** — Execute prompt: tells Claude to fix based on its opinion.
327
+ - **`claude-self-review.prompt.md`** — Self-review prompt for Claude to check its own fixes. Uses: `${REVIEW_JSON}`, `${CURRENT_BRANCH}`, `${TARGET_BRANCH}`, `${ITERATION}`.
328
+
329
+ ### refactor-suggest prompts
330
+
331
+ Each scope has a dedicated prompt with scope-specific instructions, anti-pattern guardrails, and good/bad finding examples:
332
+
333
+ - **`codex-refactor-{micro,module,layer,full}.prompt.md`** — Codex reviewer prompts per scope.
334
+ - **`claude-refactor-{micro,module,layer,full}.prompt.md`** — Claude reviewer prompts (symlinks to codex versions by default).
335
+
336
+ All refactor prompts use variables: `${TARGET_BRANCH}`, `${ITERATION}`, `${SOURCE_FILES_PATH}`.
337
+
338
+ - **`claude-refactor-fix.prompt.md`** — Opinion prompt: Claude evaluates refactoring findings with scope-aware judgment. Uses: `${REVIEW_JSON}`, `${CURRENT_BRANCH}`, `${TARGET_BRANCH}`.
339
+ - **`claude-refactor-fix-execute.prompt.md`** — Execute prompt with safety guards (syntax check, scope overflow detection, regression testing).
340
+
341
+ Reference prompts (read-only originals) are in `prompts/reference/`.
342
+
343
+ ## Priority Levels
344
+
345
+ | Level | Meaning | Action |
346
+ |-------|---------|--------|
347
+ | P0 | Blocking release | Fixed by Claude |
348
+ | P1 | Urgent | Fixed by Claude |
349
+ | P2 | Normal | Fixed by Claude |
350
+ | P3 | Low / nice-to-have | Fixed by Claude |
351
+
352
+ ## Exit Conditions
353
+
354
+ The loop terminates when any of these occur:
355
+
356
+ - **all_clear** — No findings and overall verdict is "patch is correct"
357
+ - **no_diff** — No changes between branches
358
+ - **dry_run** — Review-only mode
359
+ - **max_iterations_reached** — Hit the `-n` limit
360
+ - **auto_commit_disabled** — `--no-auto-commit` or `AUTO_COMMIT=false`; fixes applied but not committed
361
+ - **parse_error** — Could not parse Codex output as JSON
362
+
363
+ ## Uninstall
364
+
365
+ ```bash
366
+ # Quick — just nuke the directory
367
+ rm -rf .review-loop
368
+
369
+ # Also remove the Python package
370
+ pip uninstall overkill # or: uv tool uninstall overkill / pipx uninstall overkill
371
+ ```
372
+
373
+ ## Contributing
374
+
375
+ 1. Fork the repository
376
+ 2. Create a feature branch (`git checkout -b feat/my-feature`)
377
+ 3. Commit your changes
378
+ 4. Open a Pull Request against `develop`
379
+ 5. Run `overkill review-loop -n 3 --dry-run` on your PR branch — **required**. Let Mr. Overkill review your code before a human ever sees it.
380
+
381
+ ## Development
382
+
383
+ ```bash
384
+ git clone https://github.com/modocai/mr-overkill.git
385
+ cd mr-overkill
386
+ uv sync # install dev dependencies
387
+ uv run pytest # run tests
388
+ uv run ruff check src/ tests/
389
+ uv run mypy src/
390
+ ```
391
+
392
+ ## Testing
393
+
394
+ ```bash
395
+ # Python tests
396
+ uv run pytest --tb=short
397
+
398
+ # Bash integration tests (requires bats-core)
399
+ brew install bats-core # one-time setup
400
+ bats test/ # run all tests
401
+ ```
402
+
403
+ ## License
404
+
405
+ [MIT](LICENSE) &copy; 2026 ModocAI