AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Configure Custom Rulebooks and Style Guidelines for Sweep

Amanda Nagy · 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

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:

FieldPurposeEnforcement Layer
descriptionHigh-level repository context, architecture, and technology stackSemantic / LLM prompt
rulesSpecific coding guidelines, architectural constraints, and style mandatesSemantic / LLM prompt
sandboxExecution commands (install and check) to run linters and formattersDeterministic / Local container
blocked_dirsFile paths and directories Sweep is strictly forbidden from editingHard boundary / File filter
gha_enabledWhether Sweep inspects GitHub Actions CI output to self-correct failuresDeterministic / CI feedback loop
branchThe default base branch targeted for generated pull requestsGit orchestration
draftWhether to open pull requests as drafts by defaultWorkflow 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

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:

  1. Do not use rules as a style guide. Delegate formatting, whitespace, quotes, and static type validation entirely to sandbox.check with tools like Prettier, ESLint, or Ruff.
  2. Use rules strictly 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.
  3. Lock down high-risk surfaces with blocked_dirs.
  4. Validate your configuration locally. Sweep provides the sweep-sandbox utility (curl https://raw.githubusercontent.com/sweepai/sweep/main/bin/install_sweep_sandbox.sh | sh) to test sandbox.check scripts locally before merging sweep.yaml into your default branch.

References