Skip to content

chore(copilot): update instruction files for copilot#7971

Draft
nineteen88 wants to merge 2 commits into
masterfrom
copilotInstructionUpdate
Draft

chore(copilot): update instruction files for copilot#7971
nineteen88 wants to merge 2 commits into
masterfrom
copilotInstructionUpdate

Conversation

@nineteen88
Copy link
Copy Markdown
Contributor

Proposed behaviour

Split out the copilot files so that we have instructions for vscode and separate instructions for github copilot

Current behaviour

Currently the instructions are being loaded into context for copilot in vscode and this means there's a lot of information in there that isn't required for it as much of it was for github copilot only. We can separate out the concerns to reduce the context payload and therefore reduce the amount of tokens we use

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

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

This PR splits Copilot guidance into separate instruction files for VS Code coding assistance vs. GitHub Copilot review, while keeping a smaller shared set of repo conventions.

Changes:

  • Adds a VS Code-specific Copilot instruction file and wires it up via workspace settings.
  • Introduces a dedicated GitHub Copilot code review instruction file.
  • Refactors the existing shared Copilot instructions into a shorter, surface-agnostic document.

Reviewed changes

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

File Description
.vscode/settings.json Configures VS Code Copilot Chat code generation to load instructions from .vscode/copilot.md.
.vscode/copilot.md Adds VS Code-focused coding workflow/testing/preferences guidance (intended to be lighter-weight).
.github/copilot-review-instructions.md Adds GitHub Copilot review-only checks (breaking changes, skills sync, commit type mismatch, etc.).
.github/copilot-instructions.md Replaces the prior long-form agent instructions with a condensed shared set of repo/environment/convention notes and references.
Comments suppressed due to low confidence (4)

.vscode/copilot.md:8

  • suggestion: align the setup command here with the repo’s stated required environment (shared instructions recommend updating npm to 11.11.1 before running npm run setup) to avoid toolchain mismatches.
1. Setup: `nvm use && npm run setup`
2. Edit `src/`. API/props/behaviour/docs change → `npm run build:skills` + commit result

.github/copilot-instructions.md:40

  • issue: the documented npm run build pipeline order is inaccurate (per package.json, the sequence is clean-lib → generate-tokens → type-check → rollup → build:generate-package-json-files → build:move-svg → build:types). Please correct this so contributors follow the real build chain.
| PW CT | `npm run test:ct` (`*.pw.tsx`) |
| Build | `npm run build` (clean→tokens→types→rollup→pkg-jsons→svg→d.ts) |
| Skills | `npm run build:skills -- --check` |

.vscode/copilot.md:10

  • issue: this suggests tests live in <name>.test.tsx, but Jest matches both *.spec.* and *.test.* (see jest.config.ts). Document both patterns to avoid contributors creating tests that don’t run.
3. Tests: `<name>.test.tsx` (jsdom, 100% coverage new code). Browser behaviour → `<name>.pw.tsx`
4. Validate (in order): `npm run format` → `npm run lint` → `npm run type-check` → `npm test -- <spec>` → `npm test` → `npm run build:skills -- --check` → `npm run build` (if needed) → `npm run test:ct -- <pw>` (if needed)

.vscode/copilot.md:16

  • issue: the example command npm test -- path/to/file.test.tsx is too specific; the repo also uses *.spec.* tests. Consider using a neutral placeholder (e.g. path/to/file.(spec|test).tsx) so the guidance matches the configured testMatch.
- Fast loop: `npm test -- path/to/file.test.tsx`
- Full: `npm test`

Comment thread .vscode/copilot.md
Comment thread .github/copilot-instructions.md

### 1. Undeclared breaking changes

Block if PR lacks `!` or `BREAKING CHANGE:` footer AND does any of:
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.

suggestion: I think we should tweak this a little bit, the removal of a storybook story shouldn't be considered a breaking change, also removing data- tags or class names is not breaking if they're not exported to consumers.

It may also be worth clarifying that changes to an index.ts is only breaking when it does not sit within an /__internal__/ file path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Made changes as requested

@nineteen88 nineteen88 force-pushed the copilotInstructionUpdate branch 2 times, most recently from f8cfb19 to 2d94d62 Compare May 22, 2026 13:28
split out the copilot files so that we have instructions for vscode and seperate instructions for
github copilot
@nineteen88 nineteen88 force-pushed the copilotInstructionUpdate branch from 2d94d62 to c82bda0 Compare May 22, 2026 13:45

Run these locally before pushing — CI runs the exact same commands and a PR will fail if any of them fail:
- "Cannot find module .../static-tokens" → run `generate-tokens:dev`
- `nwsapi` SyntaxError → `:has()` in styled-components + jsdom. Avoid or use role queries
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.

comment: support for :has() was added in nwsapi 2.3.0 and it looks liek we use 2.3.9

- Add unused `eslint-disable`
- Raise `--max-warnings` ceiling
- Use `:has()` in styles tested by jsdom
- Broad snapshot tests
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.

question: will this flag the ones we've used in the tokens (old and new) tests? I agree with this beyond them just not sure if they'll be flagged etc


### 3. Commit type mismatch

`chore:`/`docs:`/`style:`/`refactor:`/`test:`/`build:`/`ci:` = no version bump. Flag user-visible behaviour/API/runtime-dep changes in these → needs `feat:`/`fix:` (+ `!` if breaking).
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.

comment: we don't support using ! as a breaking change marker

Comment thread .vscode/copilot.md
## Preferences

- Minimal focused edits, not broad rewrites
- RTL: `getByRole`/`getByLabelText` over `getByTestId`
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.

question: will this flag findByTestId as well or do we need to explicitly define that?

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

Development

Successfully merging this pull request may close these issues.

4 participants