AI-powered tool for generating Konveyor analyzer rules from migration guides and documentation.
The Analyzer Rule Generator uses Large Language Models (LLMs) to automatically extract migration patterns from documentation and generate static analysis rules for the Konveyor analyzer. This helps migration teams quickly create comprehensive rulesets without manual authoring.
- Multiple Input Formats: URLs, Markdown files, plain text, ESLint codemods
- Multi-Language Support: Java, TypeScript/React, Go, Python, CSS, and more
- LLM-Powered Extraction: Automatically identifies migration patterns, complexity, and conditions
- ESLint Rule Extraction: Direct extraction from ESLint codemod repositories (e.g., PatternFly pf-codemods) without LLM
- Migration Complexity Classification: Automatic classification (trivial, low, medium, high, expert) for generated and existing rules
- Konveyor Analyzer Format: Generates rules compatible with analyzer-lsp
- Flexible LLM Support: OpenAI, Anthropic Claude, Google Gemini
- Smart Provider Detection: Automatically uses Java or Builtin provider based on detected language
- Pattern Detection: Extracts fully qualified class names, regex patterns, and file globs
- Rule Validation: Syntactic and optional semantic validation to ensure rule quality
- Test Data Generation: AI-powered generation of test applications for rule validation
- CI Test Updater: Automated updates to go-konveyor-tests expectations
# Install dependencies
pip install -r requirements.txt
# Set up your LLM API key
export OPENAI_API_KEY="your-key-here"
# Generate rules from a migration guide
python scripts/generate_rules.py \
--guide https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide \
--source spring-boot-3 \
--target spring-boot-4 \
--output examples/output/spring-boot-4.0/migration-rules.yamlInteractive AI Assistant for Rule Generation
This project includes a Claude Code skill that provides an interactive AI assistant for generating migration rules. Instead of running command-line scripts manually, you can have a natural conversation with Claude to generate rules.
konveyor-rules
The skill will guide you through:
- Providing the migration guide (URL or file)
- Specifying source and target frameworks
- Choosing LLM provider and options
- Reviewing generated rules and next steps
- Natural language interface - Describe what you need in plain English
- Interactive guidance - Claude asks clarifying questions and provides suggestions
- Automatic validation - Checks inputs and provides helpful error messages
- Context-aware - Understands the project structure and suggests best practices
See .claude/skills/konveyor-rules/README.md for complete documentation.
flowchart TD
A[π Migration Guide] --> B[π€ Generate Rules]
B --> C[π Konveyor Rules]
C -.Optional.-> C1[β
Validate Rules]
C1 --> C
C --> D[π€ Generate Test Data]
D --> E[π§ͺ Kantra Test]
E -->|Pass| F[π¦ Submit to konveyor/rulesets]
E -->|Fail| D
F --> G[π¬ Run Analysis]
G --> H[π Update CI Tests]
H --> I[π¦ Submit to go-konveyor-tests]
F -.Link PRs.-> I
style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style B fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style C fill:#fff9c4,stroke:#f9a825,stroke-width:2px
style C1 fill:#e1f5fe,stroke:#0277bd,stroke-width:2px,stroke-dasharray: 5 5
style D fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style E fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
style F fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
style G fill:#ffebee,stroke:#c62828,stroke-width:2px
style H fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style I fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
Complete Workflow:
- Generate Rules: LLM extracts migration patterns from documentation
- Detects language (Java vs TypeScript/React/Go/Python)
- For Java: Fully qualified class names and location types
- For others: Regex patterns and file globs
- Validate Rules (Optional): Check rule quality before testing
- Syntactic validation: Required fields, effort scores, pattern checks
- Semantic validation: AI-powered description/pattern alignment
- Generate Test Data: AI creates test applications with violations
- Test Locally: Validate rules with Kantra
- Submit Rules: PR to konveyor/rulesets
- Run Analysis: Test rules on reference applications
- Update CI Tests: Automated update of go-konveyor-tests expectations
- Submit Tests: PR to go-konveyor-tests (linked with rules PR)
python scripts/generate_rules.py \
--guide https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide \
--source spring-boot-3 \
--target spring-boot-4 \
--output examples/output/spring-boot-4.0/migration-rules.yamlOption 1: From ESLint Codemods (Recommended - No LLM required)
python scripts/generate_rules.py \
--eslint-repo https://github.com/patternfly/pf-codemods.git \
--source patternfly-v5 \
--target patternfly-v6 \
--output examples/output/patternfly-v6/Extracts rules directly from PatternFly's official ESLint codemods. Advantages:
- No LLM API costs
- High-quality rules based on official codemods
- Includes code examples and documentation links
- Extracts 91 rules from 106 ESLint rules (86% coverage)
- Supports: prop renames/removals, import changes, component renames, TypeScript types, markup warnings
Option 2: From Migration Guide (LLM-based)
python scripts/generate_rules.py \
--guide https://www.patternfly.org/get-started/upgrade/ \
--source patternfly-v5 \
--target patternfly-v6 \
--follow-links \
--max-depth 1 \
--output examples/output/patternfly-v6/migration-rules.yamlGenerates 41 comprehensive rules with hybrid detection (nodejs + builtin providers) for eliminating false positives.
- ruleID: spring-boot-3-to-spring-boot-4-00001
description: Replace deprecated Spring Boot 3 annotations
effort: 3
category: mandatory
labels:
- konveyor.io/source=spring-boot-3
- konveyor.io/target=spring-boot-4
when:
java.referenced:
pattern: org.springframework.web.bind.annotation.RestController
location: ANNOTATION
message: "Review Spring Boot 4.0 migration requirements for REST controllers"
links:
- url: "https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide"
title: "Spring Boot 4.0 Migration Guide"
migration_complexity: low- ruleID: patternfly-v5-to-patternfly-v6-00001
description: isDisabled should be replaced with isAriaDisabled
effort: 3
category: potential
labels:
- konveyor.io/source=patternfly-v5
- konveyor.io/target=patternfly-v6
when:
builtin.filecontent:
pattern: isDisabled\s*[=:]
filePattern: '*.{tsx,jsx,ts,js}'
message: "The isDisabled prop has been renamed to isAriaDisabled for better accessibility"The tool automatically classifies migration complexity for generated rules and provides a script to classify existing rulesets.
- trivial (95%+ AI success): Namespace changes, mechanical fixes (e.g., javax β jakarta)
- low (80%+ AI success): Simple API equivalents, straightforward replacements
- medium (60%+ AI success): Requires context understanding, moderate refactoring
- high (30-50% AI success): Architectural changes, complex migrations
- expert (<30% AI success): Custom implementations, likely needs human review
Add complexity classifications to existing Konveyor analyzer rulesets:
# Preview classifications (dry run)
python scripts/classify_existing_rules.py \
--ruleset examples/output/spring-boot/migration-rules.yaml \
--dry-run
# Apply classifications
python scripts/classify_existing_rules.py \
--ruleset examples/output/spring-boot/migration-rules.yaml
# Batch process multiple rulesets
bash scripts/batch_classify_rulesets.sh /path/to/rulesetsThe classifier analyzes:
- Pattern descriptions and messages
- Rule effort scores
- When condition complexity
- Migration keywords and indicators
See docs/guides/migration-complexity.md for complete documentation.
π View Rules Online - Interactive web viewer for any Konveyor ruleset
Load and explore rules from:
- GitHub URLs (paste any rule file URL)
- Local YAML files (drag & drop)
- Share with
?url=parameter
See Rule Viewers Guide for more options.
Getting Started:
- Rule Viewers Guide - View and explore generated rules
Guides:
- Konveyor Submission Guide - Complete end-to-end submission workflow
- Updating CI Tests - Step-by-step guide for go-konveyor-tests
- Testing Guide - Testing generated rules
- Complete Automation Guide - Full automation workflow
Technical Reference:
- Generate Rules Script Reference - Complete script documentation
- Validate Rules Script Reference - Rule validation documentation
- CI Test Updater Reference - Script documentation
- Java Rule Schema - Rule structure and syntax
Generated rules and tests integrate with:
- Konveyor Analyzer - Static analysis engine
- Konveyor Rulesets - Official rule repository
- go-konveyor-tests - CI test expectations
- Python 3.9+
- LLM API access (OpenAI, Anthropic, or Google)
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
This project enforces code quality through automated tooling:
- Black for code formatting
- isort for import sorting
- flake8 for linting
- pytest for testing (80%+ coverage required)
# Install dev dependencies
pip install black isort flake8 pre-commit
# Install pre-commit hooks (runs checks automatically)
pre-commit install
# Run checks manually
black src/ scripts/ tests/
isort src/ scripts/ tests/
flake8 src/ scripts/ tests/
pytestAll pull requests are automatically checked by GitHub Actions for code quality and test coverage.
Apache License 2.0
- konveyor/analyzer-lsp - Static analysis engine
- konveyor/rulesets - Official rulesets
- konveyor-iq - LLM evaluation framework