Skip to content

ENH: Add commit and simplify-staged Claude Code skills#36

Merged
aylward merged 4 commits into
Project-MONAI:mainfrom
aylward:commit_and_simplify
Mar 31, 2026
Merged

ENH: Add commit and simplify-staged Claude Code skills#36
aylward merged 4 commits into
Project-MONAI:mainfrom
aylward:commit_and_simplify

Conversation

@aylward
Copy link
Copy Markdown
Collaborator

@aylward aylward commented Mar 31, 2026

Provides /commit (auto-drafts message, fixes pre-commit hook failures, guards against committing to main) and /simplify-staged (reviews staged files for open-source clarity, reuse, and type-annotation standards before committing).

Summary by CodeRabbit

  • Documentation
    • Added user-facing commit and review guidance covering safe commit checks, message format, and per-file simplification recommendations.
  • Chores
    • Introduced standardized developer "skills" docs to unify commit/review practices.
  • New Features
    • CLI: added a prompt-only mode, clarified/renamed flags and messages, enforced branch-safety (rejects main in certain flows), and fetches remote branch data before computing change ranges.

Provides /commit (auto-drafts message, fixes pre-commit hook failures, guards against committing to main) and /simplify-staged (reviews staged files for open-source clarity, reuse, and type-annotation standards before committing).
Copilot AI review requested due to automatic review settings March 31, 2026 16:44
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 31, 2026

Walkthrough

Adds two new skill docs for scripted commits and staged-file simplification, and updates utils/claude_github_reviews.py: replaces dry-run with prompt-only, tightens since-last-push gating (blocks on detached/main), adds git_fetch, prefers upstreamorigin for repo slug, uses fetched ref for reflog cutoff, and includes Write in Claude allowed tools.

Changes

Cohort / File(s) Summary
Workflow Skills
​.claude/skills/commit/SKILL.md, ​.claude/skills/simplify-staged/SKILL.md
Added two new Markdown skill docs: scripted commit workflow enforcing branch safety, diff inspection, TAGged commit message format, and pre-commit remediation; and a staged-file simplification workflow targeting only changes staged by git commit -a, with limited edits and focused ruff fixes on changed .py files.
API Map
docs/API_MAP.md
Updated API map entries and line references for utils/claude_github_reviews.py; added git_fetch(...) doc entry and updated get_repo_slug(...) to document upstream→origin fallback.
GitHub review utility
utils/claude_github_reviews.py
CLI: --dry-run--prompt-only (prints prompt & exits); --since-last-push handling tightened (errors on missing head or main); added git_fetch(repo_root, remote, branch) and calls it before reflog cutoff when using since-last-push; get_repo_slug() now prefers upstream then origin; updated Claude invocation and fallback to include Write in --allowedTools.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI
  participant Git as Git (local)
  participant Remote as Remote (origin/upstream)
  participant Claude as Claude API

  CLI->>Git: parse args (--prompt-only?, --since-last-push?)
  alt since-last-push set and head_ref exists & not main
    CLI->>Git: git_fetch(repo_root, remote, head_ref)
    Git->>Remote: git fetch <remote> <branch>
    Remote-->>Git: fetch result
    Git-->>CLI: fetched refs
    CLI->>Git: compute reflog cutoff using fetched ref
  else if head_ref missing or main
    CLI-->>CLI: exit(1) with error
  end
  CLI->>Git: gather PR/data/diffs
  CLI->>Claude: build prompt (allowedTools includes Read,Write,Edit,Glob,Grep)
  alt prompt-only
    Claude-->>CLI: (not invoked) print prompt and exit
  else
    CLI->>Claude: invoke_claude(prompt)
    Claude-->>CLI: advisory / patches
    CLI->>Git: optionally apply patches or print instructions
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇✍️ I hopped through refs beneath the moonlit tree,
Fetched upstream whispers, kept the main branch free,
I checked the diffs, fixed hooks, and polished lines,
Prompt in paw, I nudged the repo to shine,
A cheerful commit — then off to nibble glee.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding two new Claude Code skills (commit and simplify-staged) as documented in the new SKILL.md files and referenced in the PR objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds two new Claude Code “skills” intended to standardize and automate common pre-commit workflows in the PhysioMotion4D repo.

