Skip to content

Feature Request: Automated KIT PR Review with Custom Business Rules #170

@memandip

Description

@memandip

📝 Problem Statement

Manual code reviews often miss subtle violations of complex business logic. While standard linters catch syntax and style issues, we need a way to automate the validation of business rules and domain-specific constraints during the Pull Request process.

🚀 Proposed Solution

Integrate KIT into the GitHub Actions pipeline to act as an automated reviewer. This integration should allow KIT to analyze PR diffs against a set of custom instructions and business rules, providing feedback or blocking merges when violations are detected.

⚙️ Technical Requirements

1. Flexible Configuration Format

To accommodate different project needs, the configuration for KIT (instructions/rules) should support:

  • Formats: YAML, JSON, or Markdown.
  • Source: * File-based: Stored directly in the repository (e.g., .github/kit-rules.md).
    • Environment-based: Passed via GitHub Variables or Secrets for sensitive or organization-wide rules.

2. Configurable Context Window

  • Default Behavior: KIT should focus only on the files that have been modified in the PR (the diff) to remain performant and cost-effective.
  • Extended Context: An optional configuration to allow KIT to scan the entire codebase or specific directories for deeper architectural context.

3. Workflow Integration

  • The tool should run as a GitHub Action.
  • It should be able to post comments directly on the PR lines where a rule is broken.
  • It should support a "Failure" state to prevent PR merging if a "Breaking Business Rule" is detected.

💡 Example Use Case

Configuration (.github/kit-rules.yaml):

rules:
  - id: auth_check
    description: "All endpoints in /api/v2 must use the @Validated decorator."
    severity: error
  - id: naming_convention
    description: "Database migrations must follow the YYYY_MM_DD_description format."
    severity: warning

Workflow Behavior:

  1. A developer submits a PR changing a file in /api/v2 without the @Validated decorator.
  2. KIT runs via GitHub Actions, reading the YAML file from the repo.
  3. KIT identifies the missing decorator and fails the CI check, leaving a comment on the specific line.

Proposed Workflow Example

name: "KIT Automated Business Logic Review"

on:
  pull_request:
    types: [opened, synchronized, reopened]

jobs:
  kit_review:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write # Required for KIT to post comments

    steps:
      - name: Checkout Code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0 # Fetches all history so KIT can see the diff

      - name: Run KIT Reviewer
        uses: kit-ai/review-action@v1 # Placeholder for the official KIT action
        with:
          # 1. Flexible Config Source (File or Secret)
          rules_path: ".github/kit_rules.yaml" 
          # rules_data: ${{ secrets.ORGANIZATION_BUSINESS_RULES }} # Alternative: load from secret
          
          # 2. Configurable Context Window
          # Options: 'diff' (default), 'full_repo', or 'directory'
          context_window: "diff" 
          
          # 3. GitHub Token for posting comments
          github_token: ${{ secrets.GITHUB_TOKEN }}
          
          # 4. Failure Logic
          fail_on_error: true # If a 'Breaking Business Rule' is hit, the check fails

✅ Expected Benefits

  • Reduced Human Error: Catches business logic flaws before they reach production.
  • Faster Onboarding: New developers get immediate feedback on domain-specific rules.
  • Consistency: Ensures all PRs are held to the same business standards automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions