AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Configure Repository Rules and Coding Standards in Sweep Using sweep.yaml

Lam Mui Teng · 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

AI coding assistants that generate pull requests without repository context create a distinct kind of developer fatigue: syntactically valid code that blatantly violates team conventions. Sweep addresses this by letting engineering teams codify repository standards directly into a configuration file named sweep.yaml.

Sweep reads this file on every issue trigger and pull request generation. By placing sweep.yaml in the root of your GitHub repository, you define natural-language coding constraints, expose architectural context, isolate sensitive directories, and execute automated validation checks inside an isolated sandbox before code ever hits a branch.

# sweep.yaml - Production Repository Configuration

# Target branch for Sweep PRs
branch: "main"

# Architectural overview and stack context
description: "Backend service built with Python 3.11 and FastAPI. Business logic lives in app/services/, and database schemas are defined in app/models/."

# Hard isolation: directories Sweep must never touch or read
blocked_dirs:
  - "alembic/versions/"
  - "deploy/terraform/"
  - ".github/workflows/"

# Natural-language coding rules injected into generation prompts
rules:
  - "All new public functions and methods must include explicit PEP 484 type annotations."
  - "Use loguru for structured logging; never use print() or standard logging."
  - "Raise custom exceptions defined in app/core/exceptions.py instead of raw HTTPExceptions."
  - "Every endpoint modification must include an accompanying test in tests/api/."
  - "Keep functions under 40 lines of code; refactor nested conditionals into helper functions."

# Sandbox execution for automated formatting and static linting
sandbox:
  install:
    - pip install poetry
    - poetry install --only dev
  check:
    - poetry run ruff check {file_path}
    - poetry run mypy {file_path}

# Listen to GitHub Actions CI results to auto-repair test failures
gha_enabled: true

# Open pull requests as drafts for human peer review
draft: false

The Core Configuration Directives

Sweep organizes repository customization into four operational layers: context provisioning, prompt constraint injection, directory isolation, and deterministic sandbox validation.

1. Repository Context: description

The description field supplies the primary mental model of the codebase to Sweep's underlying LLM. While Sweep indexes repository files via embeddings, high-level structural semantics can get lost in vector space.

Use this field to declare:

Keep it dense and factual. Vague descriptions like "A web project" waste context window capacity without steering code placement.

2. Behavioral Constraints: rules

The rules array contains plain-English instructions that Sweep appends to its internal prompt chain. When Sweep plans a pull request or writes a diff, it benchmarks candidate solutions against each rule string.

At 365Finds, we categorize effective rules into three specific areas:

Rule CategoryWeak Rule (Vague)Strong Rule (Actionable)
Tooling & Imports"Use good logging.""Use loguru instead of standard print statements. Use logger.exception in except blocks."
Typing & Signatures"Add types everywhere.""All function signatures must have explicit parameter types and return type hints."
Testing Standards"Write tests for code.""Every new service method must have a corresponding test under tests/unit/ using pytest-mock."
Code Style"Write modular clean code.""Avoid functions longer than 50 lines. Split business orchestration from database queries."

Sweep interprets these rules semantically. However, if a rule contradicts standard library conventions without an explicit reason, the model may occasionally waver. State both what to do and what to avoid.

3. Safety Firewalls: blocked_dirs

Autonomous agents should never touch database migrations or security credentials. The blocked_dirs array creates an absolute boundary:

blocked_dirs:
  - "migrations/"
  - "infra/"
  - "secrets/"
  - "vendor/"

Sweep excludes any file matching these prefixes from its search indexing and code generation pipelines. If an issue specifically demands changes inside a blocked directory, Sweep halts and flags the restriction in its tracking comments rather than producing risky modifications.

4. Deterministic Guardrails: sandbox

Prompt engineering alone cannot guarantee syntactic or structural correctness. Sweep's sandbox directive bridges the gap between probabilistic text generation and deterministic build tools.

The sandbox consists of two sequential phases:

For a modern TypeScript codebase:

sandbox:
  install:
    - yarn install --frozen-lockfile
  check:
    - yarn prettier --write {file_path}
    - yarn eslint --fix {file_path}
    - yarn tsc --noEmit

If any command in check exits with a non-zero status code, Sweep captures the standard error output, feeds it back into its repair prompt, and iterates until the file passes or its maximum retry limit is reached.

5. Continuous Feedback: gha_enabled

Setting gha_enabled: true authorizes Sweep to subscribe to repository GitHub Actions webhooks. When Sweep pushes a branch and CI fails on an automated test, Sweep reads the workflow failure logs, generates a patch addressing the assertion error, and pushes an updated commit to the pull request branch.


365Finds Implementation Guidelines

In our assessment at 365Finds, the biggest mistake teams make when deploying Sweep is relying entirely on the rules list to enforce style. Natural language is soft; compilers and formatters are strict.

Combine Rules with Sandboxes

Never write a natural-language rule for something a CLI tool can enforce automatically.

Do not write:

rules:
  - "Ensure indentation is 2 spaces and semicolons are omitted."

Instead, let your linter enforce formatting in the sandbox:

sandbox:
  check:
    - npx prettier --write {file_path}

Reserve rules strictly for architectural intent, semantic library choices (such as choosing TanStack Query over raw fetch), error-handling patterns, and test coverage mandates.

Prevent Rule Bloat

Model attention degrades when bombarded with exhaustive lists. At 365Finds, we recommend keeping rules between 6 and 12 bullet points. When a list exceeds 15 rules, contradictory instructions become common, and the agent tends to prioritize earlier rules while ignoring those near the bottom.

If a coding standard cannot be summarized in a single imperative sentence, refactor the repository's base utilities or create reusable helper functions rather than trying to explain complex state gymnastics to the model inside YAML.

sweep.yaml
└── branch: base target
└── description: architecture summary
└── blocked_dirs: security isolation
└── rules: 6-12 semantic constraints
└── sandbox: deterministic linter loop (install + check)
└── gha_enabled: CI repair loop

Validate Configuration Locally

To verify your configuration without consuming team tier quotas, place sweep.yaml on a feature branch and trigger a simple test issue:

Sweep: Add a health check endpoint at /api/health returning status: "ok"

Inspect the generated PR diff:

  1. Verify whether the new file honors your rules (e.g., proper logger import, docstrings).
  2. Inspect the GitHub Actions run to confirm whether sandbox.check ran cleanly before the commit was pushed.
  3. Confirm that no files in blocked_dirs were touched.

References