> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codeant.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Code review Instructions

> Configure review instructions for CodeAnt AI

CodeAnt AI allows you to provide custom instructions to tailor the code review process for your specific project needs. These instructions help CodeAnt understand your coding standards, ignore false positives, and focus on what matters most for your codebase.

## Setup

### 1. **Create Configuration Folder**

Create a `.codeant` folder in your repository root (same level as your `.git` folder):

```
your-repo/
├── .git/
├── .codeant/
│   └── instructions.json
├── src/
└── package.json
```

### 2. **Create Instructions File**

Inside the `.codeant` folder, create an `instructions.json` file with your custom review instructions.

## Configuration Format

The `instructions.json` file uses the following structure:

```json theme={null}
{
    "instructions": [
        {
            "id": "unique-instruction-id",
            "description": "Clear description of what this instruction does",
            "files": ["glob-pattern-1", "glob-pattern-2"],
            "scope": ["ide", "pr"]  // Optional, defaults to ["ide"]
        }
    ]
}
```

### File Pattern Examples

CodeAnt uses [minimatch](https://github.com/isaacs/minimatch) for glob patterns. Here are common patterns:

| Pattern                | Description                                              |
| ---------------------- | -------------------------------------------------------- |
| `**/*.js`              | All JavaScript files in any directory                    |
| `src/**/*.ts`          | All TypeScript files in src directory and subdirectories |
| `*.test.js`            | Test files in root directory only                        |
| `**/*.{js,ts,jsx,tsx}` | All JavaScript/TypeScript files                          |
| `!**/node_modules/**`  | Exclude node\_modules directory                          |
| `components/**/*.vue`  | All Vue files in components directory                    |
| `**/*.spec.{js,ts}`    | All spec test files                                      |

## Instruction Examples

### Common Use Cases

**1. Ignore Specific Patterns:**

```json theme={null}
{
    "id": "ignore-console-logs",
    "description": "Allow console.log statements in development files",
    "files": ["src/dev/**/*.js", "**/*.dev.js"],
    "scope": ["ide"]
}
```

**2. Framework-Specific Rules:**

```json theme={null}
{
    "id": "react-hooks-exception",
    "description": "Allow useEffect without dependencies in specific components",
    "files": ["src/components/legacy/**/*.jsx"]
}
```

**3. API Integration Guidelines:**

```json theme={null}
{
    "id": "api-error-handling",
    "description": "Ensure all API calls in services have proper error handling and timeout",
    "files": ["src/services/**/*.ts", "src/api/**/*.ts"],
    "scope": ["ide", "pr"]
}
```

**4. Security Focus:**

```json theme={null}
{
    "id": "auth-security",
    "description": "Extra scrutiny for authentication and authorization code",
    "files": ["src/auth/**/*.js", "**/middleware/auth.js"],
    "scope": ["pr"]
}
```

## Sample instructions.json

Here's a complete example configuration:

```json theme={null}
{
    "instructions": [
        {
            "id": "add-exception",
            "description": "Do not show error where add function is subtracting",
            "files": ["**/*.js", "**/*.ts", "**/*.jsx", "**/*.tsx"],
            "scope": ["ide", "pr"]
        },
        {
            "id": "test-file-exceptions",
            "description": "Allow mock functions and testing utilities without warnings",
            "files": ["**/*.test.js", "**/*.spec.ts", "**/tests/**/*.js"]
        },
        {
            "id": "legacy-code-review",
            "description": "Focus only on security issues for legacy code, ignore style warnings",
            "files": ["src/legacy/**/*.js", "old-modules/**/*.ts"],
            "scope": ["pr"]
        },
        {
            "id": "config-files",
            "description": "Skip complexity warnings for configuration files",
            "files": ["*.config.js", "webpack.config.js", "**/config/**/*.js"],
            "scope": ["ide"]
        }
    ]
}
```

## Best Practices

* **Use descriptive IDs**: Make instruction IDs clear and meaningful
* **Be specific with patterns**: Target exact files or directories that need special treatment
* **Document reasoning**: Use clear descriptions explaining why each instruction exists
* **Test patterns**: Verify your glob patterns match the intended files
* **Keep it minimal**: Only add instructions when necessary to avoid over-customization
* **Scope appropriately**: Use scope to control where instructions apply - IDE only, PR reviews only, or both

Once you've created your `instructions.json` file, CodeAnt will automatically apply these custom instructions during the next code review.