Changes:

  • Introduces a /commit skill to draft commit messages, enforce “no commits to main”, and iterate on pre-commit failures until a commit succeeds.
  • Introduces a /simplify-staged skill to review tracked, would-be-committed changes for clarity/reuse/typing/docstring standards before committing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
.claude/skills/commit/SKILL.md New commit automation skill (branch guard, message drafting, pre-commit remediation loop).
.claude/skills/simplify-staged/SKILL.md New pre-commit review/simplification checklist skill for tracked modified files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .claude/skills/commit/SKILL.md Outdated
Comment on lines +2 to +5
description: Stage all changes, draft a commit message from the diff, fix any pre-commit hook failures, and repeat until the commit succeeds.
---

Commit all pending changes in the PhysioMotion4D repository.
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frontmatter/intro says this skill will "Stage all changes" / "Commit all pending changes", but later the instructions explicitly prohibit adding untracked files and require behavior equivalent to git commit -a (tracked changes only). Please reword the description and/or the intro sentence to reflect that this only commits tracked modifications/deletions, not new files.

Suggested change
description: Stage all changes, draft a commit message from the diff, fix any pre-commit hook failures, and repeat until the commit succeeds.
---
Commit all pending changes in the PhysioMotion4D repository.
description: Stage all tracked modifications and deletions, draft a commit message from the diff, fix any pre-commit hook failures, and repeat until the commit succeeds.
---
Commit all tracked pending changes in the PhysioMotion4D repository (equivalent to `git commit -a`, not including new untracked files).

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +31
- Optional body: 1–3 sentences explaining *why*, not *what*.

3. Attempt the commit:
```
git commit -a -m "<subject>" -m "<body with co-author line>"
```
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 2 says the commit body is optional, but step 3 always includes a second -m and mentions "body with co-author line". This is contradictory and will push a body even when none is needed, and the co-author requirement seems out of scope. Consider making the second -m conditional (only when a body is warranted) and removing the co-author reference unless the project has a documented co-author convention.

Suggested change
- Optional body: 1–3 sentences explaining *why*, not *what*.
3. Attempt the commit:
```
git commit -a -m "<subject>" -m "<body with co-author line>"
```
- Optional body: 1–3 sentences explaining *why*, not *what*; omit if not needed.
3. Attempt the commit:
- If you only need a subject line:
```
git commit -a -m "<subject>"
```
- If you also wrote a body:
```
git commit -a -m "<subject>" -m "<body>"
```

Copilot uses AI. Check for mistakes.
## Instructions

1. Run `git diff HEAD` to get the full diff of tracked modified files.
Also run `git diff HEAD --name-only` to list just the changed files.
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git diff HEAD --name-only is likely to be parsed as a pathspec (--name-only) after the revision, rather than an option, so it may not list changed files as intended. Use git diff --name-only HEAD (option before revision, optionally with -- before paths) to reliably produce the file list.

Suggested change
Also run `git diff HEAD --name-only` to list just the changed files.
Also run `git diff --name-only HEAD` to list just the changed files.

Copilot uses AI. Check for mistakes.
Comment thread .claude/skills/simplify-staged/SKILL.md Outdated
- [ ] Is there dead code (unreachable branches, unused imports, stale comments)?
Remove it.

4. After editing, run `ruff check . --fix && ruff format .` to enforce code style.
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running ruff check . --fix && ruff format . can modify files outside the current change set, which conflicts with the earlier instruction to avoid refactoring code that was not changed. To keep the skill's behavior aligned with its own constraints, consider running Ruff only on the modified Python files (or explicitly instruct to revert any unrelated Ruff-only changes before proceeding).

