Skip to content

[skill][NO-JIRA]improve-backpack-review-skill#4330

Open
IrinaWei wants to merge 4 commits intomainfrom
improve-backpack-review-skill
Open

[skill][NO-JIRA]improve-backpack-review-skill#4330
IrinaWei wants to merge 4 commits intomainfrom
improve-backpack-review-skill

Conversation

@IrinaWei
Copy link
Contributor

Summary

Major upgrade of the backpack-code-review-checklist skill from v2.1.0 to v3.0.2.

This PR restructures the skill into a multi-file architecture, adds a self-improving
learned-patterns agent, and applies performance optimisations that reduce review runtime
from ~16 minutes to ~10 minutes on PRs.

Changes

Architecture: Multi-file layout (v3.0.0)

Previously, all 5 agent prompts were embedded inline inside SKILL.md. They are now
extracted into individual files under agents/, with two new supporting files:

New file Purpose
agents/agent1-constitution.md Constitution & API compliance agent
agents/agent2-sass.md Sass & design token agent
agents/agent3-a11y.md Accessibility & testing agent
agents/agent4-history.md Git history & hotspot agent
agents/agent5-bugs.md Bug scanner agent
agents/agent6-learned.md New — learned patterns agent (mines past PR comments)
domain-knowledge.md Backpack-specific token/colour/component domain knowledge
learn-mode.md Self-improvement workflow (run with learn)

New: Phase 1.5 + Agent 6 — Learned Patterns (v3.0.0)

A new pre-review phase mines the 5 most recently merged PRs for each changed component,
collects raw reviewer comments, and passes them to the new Agent 6. Agent 6 clusters
historical comments into recurring patterns and cross-references them against the current
diff — surfacing issues that the static checklist would otherwise miss.

New rules learned from 40 recent PRs (v3.0.1)

9 rules were extracted via learn mode and embedded directly into agent prompts:

  • Agent 1: semver label accuracy, versioned sub-component naming, variants via type
    prop, no build artifacts in source, Ark-UI internal-usage restriction, unversioned
    src/ layout convention
  • Agent 2: semantic spacing token for icon-to-text gaps ($bpk-spacing-icon-text)
  • Agent 5: Ark-UI keyboard state sync bug pattern, icon alignment helper size mismatch

Performance optimisations (v3.0.2)

Optimisation Before After
Diff fetching Each of 6 agents independently calls gh pr diff Orchestrator fetches once; slices by file type; embeds in prompt
Phase 1 + Phase 1.5 Sequential Parallel (independent steps)
Confidence scoring Separate Phase 3 pass after all agents complete Inline — agents include confidence + confidence_explanation in JSON output
Phase 1.5 (history mining) Always runs Skipped when >70% of changed files are brand-new

Test Plan

  • Run /backpack-code-review-checklist <PR URL> — verify review completes and output is well-formed
  • Run on a PR with .scss changes — verify Agent 2 fires and receives SCSS-scoped diff
  • Run on a PR where >70% files are brand-new — verify Agent 6 is skipped
  • Run /backpack-code-review-checklist learn — verify learn mode executes via learn-mode.md
  • Confirm all output issues include confidence and confidence_explanation

Remember to include the following changes:

  • Ensure the PR title includes the name of the component you are changing so it's clear in the release notes for consumers of the changes in the version e.g [Clover-123][BpkButton] Updating the colour
  • README.md (If you have created a new component)
  • Component README.md
  • Tests
  • Accessibility tests
    • The following checks were performed:
      • Ability to navigate using a keyboard only
      • Zoom functionality (Deque University explanation):
        • The page SHOULD be functional AND readable when only the text is magnified to 200% of its initial size
        • Pages must reflow as zoom increases up to 400% so that content continues to be presented in only one column i.e. Content MUST NOT require scrolling in two directions (both vertically and horizontally)
      • Ability to navigate using a screen reader only
  • Storybook examples created/updated
  • For breaking changes or deprecating components/properties, migration guides added to the description of the PR. If the guide has large changes, consider creating a new Markdown page inside the component's docs folder and link it here

Copilot AI review requested due to automatic review settings March 26, 2026 05:19
@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/4330 to see this build running in a browser.

Copy link
Contributor

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

Upgrades the backpack-code-review-checklist Claude skill to v3.x by splitting embedded prompts into separate agent files, adding a learned-patterns workflow/agent, and updating the orchestrator spec for improved runtime via diff prefetch + parallel phases.

Changes:

  • Restructures the skill into a multi-file architecture with dedicated prompts under agents/.
  • Adds “learn mode” + Agent 6 to mine past PR feedback and surface recurring review patterns.
  • Updates SKILL.md orchestration flow for performance (prefetch diff, parallel Phase 1/1.5, inline confidence scoring).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
.claude/skills/backpack-code-review-checklist/SKILL.md Updates skill spec to v3.0.2, adds Phase 1.5 + Agent 6 integration, and documents performance optimizations.
.claude/skills/backpack-code-review-checklist/learn-mode.md Defines the self-improvement workflow for mining merged PR feedback and proposing prompt updates.
.claude/skills/backpack-code-review-checklist/domain-knowledge.md Adds Backpack token/component domain reference material for edge cases.
.claude/skills/backpack-code-review-checklist/agents/agent1-constitution.md New Constitution/API compliance agent prompt file.
.claude/skills/backpack-code-review-checklist/agents/agent2-sass.md New Sass/token compliance agent prompt file.
.claude/skills/backpack-code-review-checklist/agents/agent3-a11y.md New accessibility/testing compliance agent prompt file.
.claude/skills/backpack-code-review-checklist/agents/agent4-history.md New git history/hotspot analysis agent prompt file.
.claude/skills/backpack-code-review-checklist/agents/agent5-bugs.md New bug scanning agent prompt file.
.claude/skills/backpack-code-review-checklist/agents/agent6-learned.md New learned-patterns agent prompt file consuming Phase 1.5 mined comments.

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

