Autonomous AI coding agents present a specific operational hazard: left unguided, they write code that compiles, passes superficial checks, and completely disregards your repository's established conventions. They invent new helper utilities when canonical ones already exist, pull in unsolicited third-party dependencies, skip unit tests, and format code according to whatever public repositories dominated their training sets.
For teams running Sweep—an AI developer that turns GitHub issues into complete pull requests—the primary mechanism to prevent this style drift is sweep.yaml. Placed at the root of a repository, this configuration file establishes explicit boundaries, architectural context, and natural-language coding rules that govern Sweep's code generation, planning, and validation stages.
At 365Finds, we look at developer automation tools through a pragmatic lens: an AI agent that saves ten minutes writing a routine feature but costs twenty minutes in code-review cleanup is a net negative. Here is our breakdown of how sweep.yaml works, how to configure repository rules to enforce coding conventions, and where its limits lie.
The Anatomy of sweep.yaml
Sweep reads sweep.yaml directly from the base branch on every triggered task. While the file supports several operational flags, five core parameters directly shape code quality and stylistic alignment:
| Key | Type | Operational Impact on Conventions |
|---|---|---|
rules | Array of strings | Direct, high-priority instructions injected into the agent's context during planning, code modification, and review. |
description | String | Global architectural context defining your tech stack, framework versions, directory patterns, and primary entry points. |
blocked_dirs | Array of strings | Strict path boundaries preventing Sweep from reading or modifying legacy, vendor, or generated directories. |
sandbox | Object (install, check) | Sandboxed execution commands that run formatters, linters, and test suites immediately after file edits. |
gha_enabled | Boolean | Allows Sweep to parse GitHub Actions logs and self-correct when continuous integration tests fail. |
# sweep.yaml - Production baseline for full-stack repositories
branch: "main"
draft: false
gha_enabled: true
description: "Python 3.11 backend with FastAPI and SQLAlchemy 2.0; TypeScript React frontend. Business logic resides strictly in src/services/."
blocked_dirs:
- "legacy/"
- "alembic/versions/"
- "frontend/build/"
rules:
# Style & Formatting
- "All Python functions must have explicit type annotations for parameters and return values; use built-in generics (list, dict) rather than typing module aliases."
- "Never use wildcard imports (e.g., from module import *)."
- "Remove all temporary print statements, debug logging, and obvious explanatory comments before submitting."
# Dependencies & Architecture
- "Use loguru for application logging. In except blocks, call logger.exception() to preserve stack traces."
- "Do not introduce new external libraries or packages without updating pyproject.toml and documenting the rationale in the pull request description."
- "All database mutations must use existing SQLAlchemy session dependencies; never open raw engine connections."
# Unit Testing Requirements
- "Every new business function in src/services/ must have an accompanying pytest test suite located in tests/."
- "Mock external HTTP requests using responses or pytest-mock; never execute live network requests during test runs."
- "Aim for complete boundary condition coverage, including null inputs, invalid payloads, and timeout scenarios."
sandbox:
install:
- poetry install --no-interaction
check:
- ruff check {file_path}
- pytest {file_path}
How Repository Rules Shape Agent Behavior
The rules block is not merely documentation; Sweep parses these items as active constraints during each phase of execution.
1. Style and Idiom Constraints
General LLM models often default to generic, verbose code patterns. In Python, for instance, an agent might mix typing.List with modern built-in list[] syntax, or leave trivial inline comments like # increments counter.
By framing rules as declarative negatives and explicit standards, you eliminate predictable style review bikeshedding:
- "Do not write inline comments explaining what the next line of code does; write comments only when documenting non-obvious business logic."
- "Enforce strict PascalCase for TypeScript interface names prefixed without an 'I' (e.g., UserProfile, not IUserProfile)."
2. Dependency and Architectural Boundaries
One of the most dangerous tendencies of automated coding bots is "dependency hallucination"—importing libraries that seem logical to the model but bloat your dependency tree or clash with internal architectural standards.
When you specify dependencies explicitly in rules, Sweep restricts itself to chosen frameworks:
- Standardizing logging: "Use loguru instead of Python's built-in logging module or standard print statements."
- Locking state management: "Use Zustand stores located in src/stores/; do not introduce Redux or unmanaged React context."
- Protecting database patterns: "Do not write raw SQL strings. All queries must utilize SQLAlchemy ORM 2.0 select syntax."
3. Unit Testing and Verification Rigor
Left unprompted, an AI developer will resolve an issue, check if the file syntax is valid, and immediately declare victory. In a mature repository, untracked code without regression coverage is technical debt.
Specifying testing requirements in rules compels Sweep to write both production code and test files in the same pull request:
- Framework and directory co-location: "All test files must use pytest and mirror the source tree inside tests/unit/."
- Mocking standards: "Never attempt live database or network connections in unit tests. Use factory-boy fixtures and pytest mock patches."
- Failure path coverage: "Test suites must assert error handling and expected exceptions alongside happy-path assertions."
Layering Natural Language with Deterministic Checks
Here is 365Finds' definitive stance on sweep.yaml: natural language rules are soft guardrails, not deterministic compilers.
If you rely solely on natural language statements like "Write clean, readable code", Sweep will interpret that ambiguity through statistical probability, leading to inconsistent outputs across different runs. The real power of sweep.yaml emerges when you combine the rules array with deterministic feedback loops:
- The
sandboxdirective: By definingsandbox.checkcommands (such as runningruff check {file_path}orprettier --check), Sweep runs your team's exact formatters against the modified file inside an isolated execution environment before opening the PR. - The
gha_enabledflag: When set totrue, Sweep does not stop when code is pushed. If your GitHub Actions CI pipeline fails on linting, type checks (tscormypy), or test failures, Sweep reads the CI logs, analyzes the failure backtraces, and automatically pushes corrective commits to the branch.
This three-tier structure—rules for intent, sandbox for pre-flight validation, and gha_enabled for CI healing—transforms Sweep from a reckless code generator into a disciplined contributor.
365Finds Recommendation and Best Practices
For engineering leads introducing Sweep to their workflow, 365Finds recommends treating sweep.yaml exactly like an onboarding runbook for an intern:
- Keep rules short and enforceable: Limit your
ruleslist to between 7 and 15 distinct, high-impact requirements. Flooding the prompt context with 50 micro-rules dilutes model attention and degrades reasoning. - Block forbidden paths early: Always populate
blocked_dirs. Sweep should never touch lockfiles (package-lock.json,poetry.lock), migration scripts, or production infrastructure configs unless explicitly instructed. - Update rules iteratively from pull request reviews: Whenever human reviewers reject a Sweep PR for a stylistic or architectural discrepancy, do not just leave a review comment—turn that correction into a bullet point in
sweep.yaml.
Sweep cannot infer unwritten engineering culture. If your team cares about typing discipline, structured error logs, and defensive unit testing, encode those expectations into sweep.yaml from day one.