Suggested change
4. After editing, run `ruff check . --fix && ruff format .` to enforce code style.
4. After editing, run Ruff only on the modified Python files to enforce code style, for example:
- `git diff --name-only HEAD | grep -E '\.py$' | xargs -r ruff check --fix`
- `git diff --name-only HEAD | grep -E '\.py$' | xargs -r ruff format`
If your workflow runs Ruff project-wide, revert any Ruff-only changes in files outside the current diff before committing.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.claude/skills/commit/SKILL.md:
- Around line 22-31: The commit template in SKILL.md is ambiguous about
co-author attribution; update step 2 to state when to include a co-author (e.g.,
when others made substantive contributions) and specify the required format
"Co-authored-by: Name <email>" (optional unless required by repo policy), or
alternatively change step 3's example command to use just "-m \"<body>\"" if
co-authors are not standard; ensure references in the document to "body with
co-author line" and the example commit command are updated to match the chosen
behavior so readers see consistent guidance.
- Around line 29-31: The fenced code block showing the git commit command is
missing a language identifier, causing MD040 markdownlint warnings; update the
block in SKILL.md by adding a language tag (e.g., "bash") to the opening fence
so the block becomes ```bash and retains the same content ("git commit -a -m
\"<subject>\" -m \"<body with co-author line>\""), ensuring syntax highlighting
and satisfying the linter.
- Around line 16-20: The instructions conflict by forbidding committing
secrets/untracked files while requiring "ONLY perform the equivalent to a `git
commit -a`"; change to selective staging: replace the `git commit -a`
requirement with an explicit "ONLY stage files you have explicitly reviewed and
approved" workflow, update the commit example to remove the `-a` flag and
instruct contributors to run `git add` only the files they've inspected (and not
to add untracked files), and remove/replace any line that mandates `git commit
-a` so the steps for inspection (lines mentioning secrets/large
binaries/untracked files) are consistent with the commit command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3292bcb5-6b3c-4379-a803-bdedc9b18c34

📥 Commits

Reviewing files that changed from the base of the PR and between 666146f and 04a507c.

📒 Files selected for processing (2)
  • .claude/skills/commit/SKILL.md
  • .claude/skills/simplify-staged/SKILL.md

Comment thread .claude/skills/commit/SKILL.md Outdated
Comment on lines +16 to +20
1. Run `git diff HEAD` and `git status` to understand what has changed.
- Read any modified source files that are not self-explanatory from the diff alone.
- Do NOT commit files that look like secrets, large binaries, or generated artefacts that belong in .gitignore.
- Do NOT add any untracked files to the commit
- ONLY perform the equivalent to a `git commit -a`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Logic conflict between selective exclusion and git commit -a behavior.

Lines 18-19 instruct to "Do NOT commit files that look like secrets, large binaries, or generated artefacts" and "Do NOT add any untracked files to the commit," but line 20 mandates using "the equivalent to a git commit -a".

The git commit -a command automatically stages all tracked modified files—you cannot selectively exclude specific files with this flag. If a tracked file contains secrets or unwanted artifacts, git commit -a will stage and commit it.

To reconcile this conflict, the workflow should either:

  1. Option A (Recommended): Modify step 1 to use selective staging instead of -a:

    • After inspection in step 1, explicitly git add only the files that should be committed
    • Remove the -a flag from the git commit command in step 3
    • Update line 20 to: "ONLY stage files you have explicitly reviewed and approved"
  2. Option B: Add an intermediate unstaging step:

    • Keep git commit -a but add explicit instructions between steps 1 and 2 to run git restore --staged <file> for any files that should be excluded
    • This is more error-prone and harder to automate

Without this fix, contributors following these instructions could accidentally commit sensitive data.

🔒 Proposed fix (Option A - selective staging)
 1. Run `git diff HEAD` and `git status` to understand what has changed.
    - Read any modified source files that are not self-explanatory from the diff alone.
    - Do NOT commit files that look like secrets, large binaries, or generated artefacts that belong in .gitignore.
    - Do NOT add any untracked files to the commit
-   - ONLY perform the equivalent to a `git commit -a`
+   - After inspection, stage only the approved files with `git add <file>...`

 2. Draft a commit message following the project convention (match style of recent `git log --oneline -10`):
    - Subject line: `<TAG>: <imperative summary>` (≤72 chars), where TAG is one of:
      `ENH` (new feature / enhancement), `FIX` (bug fix), `REF` (refactor),
      `TST` (tests only), `DOC` (docs/comments only), `MNT` (maintenance / config).
    - Optional body: 1–3 sentences explaining *why*, not *what*.

 3. Attempt the commit:
    ```bash
-   git commit -a -m "<subject>" -m "<body with co-author line>"
+   git commit -m "<subject>" -m "<body>"
    ```
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/skills/commit/SKILL.md around lines 16 - 20, The instructions
conflict by forbidding committing secrets/untracked files while requiring "ONLY
perform the equivalent to a `git commit -a`"; change to selective staging:
replace the `git commit -a` requirement with an explicit "ONLY stage files you
have explicitly reviewed and approved" workflow, update the commit example to
remove the `-a` flag and instruct contributors to run `git add` only the files
they've inspected (and not to add untracked files), and remove/replace any line
that mandates `git commit -a` so the steps for inspection (lines mentioning
secrets/large binaries/untracked files) are consistent with the commit command.

Comment thread .claude/skills/commit/SKILL.md
Comment thread .claude/skills/commit/SKILL.md
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@666146f). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #36   +/-   ##
=======================================
  Coverage        ?   13.67%           
=======================================
  Files           ?       49           
  Lines           ?     6596           
  Branches        ?        0           
=======================================
  Hits            ?      902           
  Misses          ?     5694           
  Partials        ?        0           
Flag Coverage Δ
integration-tests 13.67% <ø> (?)
unittests 13.67% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Apply PR Project-MONAI#36 review fixes: bash code fences, scope ruff to modified files, git restore escape hatch, git push reminder. Add --prompt_only flag to claude_github_reviews.py for interactive use, Write to allowedTools, and default remote to upstream with origin fallback.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
.claude/skills/commit/SKILL.md (1)

17-21: Consider documenting the escape hatch for aborting the commit workflow.

The PR objectives mention providing "a git restore escape hatch," but this section doesn't explicitly tell users how to abort and unstage if they change their mind after inspection. Consider adding a note that users can run git restore --staged . to unstage everything if they decide not to proceed.

📝 Proposed addition
 1. Run `git diff HEAD` and `git status` to understand what has changed.
    - Read any modified source files that are not self-explanatory from the diff alone.
    - If any tracked file contains secrets, large binaries, or generated artefacts
      that should not be committed, display an error, stop processing, and abort
    - Do NOT add any untracked files to the commit.
+   - If you need to abort and unstage all changes, run: `git restore --staged .`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/skills/commit/SKILL.md around lines 17 - 21, Add a short
escape-hatch note to the checklist step that begins "Run `git diff HEAD` and
`git status`" explaining how to abort/unstage if the user changes their mind:
instruct them to run `git restore --staged .` (or `git restore --staged <path>`
for a specific file) to unstage files and cancel the commit preparation, and
remind them not to add untracked files back. Place this sentence immediately
after that checklist bullet so users see the restore command during inspection.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.claude/skills/commit/SKILL.md:
- Around line 38-45: Replace the global ruff invocation "ruff check . --fix &&
ruff format ." with a scoped invocation that runs ruff only on staged/modified
files: update the instruction text in the step that mentions `ruff check . --fix
&& ruff format .` to instruct collecting modified/staged filenames (e.g., via
`git diff --name-only --cached` or `git ls-files -m`) and then run `ruff check
--fix` and `ruff format` against that file list; ensure the updated guidance
explicitly says to run ruff only on staged/modified files and not the whole
repo.

In `@utils/claude_github_reviews.py`:
- Around line 511-513: The --remote default "upstream" can fail on repos that
only have "origin"; update the handling so that when the '--since-last-push'
flow reads the parsed remote variable (remote) it first checks whether that
remote actually exists (e.g., via `git remote` or `git remote get-url`) and if
not falls back to "origin" (and only errors if neither exists). Change the code
path that uses the remote variable in the --since-last-push logic to perform
this existence check and substitution before calling the reflog/last-push logic
so users with only "origin" won't need to override the flag.
- Around line 582-596: The output text still says "dry run" while the flag has
been renamed to prompt_only; update the print statement that emits the prompt
header so it uses consistent prompt_only wording (e.g., replace "PROMPT (dry run
— not sent to Claude)" with something like "PROMPT (prompt_only — not sent to
Claude)" or "PROMPT (prompt-only — not sent to Claude)"). Locate the block
guarded by args.prompt_only and adjust the string printed for the prompt header
(the print that currently prints the title before printing the variable prompt);
ensure other messages in that block (which reference args.prompt_only, prompt,
and summary_filename) remain unchanged and consistent.
- Around line 495-498: Add a backward-compatible alias so scripts using the old
flag still work: when you call parser.add_argument for "--prompt_only" in
utils/claude_github_reviews.py, also register "--dry-run" (or pass both as
argument names) wired to the same store_true action and same destination, and
update the help text to mention both names; ensure the code uses the single dest
(e.g., prompt_only) so both flags map to the same boolean variable.

---

Nitpick comments:
In @.claude/skills/commit/SKILL.md:
- Around line 17-21: Add a short escape-hatch note to the checklist step that
begins "Run `git diff HEAD` and `git status`" explaining how to abort/unstage if
the user changes their mind: instruct them to run `git restore --staged .` (or
`git restore --staged <path>` for a specific file) to unstage files and cancel
the commit preparation, and remind them not to add untracked files back. Place
this sentence immediately after that checklist bullet so users see the restore
command during inspection.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3477befa-7359-444e-bfc0-1a623345a44e

📥 Commits

Reviewing files that changed from the base of the PR and between 04a507c and 7ecd65f.

📒 Files selected for processing (4)
  • .claude/skills/commit/SKILL.md
  • .claude/skills/simplify-staged/SKILL.md
  • docs/API_MAP.md
  • utils/claude_github_reviews.py
✅ Files skipped from review due to trivial changes (2)
  • docs/API_MAP.md
  • .claude/skills/simplify-staged/SKILL.md

Comment thread .claude/skills/commit/SKILL.md
Comment thread utils/claude_github_reviews.py Outdated
Comment thread utils/claude_github_reviews.py Outdated
Comment on lines 511 to 513
default="upstream",
help="Git remote name for reflog (default: upstream; used with --since-last-push)",
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

--since-last-push default can fail on repos without upstream.

Line 511 defaults --remote to upstream, but Line 552 uses it directly with no fallback. In clones that only have origin, this breaks --since-last-push unless users override manually.

Suggested fallback patch
-    parser.add_argument(
-        "--remote",
-        metavar="NAME",
-        default="upstream",
-        help="Git remote name for reflog (default: upstream; used with --since-last-push)",
-    )
+    parser.add_argument(
+        "--remote",
+        metavar="NAME",
+        default=None,
+        help="Git remote name for reflog (default: upstream, falling back to origin; used with --since-last-push)",
+    )
-    if args.since_last_push:
+    if args.since_last_push:
+        remote_name = args.remote
+        if remote_name is None:
+            for candidate in ("upstream", "origin"):
+                probe = subprocess.run(
+                    ["git", "remote", "get-url", candidate],
+                    text=True,
+                    capture_output=True,
+                    cwd=repo_root,
+                )
+                if probe.returncode == 0:
+                    remote_name = candidate
+                    break
+            if remote_name is None:
+                print("[ERROR] Could not read git remote URL from 'upstream' or 'origin'.")
+                sys.exit(1)
         head_ref = pr_data.get("head", {}).get("ref")
         if not head_ref:
             print("[ERROR] PR has no head branch ref; cannot use --since-last-push.")
             sys.exit(1)
-        remote_ref = f"refs/remotes/{args.remote}/{head_ref}"
-        cutoff = get_remote_reflog_cutoff(repo_root, args.remote, head_ref)
+        remote_ref = f"refs/remotes/{remote_name}/{head_ref}"
+        cutoff = get_remote_reflog_cutoff(repo_root, remote_name, head_ref)

Also applies to: 546-553

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@utils/claude_github_reviews.py` around lines 511 - 513, The --remote default
"upstream" can fail on repos that only have "origin"; update the handling so
that when the '--since-last-push' flow reads the parsed remote variable (remote)
it first checks whether that remote actually exists (e.g., via `git remote` or
`git remote get-url`) and if not falls back to "origin" (and only errors if
neither exists). Change the code path that uses the remote variable in the
--since-last-push logic to perform this existence check and substitution before
calling the reflog/last-push logic so users with only "origin" won't need to
override the flag.

