Aider Conventions Guide

How to use CONVENTIONS.md files with Aider to guide AI coding style, practices, and preferences.

RRuleBoxยทvia aider-ai
ยทDec 14, 2024ยท50 views
# Aider Conventions Repository

This repository is a collection of community-contributed convention files for use with [aider](https://aider.chat), an AI pair programming tool. Convention files help guide the AI to follow specific coding styles, practices, and preferences.

## What are Convention Files?

Convention files are markdown files that specify coding guidelines for aider to follow. They can include preferences like:
- Coding style rules
- Preferred libraries and packages
- Type hint requirements
- Testing conventions
- Documentation standards
- And more

For more information about using conventions with aider, see the [conventions documentation](https://aider.chat/docs/usage/conventions.html).

## How to Use These Conventions

1. Browse the subdirectories to find a conventions file that matches your needs
2. Copy the desired `CONVENTIONS.md` to your project
3. Load it in aider using either:
   ```bash
   aider --read-only CONVENTIONS.md
   ```
   Or add it to your `.aider.conf.yml`:
   ```yaml
   read-only: CONVENTIONS.md
   ```

## Example .aider.conf.yml

```yaml
# Model settings
model: claude-sonnet-4-20250514

# Auto-commit settings
auto-commits: true
auto-lint: true
auto-test: false

# Read convention files
read:
  - CONVENTIONS.md
  - docs/ARCHITECTURE.md

# Lint command
lint-cmd: npm run lint

# Test command
test-cmd: npm test
```

## Writing Your Own Conventions

### Directory Structure

Each subdirectory should contain:
- `README.md` - Explains the purpose and use case for the conventions
- `CONVENTIONS.md` - The actual conventions file to use with aider

### Convention File Template

```markdown
# Project Conventions

## Code Style

### Formatting
- Use 2-space indentation
- Maximum line length: 100 characters
- Use trailing commas in multi-line structures

### Naming
- Use camelCase for variables and functions
- Use PascalCase for classes and types
- Use SCREAMING_SNAKE_CASE for constants

## Type Safety

- Always use TypeScript strict mode
- Prefer explicit return types on functions
- Avoid `any` - use `unknown` with type guards

## Testing

- Write tests for all new functionality
- Use descriptive test names
- Follow AAA pattern (Arrange, Act, Assert)

## Documentation

- Add JSDoc comments for public APIs
- Keep README up to date
- Document breaking changes

## Dependencies

- Prefer well-maintained packages
- Check bundle size impact
- Review security advisories
```

## Contributing

We welcome contributions! To add your own conventions:

1. Create a new subdirectory with a descriptive name
2. Include both a `README.md` explaining your conventions and a `CONVENTIONS.md` file
3. Submit a Pull Request

Please ensure your README.md clearly explains:
- The purpose of your conventions
- What kind of projects they're best suited for
- Any special instructions for using them

## Tips for Effective Conventions

1. **Be Specific**: Vague rules are hard to follow
2. **Provide Examples**: Show what good code looks like
3. **Explain Why**: Help the AI understand the reasoning
4. **Stay Focused**: Don't try to cover everything
5. **Test Them**: Verify the AI follows your conventions

Comments

No comments yet

Be the first to share your thoughts!