AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Configure GitHub Copilot and Sweep for Repository-Specific Coding Standards

Yu Jinquan · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Generic AI suggestions are the fastest way to clutter a clean codebase. Left unguided, GitHub Copilot will happily propose deprecated APIs, violate your layered architecture, or invent utility methods that already exist elsewhere in your repository. Sweep, acting as an autonomous background contributor on GitHub issues, will generate pull requests that fail your continuous integration pipeline simply because it didn't know you preferred Zod over Joi or loguru over standard Python logging.

At 365Finds, we consider repository-level configuration mandatory rather than optional. If you want AI assistants to act like seasoned teammates instead of reckless interns, you must anchor them to your repository's conventions.

Fortunately, GitHub Copilot and Sweep approach this problem through complementary, Git-tracked configuration files: .github/copilot-instructions.md for interactive developer workflows, and sweep.yaml for autonomous PR generation. Here is how to configure both, keep them aligned, and eliminate style drift across your team.


1. Configuring GitHub Copilot via .github/copilot-instructions.md

GitHub Copilot reads repository-wide instructions through a dedicated Markdown file placed directly inside your repository. When a developer triggers Copilot Chat, uses Copilot in VS Code or Visual Studio, or requests Copilot Code Review, this file is loaded into the prompt context.

File Location

Create the file at:

.github/copilot-instructions.md

(If you are hosting on Azure DevOps, the equivalent path is .azuredevops/copilot-instructions.md.)

Core Content to Include

365Finds strongly advises keeping this file concise—under 250 lines. Large documents waste context window space and dilute model attention. Focus strictly on what Copilot cannot guess from inspecting a single file:

  1. Tech Stack & Explicit Versions: List language versions, runtime targets, and major frameworks.
  2. Directory Architecture: State which layers hold business logic, controllers, database models, and types.
  3. Strict Invariants and Anti-Patterns: Tell Copilot what it is strictly forbidden from doing (e.g., raw SQL strings, any types in TypeScript, mutative state updates).
  4. Testing and Linting Commands: Specify test runners and formatting tools so Copilot suggests appropriate commands during chat sessions.

Concrete Example

# Repository Coding Standards & Architecture

## Tech Stack
- TypeScript 5.4, Node.js 20 LTS, Next.js 14 (App Router)
- PostgreSQL with Prisma ORM
- Zod for payload schema validation
- Vitest for unit testing

## Architectural Boundaries
- Server Actions & Route Handlers reside in `app/api/` or `app/actions/`.
- Core domain logic must live in `lib/services/`. Do not execute database queries inside React components.
- Database models must only be imported through `lib/db.ts`.

## Coding Conventions
- Always declare explicit return types on public functions. Never use `any`.
- Prefer functional components and named exports.
- Use early returns to reduce indentation depth.
- Handle expected errors using custom domain classes (`AppError`), not bare string throws.

## Commands
- Lint: `pnpm run lint`
- Typecheck: `pnpm run typecheck`
- Test: `pnpm run test:unit`

2. Configuring Sweep via sweep.yaml

While GitHub Copilot assists the engineer writing code in the IDE, Sweep operates asynchronously. It reads GitHub issues, inspects the codebase, plans changes, and submits ready-to-review pull requests.

Because Sweep generates commits autonomously, its configuration file—sweep.yaml—requires structured operational parameters alongside coding guidelines.

File Location

Place the configuration file at the root of your repository:

sweep.yaml

Key Configuration Keys

Concrete Example

# sweep.yaml
branch: "main"
gha_enabled: true
draft: false

# Contextual summary for Sweep's RAG index
description: >
  Next.js 14 App Router project written in TypeScript. 
  Domain logic sits in lib/services, and tests live in tests/. 
  We use Prisma for database operations and Zod for validation.

# Paths Sweep is forbidden from editing
blocked_dirs:
  - "prisma/migrations/"
  - ".github/workflows/"
  - "dist/"

# Coding standards enforced during generation
rules:
  - "Always define Zod validation schemas for any incoming request payload."
  - "Do not write database queries inside API route handlers; call services in lib/services instead."
  - "Never use TypeScript 'any'; explicitly type all parameters and returns."
  - "All new utility functions or service methods must include a matching unit test in tests/."
  - "Use pnpm rather than npm or yarn for all package references."

# Pre-PR validation sandbox
sandbox:
  install:
    - pnpm install --frozen-lockfile
  check:
    - pnpm run typecheck
    - pnpm run lint
    - pnpm run test:unit

3. Comparing the Enforcement Mechanisms

365Finds views these two tools not as competitors, but as two checkpoints along the development lifecycle. Understanding how each engine applies rules prevents team frustration.

Feature / DimensionGitHub Copilot (.github/copilot-instructions.md)Sweep (sweep.yaml)
Execution SurfaceReal-time in IDE (Chat, inline suggestions, PR review)Asynchronous GitHub bot (Issue to PR)
Configuration FormatMarkdown (.md)YAML (.yaml)
Enforcement MethodPrompt context injection in chat and code generationPrompt rules plus active sandbox test execution
Directory Scope ControlContextual Markdown files (or scoped .instructions.md)Explicit blocked_dirs array
Self-VerificationNone natively in editor; relies on local developer runnersandbox.check runs linters and test suites before PR creation
Best Suited ForInteractive drafting, immediate style hints, in-editor reviewsChores, isolated bugfixes, automated refactoring PRs

4. How 365Finds Recommends Managing Both

Maintaining two configuration files often risks rule divergence. When the team adopts a new linter rule or replaces an ORM, someone updates Copilot's prompt and forgets Sweep, or vice versa.

To keep both tools strictly in sync, 365Finds recommends the following workflow:

  1. Treat .github/copilot-instructions.md as the human-readable specification. Write your architecture principles, banned patterns, and style preferences there in clear bullet points.
  2. Derive sweep.yaml rules as an exact subset of those bullet points. Each bullet in copilot-instructions.md that governs code syntax or import boundaries should map directly to an entry under rules: in sweep.yaml.
  3. Leverage Sweep's sandbox.check as the ultimate filter. While Copilot cannot run tests for you before suggesting a snippet, Sweep can. Adding your linter and test command to sandbox.check ensures that even if Sweep bends a prompt rule, your automated test suite catches it before human review.
  4. Focus on negative constraints. Generative AI models struggle with broad positive affirmations like "Write clean, maintainable code." They excel when given precise negative boundaries: "Never use console.log in src/", "Do not import lodash directly; use lodash-es", or "Never query Prisma inside UI components."

Both files live in Git alongside your code, meaning modifications to coding standards go through regular pull request reviews. When you change an architectural convention, the prompt updates land in the exact same commit as the code change.

References