AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Configuring Project-Level Coding Standards in Aider with CONVENTIONS.md

小森夏平 · 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

Aider will drift toward generic, lowest-common-denominator code patterns unless you explicitly anchor it to your project's standards. Without guidelines, it will import outdated libraries, invent novel ways to handle database sessions, or write untyped functions. The canonical mechanism to pin Aider down to your team's architectural choices is a markdown file—typically CONVENTIONS.md—loaded as read-only context on every run.

Setting this up requires two files in your repository root: a clear markdown document and a minimal Aider configuration file.

1. Create CONVENTIONS.md in Your Project Root

At 365Finds, we see developers make the mistake of pasting 2,000-word company onboarding wikis into CONVENTIONS.md. LLMs do not digest sprawling handbooks well; they dilute attention across irrelevant instructions. Keep the file concise, declarative, and focused on hard constraints, preferred libraries, and forbidden patterns.

A practical CONVENTIONS.md for a modern backend service looks like this:

# Engineering Conventions & Architecture

## Libraries & Tech Stack
- Use `httpx` for external HTTP requests; do not import `requests` or `urllib`.
- Use Pydantic v2 schemas for request validation and response serialization.
- Use SQLAlchemy 2.0 style queries with `select()`; avoid legacy query syntax.

## Architectural Boundaries
- Keep controllers lean: HTTP route handlers must delegate business logic to services in `app/services/`.
- Never import database models directly inside templates or presentation layers.
- Domain services must return Pydantic models, never raw ORM instances.

## Code Quality & Types
- Strict typing is mandatory: all function parameters and returns require type annotations.
- Error handling: raise domain exceptions defined in `app/errors.py`; never use bare `except:` clauses.
- Logging: use the structured logger via `structlog.get_logger()`. Do not use `print()`.

## Testing Standards
- Tests live under `tests/unit/` and `tests/integration/`.
- Use `pytest` with `pytest-asyncio` and `pytest-mock`.
- Always mock external network calls using `respx` or `unittest.mock`.

Every line in this file does real work. It eliminates ambiguity before Aider suggests a single change.

2. Automate Loading via .aider.conf.yml

You can manually load conventions inside an active session using /read CONVENTIONS.md, or from the terminal with aider --read CONVENTIONS.md. But relying on manual flags guarantees someone on your team will forget them.

The reliable approach is to commit an .aider.conf.yml file into the root of your Git repository. Aider checks the current Git root for configuration on startup and applies it automatically:

# .aider.conf.yml
read:
  - CONVENTIONS.md

If you have separate guidelines for architectural boundaries and frontend styling, Aider allows you to provide a list of files:

# .aider.conf.yml
read:
  - CONVENTIONS.md
  - docs/ARCHITECTURE.md
  - docs/API_STANDARDS.md

When committed to version control, any developer who runs aider inside the project immediately inherits these project-level standards without extra configuration.

Why the read Directive Matters Structurally

Under the hood, how you introduce instructions to Aider changes how the model behaves and what it costs.

When you add a file to Aider using /add, Aider places that file into the active chat context as an editable file. If you put your conventions file into the editable set, Aider will frequently attempt to refactor the conventions themselves instead of writing application code.

By using the read configuration (equivalent to --read or /read), Aider marks the document as immutable reference context:

365Finds Assessment: Conventions Need an Enforcement Loop

Aider respects CONVENTIONS.md with surprising fidelity when instructions are direct, but 365Finds does not recommend relying on natural language conventions alone. Instructions tell the model what to aim for; tests and linters prove whether it hit the target.

We strongly advise coupling your .aider.conf.yml conventions with Aider's automated testing flag. In your .aider.conf.yml:

# .aider.conf.yml
auto-test: true
test-cmd: "pytest && ruff check ."

When Aider generates code, it reads CONVENTIONS.md to establish architectural intent, writes the implementation, and immediately executes your linter and test suite. If an import violates your Ruff rules or breaks an architectural contract, Aider captures the terminal error and auto-corrects before handing the shell back to you.

References