How to use Kody Rules
You can use Kody Rules in two ways:Create Custom Rules
Define rules based on your team’s exact needs. Kody Rules can be applied at two different levels:Reference External Files
Rule instructions now support referencing concrete files from any codebase Kody can access. When you save a rule, Kody identifies these references and resolves them automatically.- Use
@file:path/to/file.tsfor files inside the repository where you’re editing the rule. - Include
@repo:org/projectwhen pointing to files in another repository or when configuring rules outside a repo context. - Provide accurate blob-style paths instead of placeholders so Kody can reliably find the file you mean.
- References are processed in the background right after you save—watch the status indicator next to the editor to confirm completion.
File-Level Rules
Analyze individual files to catch issues within specific code files. Available Context:- File diff: The specific changes made to the individual file being analyzed
- Rule name: Clearly define the rule purpose
- File Paths: Limit rules to specific files or directories using glob patterns
- Severity: Set to Critical, High, Medium, or Low
- Detailed Instructions: Clearly state what’s expected and why
src/**/*.ts
⚠️ Severity: Critical
📝 Instructions: “Using equality operators (== or !=) can cause infinite loops if exact values aren’t matched.”
❌ Bad Example:
Pull Request-Level Rules
Analyze the entire Pull Request for cross-file validation and PR-specific requirements. Available Context:- PR diff: Complete diff of all changes across the entire Pull Request
- PR title: The title of the Pull Request
- PR description: The description/body of the Pull Request
- PR statistics: Comprehensive metrics including total additions, deletions, files changed, and total lines modified
- Every service file must have a corresponding test file
- PR description must be complete, clearly stating what was added or removed
- When a new route is created in a controller, it must be registered in routes.json
Import from Rules Library
Leverage proven best practices instantly:- Navigate to Discovery Rules in your Kodus dashboard.
- Filter rules by severity, language, or tags.
- Import and activate rules with a single click.
- Security: “Disallow use of insecure MD5 hashing.”
- Maintainability: “Limit React components to less than 150 lines.”