AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Configure sweep.yaml to Enforce Repository-Specific Coding Standards

Kim Hyuk-chul · 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

Drop an autonomous AI developer into a repository without strict guardrails, and you will quickly witness the regression of your architecture to the mean of generic GitHub open-source code. Left to its own defaults, Sweep will happily guess your architectural patterns, invent unnecessary wrapper utilities, scatter tests into random directories, and open pull requests against whatever branch it assumes is active. At 365Finds, we have tracked how teams integrate autonomous coding agents: the difference between an indispensable automated teammate and an exhausting code-review burden comes down to a single configuration file—sweep.yaml.

This root-level configuration dictates how Sweep scans your codebase, generates edits, and verifies its work before opening a pull request. If you want deterministic code rather than hallucinated patterns, you must configure sweep.yaml as an infrastructure specification rather than a polite suggestion box.


The Production-Ready sweep.yaml Template

Here is a tested, production-grade template designed to constrain Sweep to modern conventions, isolate dangerous directories, and run automated lint checks prior to PR generation:

# Target baseline branch for Sweep PRs
branch: "main"

# Keep PRs as drafts to avoid triggering expensive CI pipelines prematurely
draft: true

# Allow Sweep to inspect GitHub Actions logs to fix its own test failures
gha_enabled: true

# High-level architecture context and structural conventions
description: |
  This repository is a Python 3.11 service built on FastAPI and SQLAlchemy 2.0.
  Core API routers reside in `app/api/v1/`. Data models reside in `app/models/`.
  We enforce absolute global imports (e.g., `from app.core.config import settings`).
  All asynchronous database queries must use SQLAlchemy 2.0 select syntax.

# Absolute directory exclusions to prevent out-of-scope edits
blocked_dirs:
  - "alembic/versions/"
  - "frontend/build/"
  - "scripts/deploy/"
  - ".github/workflows/"

# Repository-specific coding standards enforced during generation
rules:
  - "All new business logic must include corresponding pytest unit tests placed in a tests/ directory mirroring the source path."
  - "Use structlog for structured logging; never use raw print statements or standard logging."
  - "All functions and methods must have full type annotations using Python standard collection generics (list, dict, tuple) instead of typing module equivalents."
  - "Never catch generic Exception without re-raising or logging with structured traceback."
  - "Do not introduce new third-party dependencies in requirements.txt or pyproject.toml unless explicitly instructed in the issue."

# Isolated sandbox execution to mechanically validate edits before PR creation
sandbox:
  install:
    - poetry install --no-interaction
  check:
    - poetry run ruff check {file_path}
    - poetry run ruff format --check {file_path}

Core Configuration Blocks and Defensive Strategies

Configuring sweep.yaml requires understanding the boundary between what language models handle well through natural language and what must be locked down mechanically.

┌─────────────────────────────────────────────────────────────┐
│                         sweep.yaml                          │
├──────────────────────────────┬──────────────────────────────┤
│ Natural Language Context     │ Deterministic Guardrails     │
│                              │                              │
│ • description                │ • branch & draft             │
│   (framework, import style)  │ • blocked_dirs (no-go zones) │
│ • rules                      │ • sandbox (linters / tests)  │
│   (anti-patterns, paradigms) │ • gha_enabled (CI loops)     │
└──────────────────────────────┴──────────────────────────────┘

1. Lock Down Targets and Boundaries (branch & blocked_dirs)

By default, an AI agent might assume development happens on master, main, or an unmerged feature branch. Explicitly setting branch: "main" (or your designated integration branch like develop) ensures Sweep references the correct HEAD commit when calculating diffs.

More critical is blocked_dirs. AI agents should never touch database migrations, CI/CD pipeline definitions, compiled assets, or vendor directories. At 365Finds, we consider open-ended file modification access a major operational risk. If Sweep hallucinates an edit inside an Alembic migration file (alembic/versions/), it can corrupt schema tracking across the team. Specify sensitive directories as strict string paths in the blocked_dirs array.

2. Establish Architectural Grounding (description)

The description field is injected into Sweep's reasoning prompt. Many engineers make the mistake of writing marketing copy or high-level product visions here. That wastes token budget and dilutes focus.

Use description to state four technical realities:

3. Formulate Deterministic Directives (rules)

The rules array defines the discrete constraints Sweep checks when drafting code changes. Vague rules such as "write clean code" or "follow best practices" yield negligible results because the model defaults to generic training data.

Effective rules follow two patterns:

Rule TypeIneffective ExampleHigh-Impact 365Finds Standard
Negative Constraint"Keep code clean and organized.""Never use raw print() or console.log() statements; use the repository logger."
Typing Standard"Use proper types everywhere.""All exported TypeScript interfaces must use strict type definitions; 'any' is strictly prohibited."
Testing Requirement"Write tests for your changes.""Every new utility function must have an accompanying test in tests/ matching the filename suffix '_test.py'."
Dependency Gate"Be careful with packages.""Do not edit package.json or modify dependencies unless the issue prompt specifically mandates it."

At 365Finds, we recommend limiting rules to between five and eight well-crafted constraints. When teams load twenty separate rules into sweep.yaml, instruction adherence degrades due to attention dilution. Focus on your team's most frequently violated PR review comments.

4. Close the Loop with Deterministic Linters (sandbox)

Prompting an LLM to adhere to style guidelines is inherently probabilistic. Real engineering reliability requires deterministic tooling. The sandbox block allows Sweep to execute environment setup and file-level linter checks inside an isolated container before submitting code.

Using {file_path} inside sandbox.check allows fast, targeted execution:

sandbox:
  install:
    - npm ci
  check:
    - npx eslint {file_path}
    - npx prettier --check {file_path}

When Sweep modifies a file, it executes the check commands. If the linter reports syntax violations or formatting issues, Sweep receives the compiler output and self-corrects before pushing a commit. This single step eliminates trivial formatting back-and-forth during team code reviews.

5. Control Delivery Velocity (draft & gha_enabled)

We strongly advocate setting draft: true. When Sweep generates a draft PR, team members can review the diff without triggering entire multi-stage deployment workflows or notifying the whole engineering channel.

Coupling this with gha_enabled: true allows Sweep to inspect failure logs from automated GitHub Actions test runs. If a unit test fails on CI, Sweep parses the traceback and attempts an automated fix commit.


365Finds Assessment: Balancing Guardrails Against Agent Autonomy

Sweep functions best as a junior engineer that handles repetitive chores: scaffolding CRUD boilerplate, retrofitting type definitions, updating test coverage, and resolving well-scoped bug reports. It does not excel at open-ended architectural redesigns.

Our assessment at 365Finds is that relying solely on natural-language rules is a trap. Teams often blame AI models for hallucinating dependencies or generating sloppy diffs, when the root failure is an unconfigured repository. An unconfigured Sweep installation uses broad assumptions. A hardened sweep.yaml turns an unpredictable conversational model into a disciplined, bounded contributor that respects the existing codebase.

Commit your sweep.yaml to the root directory, treat rule changes as version-controlled code, and continuously prune ineffective rules whenever you can enforce them via linter hooks in the sandbox instead.


References