Recommendation
Use a multi-root VS Code workspace that enables Copilot only for actively edited packages and disables it for generated/third-party code. Combine lightweight workspace prompts (standard file headers) with strict CI checks (typecheck, lint, tests, semgrep) and automated gating for any PRs with AI-tagged commits.
Why this works
A 2M-line monorepo contains lots of irrelevant context that increases false or unsafe suggestions. Multi-root controls and explicit per-folder settings keep the model’s context window focused. CI gates catch regressions and risky patterns that a developer or Copilot might miss.
Concrete VS Code + Copilot settings (workspace-level)
- In .code-workspace, disable Copilot at the root and enable per-package folder that you want suggestions for. Key settings to use:
- "github.copilot.enable": false (root workspace)
- "github.copilot.inlineSuggest.enable": false (root workspace)
- "editor.inlineSuggest.enabled": false (root workspace)
- files excluded (root):
"files.exclude": { "**/node_modules": true, "**/dist": true, "**/build": true, "**/generated": true }
"search.exclude": same globs
"files.watcherExclude": same globs
- For an editable package folder in the same .code-workspace, override:
- "github.copilot.enable": true
- "github.copilot.inlineSuggest.enable": true
- "editor.inlineSuggest.enabled": true
Workspace prompt / developer instruction (copyable header)
Add a one-line standard comment at the top of new source files so Copilot picks up project constraints:
// PROJECT_PROMPT: TypeScript, strict mode, follow ESLint rules, prefer named exports, avoid experimental APIs, do not modify files under /generated or /vendor
(Require devs to include this via a file header snippet or repo template.)
Exclusion rules (what to exclude from suggestions and edits)
- Always exclude: node_modules, dist, build, generated, vendor, .cache
- Disable Copilot or mark directories read-only: tooling outputs, protobuf/GRPC generated code, third-party SDKs
- Use a .copilot-exclude.txt (team convention) and a pre-commit hook that rejects commits that change excluded paths without a human override.
CI checkpoints to catch bad AI edits
1. Fast gate (run on PR): tsc --noEmit for entire repo or affected packages (use Nx/changeset to limit scope), ESLint --max-warnings=0, Prettier --check.
2. Security/static checks: semgrep rules for insecure patterns (eval, hardcoded secrets, weak crypto), dependency audit (npm/yarn audit or Snyk).
3. Behavioral tests: run unit tests for affected packages (nx affected:test or similar). Fail PR if changed-lines > X (e.g., 100) without explicit human review.
4. Meta checks: a GitHub Action that flags commits with commit-message prefix like "copilot:" or a PR checkbox “Contains AI edits” and then requires a code owner approval step.
5. Optional: run automated mutation tests or contract tests for critical packages.
Decision criteria (pick what to enforce)
- Budget: full CI (semgrep + Snyk + mutation) costs more; minimal = typecheck+lint+tests.
- Team size/skill: small teams can use stricter repo-wide disable + per-file human opt-in. Large teams should automate detection and require code-owner approval for AI edits.
- Workflow stage: early iteration = looser rules; release branches = strict gating.
Best-for / Avoid-if
- Best-for: teams that need high precision in suggestions and want to avoid AI hallucinations across many packages.
- Avoid-if: very small repos where global Copilot is sufficient and the overhead of multi-root/workspace rules outweighs benefit.
Practical checklist (apply today)
1. Create .code-workspace and set root Copilot off + file excludes.
2. Add folders for packages you want active and enable Copilot per-folder.
3. Add standard PROJECT_PROMPT header snippet and file template.
4. Add pre-commit hook to prevent commits in excluded paths (husky + lint-staged or pre-commit).
5. Add CI jobs: tsc, eslint, prettier, semgrep, affected tests; fail PRs with >100 changed lines automatically.
6. Require a PR checkbox/commit prefix for AI edits and protect main with CODEOWNER review.
If you want, I can produce a ready .code-workspace snippet, a sample header template, and a GitHub Actions job matrix for the CI gates. (Tool: GitHub Copilot can assist with generating per-file snippets.)
Compare GitHub Copilot and Cursor