Comment on lines +56 to +61
## Step 4: Package import investigation

For each `import X from '../../bpk-component-Y'`:
1. Read `packages/bpk-component-Y/index.tsx` to see full export list
2. Look for size/variant suffixes (Large, Small, OnDark, V2)
3. Verify the imported variant matches context
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

This agent is scoped to SCSS-only diffs, but Step 4 asks it to inspect JS/TS imports (import X from '../../bpk-component-Y') and read index.tsx. With only .scss changes provided, the agent won’t see those imports and can’t reliably execute this step. Consider moving this investigation to the Constitution/API agent, or rephrasing Step 4 to cover SCSS-relevant @use dependencies instead.

Suggested change
## Step 4: Package import investigation
For each `import X from '../../bpk-component-Y'`:
1. Read `packages/bpk-component-Y/index.tsx` to see full export list
2. Look for size/variant suffixes (Large, Small, OnDark, V2)
3. Verify the imported variant matches context
## Step 4: Sass dependency investigation
For each changed SCSS file, inspect its `@use` statements:
1. Confirm it only uses allowed mixin/token modules (e.g. `../../bpk-mixins/tokens`, `../../bpk-mixins/utils`), not other components’ private SCSS entrypoints.
2. Check that any newly added `@use` is actually referenced in the changed lines (avoid obviously unused `@use`).
3. If the change introduces new visual behavior that should be tokenised or mixed-in, verify the appropriate `@use` dependency has been added (or flag its absence).

Copilot uses AI. Check for mistakes.
> [
> {
> "rule": "One-sentence rule statement",
> "domain": "constitution|sass-tokens|a11y-testing|bug-scan|new",
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

In Step B, the domain options include history, but the JSON schema right below omits it (constitution|sass-tokens|a11y-testing|bug-scan|new). This will produce inconsistent outputs from the clustering step. Align the allowed domain values with the earlier list (either add history to the schema or remove it from the earlier list).

Suggested change
> "domain": "constitution|sass-tokens|a11y-testing|bug-scan|new",
> "domain": "constitution|sass-tokens|a11y-testing|history|bug-scan|new",

Copilot uses AI. Check for mistakes.
```bash
gh pr view [NUMBER] \
--repo Skyscanner/backpack \
--json reviews,comments
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

gh pr view --json reviews,comments is unlikely to capture inline review comments left on diffs; it typically returns review summaries (reviews[].body) plus top-level PR comments. Since learn mode is supposed to mine reviewer comments, include the appropriate field for inline comments (e.g. reviewThreads/review comments) and extract thread comment bodies too, otherwise the learned rules will miss most of the useful feedback.

Suggested change
--json reviews,comments
--json reviews,comments,reviewThreads

Copilot uses AI. Check for mistakes.
Comment on lines +84 to +92
**Diff pre-fetch (critical for performance):** Fetch the full diff once:
```bash
gh pr diff [NUMBER] --repo Skyscanner/backpack # PR mode
git diff main...HEAD # local mode
```
Slice into scoped sections to embed directly in each agent's prompt:
- **SCSS slice** → Agent 2: `gh pr diff [N] --repo Skyscanner/backpack -- '*.scss'`
- **TSX/TS slice** → Agents 1, 3, 5: filter lines for `.ts`/`.tsx` files
- **Full diff** → Agents 4, 6
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Phase 1 claims the diff is pre-fetched once for performance, but the slicing instructions suggest additional gh pr diff calls (e.g. the SCSS slice). That undermines the main optimisation. Prefer slicing the already-fetched diff locally (or fetch once per glob and reuse) so the orchestrator doesn’t reintroduce multiple network calls.

Copilot uses AI. Check for mistakes.
Comment on lines +109 to +111
gh pr view [N] --repo Skyscanner/backpack --json reviews,comments
```
4. Collect raw text from `reviews[].body` and `comments[].body`. Pass to Agent 6 as-is.
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

In Phase 1.5, gh pr view [N] --json reviews,comments likely misses inline review comments on code (the main source of recurring patterns). To make Agent 6 effective, include the JSON field that contains diff-thread comments (e.g. reviewThreads/review comments) and aggregate those bodies along with reviews[].body.

Suggested change
gh pr view [N] --repo Skyscanner/backpack --json reviews,comments
```
4. Collect raw text from `reviews[].body` and `comments[].body`. Pass to Agent 6 as-is.
gh pr view [N] --repo Skyscanner/backpack --json reviews,comments,reviewThreads
  1. Collect raw text from reviews[].body, comments[].body, and inline diff-thread
    comments (for example reviewThreads[].comments[].body). Pass to Agent 6 as-is.

Copilot uses AI. Check for mistakes.
@IrinaWei IrinaWei added patch Patch production bug skip-changelog and removed patch Patch production bug labels Mar 26, 2026
@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/4330 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/4330 to see this build running in a browser.

… redundant snapshot check

- Remove Step 4 (snapshot currency) from agent3-a11y.md — snapshot staleness
  is caught by CI; agent reading .snap files added 65+ tool calls with no value
- Replace permissive "use Read when needed" with diff-first analysis: only read
  files when the diff raises a specific unanswerable question
- Remove snapshot check from SKILL.md Phase 5 for the same reason
- Update autopost default: PR mode now posts inline comments by default;
  use "don't post" / BACKPACK_REVIEW_AUTOPOST=false to suppress
- Fix autopost API call: use --input with JSON file instead of --field
  (gh api --field cannot accept JSON arrays)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/4330 to see this build running in a browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants