Skip to main content
Kody Rules page

Code review → Kody Rules at repository scope: pending review, the Review Rules and Memories tabs, filters, and the rules table

Two Types in the Kody Rules UI

Kody Rules are organized into two categories, managed through the Review Rules and Memories tabs in the sidebar under Code review → Kody Rules. Pick Global (or a repository / directory) in the scope picker at the top of the Code review group to choose which level you are editing.
Traditional code review rules that run during the dedicated code review stage. They analyze file diffs and PR metadata to enforce coding standards.
  • Applied at File-Level (execution mode Per file) or Pull Request-Level (execution mode Per PR)
  • Support variables, file references, and MCP functions
  • Triggered during automated code reviews

Review Rules

Create Custom Rules

Define rules based on your team’s exact needs. On the Review Rules tab, click New rule (or Write a rule when the list is empty) to open the rule dialog. Review Rules can be applied at two different levels, chosen with the Execution mode field: File-Level (Per file) and Pull Request-Level (Per PR). Both levels support variables, file references, and MCP functions to build powerful, context-aware rules.

Variables, File References & MCP Functions

Rules can access rich context through variables, file references, and MCP functions. Here’s what’s available: Variables: Variables represent the context data available during rule execution. Understanding what’s available helps you compose better rules by combining variables with MCP functions and file references.
  • File-Level:
    • fileDiff - The specific changes made to the individual file being analyzed
  • PR-Level:
    • pr_title - The title of the Pull Request
    • pr_description - The description/body of the Pull Request
    • pr_total_additions - Total number of lines added
    • pr_total_deletions - Total number of lines deleted
    • pr_total_files - Total number of files changed
    • pr_total_lines_changed - Total number of lines modified
    • pr_files_diff - Complete diff of all changes across the entire Pull Request
    • pr_tags - Tags associated with the Pull Request
    • pr_author - Author of the Pull Request
    • pr_number - Pull Request number
Use these variables in your rule instructions to access context data (the Variables menu in the Instructions editor inserts the ones available for the selected execution mode), and combine them with MCP functions to fetch additional information or perform dynamic analysis. File References: Reference files directly in your rule instructions to compare code, validate patterns, enforce consistency, and leverage existing templates or standards.
  • @file:path/to/file.ts - Reference files in the same repository where you’re editing the rule
    • Use when referencing templates, examples, or configuration files within your current repository
    • Example: @file:src/services/userService.ts
  • @repo:org/project - Reference files in another repository or when configuring rules outside a repo context
    • Use when enforcing consistency across multiple repositories or referencing shared standards
    • Example: @repo:team/api-standards
How File References Work:
  • Kody identifies file references automatically when you save a rule
  • References are resolved in the background—watch the status indicator next to the editor to confirm completion
  • Use accurate blob-style paths (e.g., src/utils/helpers.ts) instead of placeholders
  • File contents are injected into the rule context, allowing Kody to compare, validate, or enforce patterns
  • Works in both File-Level and Pull Request-Level rules
MCP Functions: Rules can use MCP (Model Context Protocol) functions to fetch additional data and context. You can use any MCP tool or server connected in your workspace’s Plugins page. The rule editor no longer has an MCP picker. Available functions include:
  • Repository operations: List repositories, get repository files, content, and languages
  • PR analysis: Get pull request details, list commits, analyze PR file content
  • File content retrieval: Fetch file contents and diffs
  • Cross-file validation: Perform advanced analysis across multiple files
  • Custom integrations: Any MCP server you’ve connected as a plugin (Jira, custom tools, etc.)
MCP functions execute during rule evaluation, enabling rules that adapt to current repository state and fetch real-time data. Best Practices:
  • Use specific file paths rather than generic placeholders
  • Reference stable files that represent your team’s standards
  • Test file references exist before saving rules to avoid resolution errors
  • Combine variables, file references, and MCP functions for comprehensive validation

File-Level Rules

Analyze individual files to catch issues within specific code files. Available Context: See the Variables, File References & MCP Functions section above for details. Available at this level: fileDiff variable, file references (@file, @repo), and MCP functions. What You Can Do:
  • Compare against reference files using @file or @repo
  • Fetch related files or repository data using MCP functions
  • Combine variables, file references, and MCP functions to validate patterns, check consistency, or enforce architectural rules
How to Configure:
  • Rule name: Clearly define the rule purpose
  • Execution mode: Per file (the default)
  • Path: Limit rules to specific files or directories using glob patterns (leave empty to apply to all files)
  • Instructions: Use fileDiff, reference files with @file/@repo, and call MCP functions to compose powerful rules with rich context. New rules can Start with a popular template
  • Severity: Set to Critical, High (the default), Medium, or Low
  • Advanced settings: Inheritable (on by default; see Rule Inheritance) and Code examples (Bad example / Good example)
Configuration Example: 📋 Rule: “Avoid equality operators (==, !=) in loop termination conditions.” 📁 Path: src/**/*.ts ⚠️ Severity: Critical 📝 Instructions: “Using equality operators (== or !=) can cause infinite loops if exact values aren’t matched.” ❌ Bad Example:
✅ Good Example:

Pull Request-Level Rules

Analyze the entire Pull Request for cross-file validation and PR-specific requirements. Available Context: See the Variables, File References & MCP Functions section above for details. Available at this level: PR variables (pr_title, pr_description, pr_files_diff, etc.), file references (@file, @repo), and MCP functions. What You Can Do:
  • Validate PR metadata using variables like pr_title, pr_description, pr_author
  • Reference configuration files or templates using @file or @repo
  • Fetch additional context using MCP functions (e.g., check if related files exist, validate against repository structure)
  • Combine PR variables, file references, and MCP functions to create comprehensive validation rules
How to Configure: The creation process is identical to file-level rules, but you must set Execution mode to Per PR (Path does not apply in this mode). This broader context enables analysis of cross-file dependencies and overall PR quality. Examples:
  • 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
  • Use pr_total_lines_changed to flag PRs exceeding size limits
  • Combine pr_files_diff with MCP functions to validate cross-file dependencies
  • Reference @file:routes.json to ensure new routes are registered
  • Use MCP functions to check if test files exist for modified service files

Composing Powerful Rules

Combine variables, MCP functions, and file references to create sophisticated rules with rich context. Here’s what’s available at each level: File-Level Composition:
  • Use fileDiff to analyze the specific changes in a file
  • Reference related files with @file:path/to/template.ts to compare against patterns
  • Call MCP functions to fetch repository data or check if related files exist
  • Example: “Analyze fileDiff and ensure it follows the pattern in @file:src/utils/example.ts. Use MCP to verify related test files exist.”
PR-Level Composition:
  • Use PR variables (pr_title, pr_description, pr_files_diff, etc.) to validate PR metadata and size
  • Reference configuration files with @file:config.json or @repo:org/shared-config to enforce consistency
  • Call MCP functions to perform cross-file validation, check repository structure, or fetch commit history
  • Example: “If pr_files_diff contains new routes, verify they’re registered in @file:routes.json. Use MCP to check if corresponding test files exist for all modified service files.”
Cross-Repository Validation:
  • Reference files from other repositories with @repo:org/project to maintain consistency across projects
  • Combine with MCP functions to validate against shared standards or templates
  • Example: “Ensure API endpoints follow the pattern defined in @repo:org/api-standards. Use MCP to fetch the latest standards document.”
Dynamic Analysis:
  • MCP functions execute during rule evaluation, enabling rules that adapt to current repository state
  • Fetch real-time data about files, commits, or repository structure
  • Example: “Use MCP to check the current repository structure and ensure new files follow the existing directory patterns.”
This composition enables rules that understand not just code changes, but the broader context of your codebase, team practices, and project requirements.

Import from Rules Library

Leverage proven best practices instantly:
  • On Code review → Kody Rules (Review Rules tab), click Discovery to open the Rules library (Rules Marketplace). You can also reach it from Browse the library when the rules list is empty, or by searching Rules library in the ⌘K command palette.
  • Start from Featured, or switch to Browse to search the full catalog and filter rules by Severity, Language, or Packs.
  • Open a rule and click Add to my rules, using the repository picker next to it to choose Global or the repositories (and directories) that should get the rule.
Examples:
  • Security: “Disallow use of insecure MD5 hashing.”
  • Maintainability: “Limit React components to less than 150 lines.”

Memories

Memories are persistent contextual instructions that Kody learns from your team’s conversations and coding practices. Unlike Review Rules that run during code review, Memories are injected across all prompts and conversations to provide continuous, high-priority context and improve future suggestions.

How Memories Work

  • Injected everywhere: Memories are included in code review analysis (cross-file, safeguards, PR-level rules) and in conversational interactions
  • High-priority context: Memories are treated as high-priority guidance by the AI, ensuring your team’s conventions are consistently applied
  • Better future suggestions: Memories help Kody avoid repeating the same mistaken assumptions about your repo
  • Intelligent deduplication: When a new memory is created, Kody uses an LLM-based resolution mechanism to determine whether to create it, skip it (if duplicate), or update an existing memory

Creating Memories

There are two ways to create memories:

Via Conversation

The most natural way to create memories is through conversation with Kody in your PR comments. Kody detects both explicit and implicit intents to save conventions: Explicit — directly asking Kody to remember:
Implicit — stating a preference or convention that Kody captures:
Kody will NOT create memories for transient instructions (e.g., “fix this now”), debugging chatter, questions, vague statements, or requests explicitly scoped to a single task or PR.
When a memory is created or updated, Kody responds with a confirmation and provides a direct link to view the memory in the UI.

Via the UI

You can also create memories manually:
  1. In the sidebar, pick Global (or the repository / directory) in the scope picker at the top of the Code review group, then open Kody Rules. The memory is created at the scope you pick here
  2. Switch to the Memories tab
  3. Click New memory (or Add a memory when the list is empty)
  4. Fill in Memory name and Instructions, then click Create memory

Memory Scopes

Each memory has a scope that determines where it applies:

LLM-Generated Memories Approval

By default, AI-generated memories are automatically activated. You can require manual approval before they take effect:
  1. Go to Code review → Kody Rules at the scope you want (Global, a repository or a directory)
  2. Click Configuration to open the side sheet
  3. Enable Kody knowledge approval
When enabled:
  • AI-generated rules and memories enter a pending state and are not active until approved
  • A badge on the Review Rules and Memories tabs shows the pending count
  • Pending items appear in the Pending review section at the top of the page, where you approve or discard them (see Pending review below)
  • Both new creations and updates to existing rules/memories go through the approval flow
You can also set this in kodus-config.yml:

Pending review

The Pending review section (“Rules and memories awaiting approval.”) lists pending rules and memories together, each marked as a Rule, a Memory, or an Update:
  • New rules and memories: AI-generated items waiting for approval. Choose Approve to activate the item or Discard to reject it.
  • Updates: Proposed changes to an existing rule or memory, shown as a diff. Choose Update existing to apply the change, Create new instead to keep the original and add the proposal as a separate item, or Discard to reject it.
Select several items and use Bulk actions (Approve N, Create as new (N), Discard N) to handle them at once.

Next Steps

Sync IDE Rules

Automatically import rules from Cursor, Copilot, Claude and other AI coding tools.

Repository Rules

Create rules directly in your repository using structured markdown files.

AI Generation

Let AI generate rules based on your codebase patterns and past reviews.