Comment thread utils/claude_github_reviews.py Outdated
…b review script

Scope ruff to modified files in commit skill. Add --dry-run alias for --prompt_only, fix --remote default to origin, auto-fetch before reflog lookup, and fix stale dry-run wording in prompt_only output.
Copilot AI review requested due to automatic review settings March 31, 2026 18:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

Comments suppressed due to low confidence (1)

utils/claude_github_reviews.py:536

  • The new CLI flag --since_last_push breaks the existing hyphenated option style used elsewhere in this repo and is a backward-incompatible rename from --since-last-push. Consider accepting --since-last-push as the primary/alias option (keeping dest="since_last_push") to preserve compatibility and match established argparse conventions in this codebase.
    parser.add_argument(
        "--since_last_push",
        action="store_true",
        help=(
            "Only include inline comments and reviews after the latest reflog time "
            "for refs/remotes/<remote>/<PR_head_branch> (this clone)"
        ),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread utils/claude_github_reviews.py Outdated
Comment on lines +51 to +63
def get_current_branch(repo_root: Path) -> str:
"""Return the name of the currently checked-out branch."""
try:
out = subprocess.run(
["git", "rev-parse", "--show-toplevel"],
["git", "branch", "--show-current"],
check=True,
text=True,
capture_output=True,
cwd=repo_root,
)
return Path(out.stdout.strip())
return out.stdout.strip()
except subprocess.CalledProcessError:
print("[ERROR] Not inside a Git repository.")
sys.exit(1)
return ""
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_current_branch() is currently unused in this script. Consider removing it to avoid dead code, or use it to enforce a concrete behavior (e.g., refuse to run on certain branches) so it stays covered by the script’s logic.

Copilot uses AI. Check for mistakes.
Comment on lines 523 to 529
parser.add_argument(
"--prompt_only",
"--dry-run",
dest="prompt_only",
action="store_true",
help="Print the prompt that would be sent to Claude and exit without changes",
)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, --prompt_only is an underscore-style long option, which is inconsistent with the repo’s other scripts (typically --kebab-case). Consider adding a --prompt-only alias (and possibly deprecating --dry-run more explicitly) to keep CLI UX consistent.

Copilot uses AI. Check for mistakes.
Comment thread utils/claude_github_reviews.py Outdated
@@ -488,14 +521,15 @@ def parse_args() -> argparse.Namespace:
help="GitHub repo slug (default: inferred from git remote origin)",
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --repo help text says the slug is inferred from the origin remote, but get_repo_slug() now prefers upstream (falling back to origin). Update the help text to reflect the actual inference behavior so users know which remote is consulted.

Suggested change
help="GitHub repo slug (default: inferred from git remote origin)",
help=(
"GitHub repo slug (default: inferred from git remote upstream, "
"falling back to origin)"
),

Copilot uses AI. Check for mistakes.
Comment thread .claude/skills/simplify-staged/SKILL.md Outdated

2. For each modified Python file, read the **entire file** — not just the diff.
Understanding the unchanged context is necessary to judge whether the new code
fits naturally.
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 2 says to read the entire file for each modified Python file, but git diff HEAD --name-only / git diff HEAD can include deleted/renamed files. Add guidance to skip deleted files (or read the prior version via git show HEAD:<path>) so the workflow doesn’t fail when a changed file no longer exists on disk.

Suggested change
fits naturally.
fits naturally. If a path from `git diff HEAD --name-only` no longer exists on
disk (for example, the file was deleted or renamed), skip it, or, if you need to
inspect its previous contents, read it via `git show HEAD:<path>` instead.

Copilot uses AI. Check for mistakes.
Comment thread .claude/skills/simplify-staged/SKILL.md Outdated
Comment on lines +59 to +62
4. After editing, run ruff only on the Python files that appear in the diff
(`git diff HEAD --name-only`). Pass only those `.py` files to
`ruff check --fix` and `ruff format`. Do not run ruff project-wide — it
may reformat files outside the current change set.
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 4 suggests running ruff on Python files from git diff HEAD --name-only, but that list can include deleted paths, which will cause ruff to error. Filter to existing .py files (and/or exclude D status) before invoking ruff check / ruff format.

Suggested change
4. After editing, run ruff only on the Python files that appear in the diff
(`git diff HEAD --name-only`). Pass only those `.py` files to
`ruff check --fix` and `ruff format`. Do not run ruff project-wide — it
may reformat files outside the current change set.
4. After editing, run ruff only on Python files that both appear in the diff
and still exist on disk. For example, use
`git diff --diff-filter=d --name-only HEAD -- '*.py'` to list changed,
non-deleted `.py` files, and pass only that list to `ruff check --fix`
and `ruff format`. Do not run ruff project-wide — it may reformat files
outside the current change set.

Copilot uses AI. Check for mistakes.
Comment thread .claude/skills/commit/SKILL.md Outdated
Comment on lines +13 to +14
If the branch is `main`, stop immediately and report:
"ERROR: Refusing to commit directly to main. Please switch to a feature branch first."
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 0 only guards against committing on main, but git branch --show-current returns an empty string in a detached HEAD state. Consider treating an empty branch name as an error as well (refuse to commit) to avoid creating commits on detached HEAD unexpectedly.

Suggested change
If the branch is `main`, stop immediately and report:
"ERROR: Refusing to commit directly to main. Please switch to a feature branch first."
If the command returns no branch name (empty output / detached HEAD) or the branch is `main`,
stop immediately and report an appropriate error, e.g.:
"ERROR: Refusing to commit in detached HEAD or directly to main. Please switch to a named feature branch first."

Copilot uses AI. Check for mistakes.
Comment thread .claude/skills/commit/SKILL.md Outdated
Comment on lines +41 to +43
- For `ruff` formatting/lint: run ruff only on the modified Python files
(`git diff HEAD --name-only`), not the whole repo. Pass only those `.py`
files to `ruff check --fix` and `ruff format`.
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ruff guidance uses git diff HEAD --name-only to select files, but that list can include deleted paths; running ruff on missing files will fail. Filter to existing .py files (and/or use git diff --name-status to exclude deletions) before invoking ruff.

Suggested change
- For `ruff` formatting/lint: run ruff only on the modified Python files
(`git diff HEAD --name-only`), not the whole repo. Pass only those `.py`
files to `ruff check --fix` and `ruff format`.
- For `ruff` formatting/lint: run ruff only on the modified Python files,
using `git diff --name-status HEAD` (or `git diff HEAD --name-only`) to list
changed paths, filtering out deleted entries and non-`.py` files, and passing
only existing `.py` files to `ruff check --fix` and `ruff format`.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
utils/claude_github_reviews.py (1)

531-537: ⚠️ Potential issue | 🟠 Major

Add --since-last-push as a backward-compatible alias.

The CLI only registers --since_last_push (underscore, line 531), but README.md (line 693) documents --since-last-push (hyphen). Users following the README will encounter an unrecognized argument error.

Suggested fix
     parser.add_argument(
         "--since_last_push",
+        "--since-last-push",
+        dest="since_last_push",
         action="store_true",
         help=(
             "Only include inline comments and reviews after the latest reflog time "
             "for refs/remotes/<remote>/<PR_head_branch> (this clone)"
         ),
     )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@utils/claude_github_reviews.py` around lines 531 - 537, The CLI currently
registers the flag "--since_last_push" in the parser.add_argument call but
README documents the hyphenated "--since-last-push", causing an unrecognized
argument error; update the parser.add_argument invocation that defines
"--since_last_push" (the add_argument call in utils/claude_github_reviews.py) to
also accept a backward-compatible alias "--since-last-push" (e.g., add the
hyphenated string to the same add_argument call and ensure both map to the same
dest/since_last_push with action="store_true") so both forms are supported
without changing behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@utils/claude_github_reviews.py`:
- Around line 94-96: Update the user-facing help text for the CLI flag that
documents repository resolution to match get_repo_slug's behavior of checking
"upstream" then "origin" (not origin-only); find the help string used for the
--repo/--repository argument and change its wording to indicate it will look for
upstream first and fall back to origin so it aligns with get_repo_slug's remote
resolution logic.

---

Outside diff comments:
In `@utils/claude_github_reviews.py`:
- Around line 531-537: The CLI currently registers the flag "--since_last_push"
in the parser.add_argument call but README documents the hyphenated
"--since-last-push", causing an unrecognized argument error; update the
parser.add_argument invocation that defines "--since_last_push" (the
add_argument call in utils/claude_github_reviews.py) to also accept a
backward-compatible alias "--since-last-push" (e.g., add the hyphenated string
to the same add_argument call and ensure both map to the same
dest/since_last_push with action="store_true") so both forms are supported
without changing behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9ceb1cbe-f894-4f75-90c3-9f47bade1dfc

📥 Commits

Reviewing files that changed from the base of the PR and between 7ecd65f and 250b495.

📒 Files selected for processing (3)
  • .claude/skills/commit/SKILL.md
  • docs/API_MAP.md
  • utils/claude_github_reviews.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/API_MAP.md

Comment thread utils/claude_github_reviews.py
…ew script

Guard detached HEAD in commit skill. Use --diff-filter=d for ruff in both skills. Skip deleted files in simplify-staged. Remove unused get_current_branch(). Fix --repo help text and rename CLI args to kebab-case.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.claude/skills/commit/SKILL.md:
- Around line 41-43: Update the instruction for running Ruff so it explicitly
handles the case of no modified Python files: after running git diff
--diff-filter=d --name-only HEAD -- '*.py' check whether the result is empty
and, if so, skip running ruff check --fix and ruff format; otherwise pass only
the listed files to those commands. Mention the git diff command and the ruff
commands (ruff check --fix, ruff format) by name so readers know to
conditionally skip Ruff when no files are returned.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5e76246c-7db1-4c53-bf19-4a09a8734dc7

📥 Commits

Reviewing files that changed from the base of the PR and between 250b495 and afbadd6.

📒 Files selected for processing (4)
  • .claude/skills/commit/SKILL.md
  • .claude/skills/simplify-staged/SKILL.md
  • docs/API_MAP.md
  • utils/claude_github_reviews.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • .claude/skills/simplify-staged/SKILL.md
  • utils/claude_github_reviews.py

Comment thread .claude/skills/commit/SKILL.md
@aylward aylward merged commit 7e4a155 into Project-MONAI:main Mar 31, 2026
14 checks passed
@aylward aylward deleted the commit_and_simplify branch March 31, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants