Skip to content

fix(review): harden SKILL.md against weak-model rule skipping#4340

Merged
pomelo-nwu merged 2 commits into
QwenLM:mainfrom
wenshao:fix-review-skill-weak-model-guards
May 20, 2026
Merged

fix(review): harden SKILL.md against weak-model rule skipping#4340
pomelo-nwu merged 2 commits into
QwenLM:mainfrom
wenshao:fix-review-skill-weak-model-guards

Conversation

@wenshao

@wenshao wenshao commented May 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Weak models (and small fast models) running /review sometimes skip parts of the long SKILL.md prompt and fall back to familiar defaults:

  • Running gh pr checkout / git checkout <branch> to switch the working tree into the PR, instead of going through qwen review fetch-pr which isolates the PR into an ephemeral worktree. This contaminates the user's local branch state.
  • Running the Step 8 autofix prompt ("Apply auto-fixes? (y/n)") even when the user passed --comment, which is supposed to mean "only post inline PR comments, do not touch code".

Both of these are already implied by SKILL.md, but the relevant rules are scattered in the middle of long sections and easy to miss. This PR reinforces them with three small additions — no CLI changes:

  • Critical rules (top of file): promote the two most-violated rules to slots pre-release: fix ci #1 and Where is the config saved? #2 — worktree is mandatory for PR reviews, and --comment skips Step 8 entirely. Existing language/API rules become 如何自定义密钥文件 .env可能与其他文件冲突 #3 and Are you interested in AI Terminal? #4.
  • Step 1 (PR branch): add an inline ⚠️ MANDATORY worktree flow blockquote that names the specific forbidden commands (gh pr checkout, git checkout <branch>, git switch, git pull, git reset --hard) and points at qwen review fetch-pr as the only entry point.
  • Step 8 (Autofix): add an explicit skip block at the top listing the three conditions that bypass autofix — --comment specified, cross-repo lightweight mode, or no fixable findings. A weak model now sees the skip rule before it sees "If there are Critical or Suggestion findings…".

Notes

  • git fetch <remote> pull/<n>/head:<ref> is not in the forbidden list — it doesn't touch the working tree and is what qwen review fetch-pr itself uses internally.
  • The cross-repo lightweight skip for Step 8 was already documented in Step 1 (line 38). The new Step 8 header restates it so a model that jumped straight to Step 8 still sees it.
  • No frontmatter or allowedTools changes, so the existing bundled-skills.integration.test.ts parse test continues to cover this file.

Test plan

  • Run /review <pr-number> with a smaller/faster model and confirm it uses the worktree at .qwen/tmp/review-pr-<n> (verify with git worktree list) and does not switch the user's HEAD.
  • Run /review <pr-number> --comment with the same model and confirm Step 8 is skipped silently (no "Apply auto-fixes? (y/n)" prompt) and flow goes Step 7 → Step 9 directly.
  • Run /review <pr-number> (without --comment) and confirm Step 8 still triggers as before for fixable findings.
  • Run a cross-repo PR review (URL with no matching remote) and confirm Step 8 is still skipped (lightweight mode).

Weak models often skip parts of the long /review prompt and fall back
to familiar defaults — `gh pr checkout` instead of the worktree flow,
or running the autofix prompt even when the user passed `--comment`
(which means "only post inline comments, don't mutate code").

Three reinforcements, all in SKILL.md (no CLI changes):

- Promote the two most commonly violated rules to the top of the
  "Critical rules" list: worktree is mandatory for PR reviews, and
  `--comment` skips Step 8 entirely.
- Add an inline blockquote at the top of the Step 1 PR branch that
  names the specific forbidden commands (`gh pr checkout`,
  `git checkout`, `git switch`, `git pull`, `git reset --hard`).
- Add an explicit skip block at the top of Step 8 listing the three
  conditions that bypass autofix — `--comment`, cross-repo lightweight
  mode, or no fixable findings — so a weak model doesn't have to
  infer them from scattered earlier text.
@github-actions

Copy link
Copy Markdown
Contributor

📋 Review Summary

This PR strengthens the SKILL.md review skill by promoting two commonly-violated rules to the top "Critical rules" section and adding explicit guard blocks to prevent weak/fast models from skipping key constraints. The changes are documentation-only (no CLI code changes) and address real observed failure modes: models switching the user's working tree instead of using the mandatory worktree flow, and running autofix prompts when --comment flag should skip that step entirely.

🔍 General Feedback

  • Well-structured incremental improvement that follows the "make implicit rules explicit" pattern
  • Good separation of concerns: critical rules at top, contextual warnings at point-of-use in Steps 1 and 8
  • The diff stat (13 additions, 3 deletions) shows surgical precision — only adding what's needed
  • Smart to keep the forbidden command list explicit (gh pr checkout, git checkout <branch>, git switch, git pull, git reset --hard) rather than vague language
  • Good consistency check: cross-repo lightweight mode skip condition is now documented in both Step 1 and Step 8, reducing chance a model jumping to Step 8 will miss it

🎯 Specific Feedback

🔵 Low

  • SKILL.md:line 21 — The reordered critical rules now put worktree and --comment rules at slots 1-2, pushing language-matching to slot 3. Consider whether language-matching should remain in the "Critical rules" section at all, or move to a separate "Output formatting" section. Having 4 rules in "Critical rules" dilutes the urgency — the first two are genuinely critical (data loss / unwanted mutations), while the latter two are more about output format. That said, keeping them together is defensible if these are the most-violated rules empirically.

  • SKILL.md:line 49 — The mandatory worktree flow warning block uses ⚠️ emoji in a markdown blockquote. This is clear, but consider whether this should also get a numbered rule reference like "See Critical Rule pre-release: fix ci #1" to create bidirectional linking between the top-level rule and its contextual reminder at point-of-use. Same for Step 8's skip block referencing Critical Rule Where is the config saved? #2.

  • SKILL.md:line 451 — The Step 8 skip conditions list three bullets, but the third bullet ("There are no Critical or Suggestion findings with concrete, applicable fixes") is already implied by the opening "Otherwise, if there are Critical or Suggestion findings..." clause. This redundancy isn't harmful — it may actually help weak models — but it's worth noting that the first two bullets are the real value-add here.

✅ Highlights

  • Excellent problem diagnosis: the PR description clearly identifies the root cause (rules scattered in long sections, easy for weak models to miss) rather than just treating symptoms
  • Strategic placement of guard rails: putting the most-violated rules at the very top ensures they're seen first, even by models that skim or jump to specific sections
  • The explicit forbidden command list is practical and actionable — models can pattern-match against these exact strings
  • Good test plan coverage: the four test scenarios (worktree verification, --comment skip, normal autofix, cross-repo skip) cover the critical paths
  • Maintains backward compatibility: the changes don't break existing workflows, they just add guardrails that were supposed to be implicit
  • Smart to note that git fetch <remote> pull/<n>/head:<ref> is NOT forbidden — this shows nuanced understanding of what "touching the working tree" actually means

@wenshao wenshao marked this pull request as draft May 20, 2026 03:59
@wenshao wenshao marked this pull request as ready for review May 20, 2026 10:30
@wenshao wenshao requested a review from yiliang114 May 20, 2026 13:33
Comment thread packages/core/src/skills/bundled/review/SKILL.md Outdated
Comment thread packages/core/src/skills/bundled/review/SKILL.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Reinforces the /review bundled skill instructions to prevent weak models from skipping key rules, specifically around mandatory PR worktree isolation and disabling autofix behavior when --comment is used.

Changes:

  • Promotes worktree isolation and --comment → skip autofix guidance to the top “Critical rules” section.
  • Adds an explicit “MANDATORY worktree flow” warning block in Step 1, including a list of forbidden git commands that mutate the user’s working tree.
  • Adds a prominent “Skip Step 8” header in the Autofix section enumerating bypass conditions (--comment, cross-repo lightweight mode, no fixable findings).

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

Comment thread packages/core/src/skills/bundled/review/SKILL.md Outdated
Follow-up to the initial harden pass, addressing the inline review
comments on PR QwenLM#4340.

Rule #1 (worktree mandatory):
- Scope it to **same-repo PR reviews** so cross-repo PRs running in
  lightweight mode (no matching local remote, no worktree) don't read
  as a contradiction.
- Replace "Your very first action" with "After argument parsing and
  remote detection, the first command that touches code state" — the
  literal "very first" was wrong since `--comment` parsing and
  URL/remote disambiguation legitimately run before `fetch-pr`.
- Align the forbidden-command list with the Step 1 blockquote (add
  `git pull` and `git reset --hard`) so a weak model that only reads
  the Critical rules section sees the same five commands as a model
  that reaches the blockquote at the point of use.
- Add an explicit "cross-repo PRs use lightweight mode" parenthetical
  so the same model knows where to look for the alternative path.

Step 8 skip block:
- Drop the redundant third bullet ("no Critical or Suggestion findings
  with concrete, applicable fixes") — it was both logically equivalent
  to the "Otherwise" clause below and used a different qualifier
  ("concrete, applicable" vs "clear, unambiguous"), risking a weak
  model treating them as two distinct thresholds.
- "ANY of the following" → "EITHER" since only two bullets remain.
- Fold the no-findings case into the Otherwise clause as a no-op note.

@pomelo-nwu pomelo-nwu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Solid hardening of the review skill, and the approach is right — promoting the two most-violated rules to the top "Critical rules" block and restating the Step 8 skip at its point-of-use is exactly how you make a long prompt robust against weaker/faster models that don't read the whole thing.

A few notes:

  • Giving worktree-isolation slot #1 is well justified: gh pr checkout / git switch contaminating the user's working tree is a far worse failure than a stylistic slip, so it earns the top slot over the language rule.
  • The redundancy between Critical rule #2 and the new Step 8 skip block is good, not duplication — a model that jumps straight to Step 8 still sees the --comment skip. The PR body already calls this out.
  • Minor: the forbidden-command list is now stated in both Critical rule #1 and the Step 1 blockquote. If they ever drift, a weak model may trust whichever it reads first. Consider keeping the authoritative list in one place and referencing it from the other — and adding the note that git fetch <remote> pull/<n>/head:<ref> is the one allowed fetch (it's in the PR description but not in SKILL.md itself).

Direction and content both LGTM.

中文

对 review skill 的合理强化,方向正确:把两条最常违反的规则提到顶部 Critical rules,并在 Step 8 处就地重申跳过条件,正是让长 prompt 对弱/快模型更稳健的做法。

  • worktree 隔离规则排到 #1 合理:gh pr checkout / git switch 污染用户工作树比风格问题严重得多,值得压过语言规则居首。
  • Critical #2 与新增 Step 8 跳过块的冗余是有意为之、并非重复——直接跳到 Step 8 的模型仍能看到 --comment 跳过规则,PR 描述已说明。
  • 小建议:禁用命令清单现在同时出现在 Critical #1 和 Step 1 引用块两处,若日后不同步,弱模型可能信它先读到的那份。可考虑只在一处维护权威清单、另一处引用;并补一句 git fetch <remote> pull/<n>/head:<ref> 是唯一允许的 fetch(你在 PR 描述提了,但 SKILL.md 正文没写)。

方向与内容都 LGTM。

@pomelo-nwu pomelo-nwu merged commit 96fa061 into QwenLM:main May 20, 2026
15 checks passed
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.

4 participants