CodeLLM Rules: Personalize Your Coding Agent Like a Pro

What are Rules?

Rules in CodeLLM help you guide your AI coding agent with specific instructions - from coding style preferences to architectural decisions, project templates, and even how the assistant talks to you. Think of them as reusable, always-on instructions that act like a persistent memory for your assistant - ensuring consistency in your workflows, across files and sessions.

Why Use Rules?

How Rules Work

Large language models don’t retain memory between tasks. Rules solve this by injecting persistent context into your AI prompts — helping the assistant respond consistently across your files and projects.

Whenever a Rule applies, its contents are included automatically at the start of the model’s context.

Where Are Rules Applied?

Rules apply in:

They are scoped using two settings:

Use Cases & Copy-Paste Starter Rules

You may find the different rules here in this Rule directory and add them to the list - https://rules.abacusai.app/

1. Encode Domain-Specific Knowledge

Help CodeLLM understand project-specific terms and logic while helping you coding and providing suggestions.

Example Rule:
description: "Domain-specific terminology and conventions"
globs: ["*"]
ruleType: always
---

- In our app, 'Tenant' refers to an organization, not an individual user.
- The 'Account' model handles billing relationships.
- 'Subscription' controls feature access levels and is always linked to a Tenant.

📌 Tip: Add to .codellm/rules to apply across the project.

2. Automate Project-Specific Workflows

Define reusable templates for common tasks.

Example Rule:
description: "API endpoint boilerplate"
globs: ["routes/api/*.ts"]
ruleType: auto-attached
---

Use this template for new API routes:

```ts
import { NextApiRequest, NextApiResponse } from 'next'
import { withAuth } from '@/lib/auth'

export default withAuth(async function handler(req: NextApiRequest, res: NextApiResponse) {
  // Your code here
})
```

- All endpoints must use withAuth
- Validate request payloads using zod

3. Standardize Architecture & Style

Enforce how code should be structured across the team.

Example Rule:
description: "React component guidelines"
globs: ["components/**/*.tsx"]
ruleType: always
---

- Use functional components (avoid class components)
- Follow PascalCase for naming (e.g., `UserProfile`)
- Component file layout:
  - Main component
  - Subcomponents
  - Styles
  - Tests
- Avoid inline styles; prefer styled-components

4. Customize Language & Tone

Control how the assistant talks — great for teams or non-English settings.

Example Rule:
description: "Formal French tone"
globs: ["*"]
ruleType: always
---

- Respond in fluent French
- Use a formal, documentation-style tone
- Keep responses short and precise with code examples

5. Add Personal Style Preferences

Adapt the response style to your coding proficiency and learning style. Really helpful for non-technical users and beginners for setting up the style in a manner that you can understand

Example Rule:
description: "Non-technical communication style and support"
globs: ["*"]
ruleType: always
---

- Adjust responses to match the proficiency of a non-technical user.
- When suggesting a tool, code, or task, always include brief background context to explain:
  - Why the task is important
  - When it is typically needed
  - How it fits into the bigger picture
- If the task involves manual steps (e.g., command-line use, file changes, or UI navigation), provide:
  - Clear step-by-step instructions
  - Expected outcomes or changes after each step
  - Any prerequisites, dependencies, or files the user should check beforehand
- Use code comments to explain logic instead of long paragraphs

How to Create Rules (Step-by-Step)

  1. Open a Folder in CodeLLM

  2. Search for Rule in the Main search bar with the given string >Rule and click on Create Rule.

Search for Rule

  1. Add the Rule File name in the Top bar

Search for Rule

  1. This adds a .codellm/rules/ folder to your project with the given file name

  2. Fill out the following details:

Search for Rule

  1. You can access your rules here in the project directory

Search for Rule

📌 Tip: You can also copy-paste existing rule files between projects!

Best Practices

✅ Good Practice ❌ Avoid This
Be specific and actionable Vague guidance like "write clean code"
Keep rules modular One giant rule covering everything
Add concrete examples Generic instructions without context
Use globs smartly Overusing * everywhere
Test your rules on sample files Assuming it works without trying

Frequently Asked Questions (FAQs)

Q: Can I use multiple rules in a project?

Yes, absolutely! Just make sure they don’t conflict with each other and are not ambiguous.

Q: Can I apply a rule temporarily for a specific task or query?

Yes, just mention it in your prompt with @file to attach it manually.

Search for Rule

Need More Help?

For further assistance, please contact our support team: support@abacus.ai.