Sweep converts GitHub issues into ready-to-merge pull requests. Left without guardrails, however, an autonomous AI developer will happily introduce stylistic inconsistencies, skip internal logging wrappers, and generate foreign design patterns across your codebase. At 365Finds, our stance is clear: you cannot rely on an LLM to divine team culture through git commit history alone. You must give it explicit boundaries.
Sweep enforces repository conventions through a single file placed at the root of your repository: sweep.yaml (or .sweep.yaml). But maintaining genuine consistency requires more than just dumping coding guidelines into a list. The teams that succeed with Sweep employ a dual-layer strategy: semantic prompt rules for architectural intent, paired with deterministic sandbox linters for mechanical syntax.
The Core Configuration File: sweep.yaml
Sweep inspects your repository root for sweep.yaml whenever an issue is dispatched. The configuration file divides responsibilities across several top-level keys:
| Field | Purpose | Enforcement Layer |
|---|---|---|
description | High-level repository context, architecture, and technology stack | Semantic / LLM prompt |
rules | Specific coding guidelines, architectural constraints, and style mandates | Semantic / LLM prompt |
sandbox | Execution commands (install and check) to run linters and formatters | Deterministic / Local container |
blocked_dirs | File paths and directories Sweep is strictly forbidden from editing | Hard boundary / File filter |
gha_enabled | Whether Sweep inspects GitHub Actions CI output to self-correct failures | Deterministic / CI feedback loop |
branch | The default base branch targeted for generated pull requests | Git orchestration |
draft | Whether to open pull requests as drafts by default | Workflow safety |
Layer 1: Defining Semantic Rulebooks (rules & description)
The rules key in sweep.yaml accepts an array of natural language directives. When Sweep processes a task, it injects these rules directly into the system prompts that guide code decomposition and diff creation.
At 365Finds, we consider it an anti-pattern to use rules for mechanical formatting. Telling an LLM "always use 2 spaces and single quotes" wastes prompt attention on rules that a linter handles without cognitive overhead. Reserve rules for design choices, architectural boundaries, and library preferences.
High-Signal Rules vs. Low-Signal Clutter
- Poor rule: "Write clean and readable code." (Too subjective; the LLM ignores it.)
- Effective rule: "Use loguru for all application logging. Call
logger.exception()within catch blocks to preserve stack traces; never use rawprint()statements." - Poor rule: "Format TypeScript files properly." (Redundant if Prettier is installed.)
- Effective rule: "Do not make direct database queries in API route handlers; invoke methods from repository classes located in
src/repositories/." - Effective rule: "Any new public endpoint in
src/api/must include corresponding unit tests intests/api/using pytest."
Providing Architecture Context via description
The description field anchors the LLM's world model. It tells Sweep what frameworks you run, where key entry points live, and how modules interact before the model touches a single line:
description: |
A Python 3.11 backend built on FastAPI and SQLAlchemy 2.0.
Core business logic resides in `src/services/`.
Database models are defined in `src/models/`.
All async endpoints must handle request validation via Pydantic schemas.
Layer 2: Deterministic Enforcement via sandbox
Prompt directives alone cannot guarantee that generated code passes continuous integration. LLMs occasionally hallucinate obsolete syntax or overlook formatting quirks. Sweep solves this through its sandbox configuration.
Before Sweep opens a pull request or updates a branch, it runs an isolated environment where it executes your project's install scripts and applies check commands against modified files using the {file_path} placeholder. If a check command fails, Sweep receives the stdout/stderr error stream and iterates on the code to resolve the problem.
Sandbox Configuration Examples
Python (Poetry + Ruff / Pylint)
sandbox:
install:
- poetry install --no-interaction
check:
- poetry run ruff check --fix {file_path}
- poetry run ruff format {file_path}
- poetry run pylint --errors-only {file_path}
TypeScript & Node.js (Yarn + Prettier + ESLint + TSC)
sandbox:
install:
- yarn install --frozen-lockfile
check:
- yarn prettier --write {file_path}
- yarn eslint --fix {file_path}
- yarn tsc --noEmit
Sweep also supports Trunk out of the box (trunk fmt {file_path} and trunk check {file_path}), which automatically orchestrates multi-language linters if your repository already uses it.
Production-Ready sweep.yaml Blueprint
Here is a comprehensive sweep.yaml configuration that combines architectural guardrails, strict linting, and safety controls:
# Target base branch
branch: 'main'
# Open PRs as draft until reviewed
draft: true
# Enable GitHub Actions inspection for automated test fixing
gha_enabled: true
# Global context for repository architecture
description: |
A modular TypeScript/Next.js and Node.js monorepo.
Frontend components live under `apps/web/`.
API routing and backend controllers reside in `packages/api/`.
Follow modern functional React patterns with strict TypeScript typing.
# Repository-level coding rules and conventions
rules:
- "Never use wildcard imports (e.g., import * from 'module'). Use explicit named imports."
- "All React functional components must have explicit TypeScript interface props definitions."
- "Use custom error classes extending AppError located in packages/api/src/errors/."
- "Any new API route must have a corresponding integration test in tests/integration/."
- "Never commit hardcoded secrets, API tokens, or localhost URLs; consume environment variables via config/env.ts."
# Deterministic sandbox verification
sandbox:
install:
- npm ci
check:
- npx prettier --write {file_path}
- npx eslint --fix {file_path}
- npx tsc --noEmit
# Restricted directories Sweep cannot touch
blocked_dirs:
- "migrations/"
- "prisma/migrations/"
- "infra/"
- ".github/workflows/"
Defensive Guardrails: blocked_dirs and CI Feedback
A critical rulebook strategy is knowing what not to let an AI modify. We strongly urge teams to populate blocked_dirs immediately.
Sweep should never write database migrations autonomously. A subtle schema alteration generated in response to an innocuous issue can break production data pipelines. Similarly, lock down infrastructure-as-code manifests (infra/, terraform/) and CI/CD pipelines (.github/workflows/).
Setting gha_enabled: true completes the feedback loop. When a pull request triggers your existing GitHub Actions test suite, Sweep intercepts failure logs, evaluates stack traces, and commits remedial patches to the branch without developer intervention.
The 365Finds Recommendation: The Dual-Layer Rulebook
When engineering leads ask us how to stop Sweep from generating pull requests that fail code review, our advice is straightforward:
- Do not use
rulesas a style guide. Delegate formatting, whitespace, quotes, and static type validation entirely tosandbox.checkwith tools like Prettier, ESLint, or Ruff. - Use
rulesstrictly for architectural intent and library discipline. Write 5 to 10 specific, testable constraints that a human reviewer would otherwise have to call out in PR comments. - Lock down high-risk surfaces with
blocked_dirs. - Validate your configuration locally. Sweep provides the
sweep-sandboxutility (curl https://raw.githubusercontent.com/sweepai/sweep/main/bin/install_sweep_sandbox.sh | sh) to testsandbox.checkscripts locally before mergingsweep.yamlinto your default branch.