Skip to content
kotlin-api-consultant logo

Kotlin API Oracle & Compatibility Validator

kotlin-api-consultant

Queries Kotlin compiler source code for API validation, compatibility checks, Metro pattern alignment, breaking change detection, and best practice recommendations. Use when validating Kotlin APIs, checking compiler compatibility, analyzing API usage patterns, detecting breaking changes, or when ...

mattnigh/skills_collection0installs24stars

SKILL.md

Full skill instructions

Kotlin API Oracle & Compatibility Validator

Automatic Kotlin compiler source consultation with Metro pattern alignment for production-quality compiler plugin development.

Core Mission

Provides real-time Kotlin compiler API validation by consulting local Kotlin compiler source (/​kotlin/​compiler/), detecting breaking changes, analyzing Metro usage patterns, and ensuring API compatibility across Kotlin versions.

Instructions

1. Identify Target API

Extract from conversation:

  • API class/​interface name from user's message
  • Look for patterns: "check IrGenerationExtension", "validate IrPluginContext API", "how does Metro use X"
  • Common APIs: IrGenerationExtension, IrPluginContext, IrFactory, IrClass, IrTypeParameter, CompilerPluginRegistrar

If unclear or missing:

Ask: "Which Kotlin compiler API would you like me to consult?"
Suggest: IrGenerationExtension | IrPluginContext | IrFactory | CompilerPluginRegistrar | Other

2. Locate API in Kotlin Compiler Source

Search Kotlin source tree:

# Primary location: /​kotlin/​compiler/
cd /​kotlin/​compiler/

# Find API definition
find . -name "*.kt" -type f -exec grep -l "interface ${API_NAME}\|class ${API_NAME}" {} \;

# Common locations:
# - ir/​backend.common/​src/​.../​extensions/ (IR APIs)
# - fir/ (FIR APIs)
# - plugin-api/​src/ (Plugin APIs)
# - cli/​cli-common/​src/ (CLI APIs)

If found multiple:

  • Prioritize interface over class (usually the API contract)
  • Prefer backend.common over implementation modules
  • Note all locations for completeness

If not found:

❌ API '${API_NAME}' not found in Kotlin compiler source

💡 Suggestions:
1. Check spelling (case-sensitive)
2. Try fuzzy search: grep -r "${PARTIAL_NAME}" /​kotlin/​compiler/
3. Consult Kotlin docs: https://kotlinlang.org/​api/​latest/
4. Check if it's an internal/​experimental API

3. Read and Parse API Definition

Read the source file:

Read /​kotlin/​compiler/​.../​extensions/​${API_NAME}.kt

Extract key information:

  • Package and imports
  • Interface/​class declaration
  • Generic type parameters
  • Method signatures
  • Annotations (@UnsafeApi, @FirIncompatiblePluginAPI, @Deprecated)
  • KDoc comments
  • Default implementations

Analyze annotations:

// Critical markers
@UnsafeApi                          // May change without notice
@FirIncompatiblePluginAPI          // K1 only, not K2
@Deprecated(message = "...", level = ERROR)  // Removal planned
@ExperimentalCompilerApi           // Unstable, may change

4. Check Metro Usage Patterns

Search Metro codebase:

# Find Metro usage of this API
grep -r "${API_NAME}" /​metro/​compiler/​src/​main/​kotlin/​dev/​zacsweers/​metro/​compiler/

# Look for:
# - How Metro implements/​extends this API
# - Patterns Metro follows
# - Workarounds for known issues

Common Metro files to check:

metro/​compiler/​src/​main/​kotlin/​dev/​zacsweers/​metro/​compiler/
├── MetroCompilerPluginRegistrar.kt     # Plugin registration
├── ir/​MetroIrGenerationExtension.kt    # IR generation
├── fir/​MetroFirExtensionRegistrar.kt   # FIR phase
└── context/​IrMetroContext.kt           # Context pattern

Metro alignment checklist:

  • How does Metro use this API?
  • Any Metro-specific patterns?
  • Workarounds Metro implements?
  • Best practices Metro demonstrates?

5. Detect Breaking Changes

Compare with documented version:

# Check git history for changes
cd /​kotlin/​compiler/
git log -p --all -- **/​${API_NAME}.kt | head -100

# Look for:
# - Method signature changes
# - Removed methods
# - Added required methods
# - Changed default implementations

Breaking change indicators:

  • Removed methods (breaking)
  • Changed method signatures (breaking)
  • Added abstract methods to interface (breaking)
  • Changed return types (breaking)
  • New required type parameters (breaking)
  • Deprecation with ReplaceWith (migration path)

Version compatibility:

🔍 API: ${API_NAME}
📅 Current Kotlin: 2.2.21 (or detected version)
📋 Changes since 2.0.0: [list]

⚠️ Breaking changes detected: [yes/​no]

6. Analyze Current API Definition

Generate API report:

═══════════════════════════════════════════════════
🔍 KOTLIN API CONSULTATION: ${API_NAME}
═══════════════════════════════════════════════════

📍 LOCATION:
File: /​kotlin/​compiler/​.../​path/​to/​${API_NAME}.kt
Package: org.jetbrains.kotlin.backend.common.extensions
Module: backend.common

📋 INTERFACE DEFINITION (Kotlin ${VERSION}):
```kotlin
interface ${API_NAME} {
    // Methods extracted from source
    fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext)

    // Annotations and markers
    @FirIncompatiblePluginAPI
    val shouldAlsoBeAppliedInKaptStubGenerationMode: Boolean
}

🏗️ METRO USAGE PATTERN:

class MetroIrGenerationExtension(...) : IrGenerationExtension {
    override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) {
        val context = IrMetroContext(pluginContext, messageCollector, ...)
        context(context) { generateInner(moduleFragment) }
    }
}

✅ FAKT ALIGNMENT CHECKLIST:

  • [✅/❌] Follows Metro pattern
  • [✅/❌] Uses context pattern for organization
  • [✅/❌] Handles K2 compatibility properly
  • [✅/❌] Implements all required methods
  • [✅/❌] Respects annotations and warnings

📚 BEST PRACTICES:

  1. [Practice from KDoc or Metro usage]
  2. [Practice 2]
  3. [Practice 3]

⚠️ WARNINGS & CAVEATS:

  • [Any @UnsafeApi warnings]
  • [Deprecation notices]
  • [Known issues or limitations]

═══════════════════════════════════════════════════


### 7. Provide Usage Recommendations

**For Fakt implementation:**

**If API is stable:**

✅ SAFE TO USE: ${API_NAME}

📋 Recommended usage:

  1. Follow Metro pattern exactly
  2. Use context pattern for organization
  3. Handle errors with messageCollector
  4. Support both K1 and K2 if applicable

📝 Example implementation: [Code snippet showing recommended usage]


**If API has warnings:**

⚠️ USE WITH CAUTION: ${API_NAME}

📋 Warnings:

  • @UnsafeApi: May change without notice
  • Monitor Kotlin release notes for changes
  • Consider abstraction layer for isolation

📋 Mitigation:

  • Create wrapper interface
  • Document API version dependency
  • Add compatibility tests

**If API is deprecated:**

🚨 DEPRECATED: ${API_NAME}

📋 Status:

  • Deprecated since: Kotlin ${VERSION}
  • Removal planned: Kotlin ${FUTURE_VERSION}
  • Replacement: ${REPLACEMENT_API}

📋 Migration path: [Show ReplaceWith suggestion or manual migration steps]


### 8. Cross-Reference Related APIs

**Suggest related APIs:**

🔗 RELATED APIS:

Used together with ${API_NAME}:

  • ${RELATED_API_1} - [Brief description]
  • ${RELATED_API_2} - [Brief description]

See also:


### 9. Provide Implementation Examples

**Real-world examples:**

**From Metro:**
```kotlin
// Metro's implementation of ${API_NAME}
[Extract relevant Metro code]

Recommended for Fakt:

// Adapted for Fakt's use case
[Show recommended implementation]

Anti-patterns to avoid:

// ❌ Don't do this:
[Show common mistakes]

// ✅ Do this instead:
[Show correct approach]

Supporting Files

Progressive disclosure for API knowledge:

  • resources/​api-lookup-patterns.md - Strategies for finding APIs in Kotlin source (loaded on-demand)
  • resources/​metro-api-usage.md - Metro usage examples for common APIs (loaded on-demand)
  • resources/​breaking-changes-catalog.md - Known breaking changes across Kotlin versions (loaded on-demand)
  • resources/​api-best-practices.md - Best practices from Kotlin and Metro (loaded on-demand)

Related Skills

This Skill composes with:

  • kotlin-ir-debugger - Debug IR generation using validated APIs
  • metro-pattern-validator - Validate Metro alignment for API usage
  • generic-scoping-analyzer - Analyze IrTypeParameter API (Phase 2)
  • fakt-docs-navigator - Access Metro alignment documentation

Common API Consultations

Frequently consulted APIs:

IrGenerationExtension

"Check IrGenerationExtension API"
"How does Metro use IrGenerationExtension?"
"Validate IR generation API"

IrPluginContext

"Consult IrPluginContext"
"What's in IrPluginContext API?"
"How to use irFactory from IrPluginContext?"

IrTypeParameter

"Check IrTypeParameter for generics"
"Generic type API validation"
"How to handle IrTypeParameterSymbol?"

CompilerPluginRegistrar

"Validate CompilerPluginRegistrar"
"Check plugin registration API"
"Metro's CompilerPluginRegistrar pattern"

Error Handling

API Not Found

❌ API '${API_NAME}' not found

🔍 Attempting fuzzy search...
[Run grep with partial name]

💡 Did you mean:
- ${SIMILAR_API_1}
- ${SIMILAR_API_2}

Multiple Matches

⚠️ Multiple definitions found for '${API_NAME}':

1. /​kotlin/​compiler/​ir/​.../​IrFactory.kt (interface)
2. /​kotlin/​compiler/​ir/​.../​IrFactory.kt (implementation class)

📋 Analyzing interface (primary API contract)...

Deprecated API

🚨 DEPRECATED API DETECTED

API: ${API_NAME}
Status: Deprecated since Kotlin ${VERSION}
Replacement: ${NEW_API}

💡 Recommendation: Migrate to ${NEW_API}
Migration guide: [Link or steps]

Best Practices

  1. Always check Metro first - If Metro uses an API, it's battle-tested
  2. Respect @UnsafeApi - Isolate behind abstraction layer
  3. Monitor Kotlin releases - Breaking changes happen in minor versions
  4. Test across K1/​K2 - API behavior may differ
  5. Document API versions - Track which Kotlin version APIs target

API Categories

CategoryExamplesStability
Core IRIrGenerationExtension, IrPluginContextStable
FIR PhaseFirExtensionRegistrarK2 specific
Plugin SystemCompilerPluginRegistrarStable
Type SystemIrTypeParameter, IrTypeModerate
ExperimentalVarious @ExperimentalCompilerApiUnstable

Validation Checklist

Before using an API in Fakt:

  • API located in Kotlin source
  • Current definition analyzed
  • Metro usage pattern reviewed
  • Breaking changes checked
  • Deprecation status confirmed
  • K1/​K2 compatibility verified
  • Implementation example created

Performance Notes

  • API lookup: ~5-10 seconds (file system search)
  • Source reading: ~2-5 seconds per file
  • Metro cross-reference: ~5 seconds
  • Total consultation: ~20-30 seconds

Fast enough for real-time development guidance!

More skills from mattnigh

spring-framework-patterns logo
mattnigh/skills_collection

spring-framework-patterns

Comprehensive Spring Framework and Spring Boot best practices including dependency injection patterns, bean lifecycle and scopes, REST API development, Spring Data JPA, service layer design, Spring Security, testing strategies, caching, AOP, async processing, error handling, and common anti-patte...

24 0
View

TypeScript厳格モードによる型安全性設計を専門とするスキル。 📖 参照書籍: - 『Effective TypeScript』(Dan Vanderkam): 型設計 📚 リソース参照: - `resources/Level1_basics.md`: レベル1の基礎ガイド - `resources/Level2_intermediate.md`: レベル2の実務ガイド - `resources/Level3_advanced.md`: レベル3の応用ガイド - `resources/Level4_expert.md`: レベル4の専門ガイド - `resources/di...

24 0
View
deploying-cloud-k8s logo
mattnigh/skills_collection

deploying-cloud-k8s

Deploys applications to cloud Kubernetes (AKS/GKE/DOKS) with CI/CD pipelines. Use when deploying to production, setting up GitHub Actions, troubleshooting deployments. Covers build-time vs runtime vars, architecture matching, and battle-tested debugging.

24 0
View
moai-alfred-agent-guide logo
mattnigh/skills_collection

moai-alfred-agent-guide

19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.

24 0
View
mermaid-diagram-generator logo
mattnigh/skills_collection

mermaid-diagram-generator

Converts architecture descriptions, module specs, or workflow docs into Mermaid diagrams. Use when visualizing brick module relationships, workflows (DDD, investigation), or system architecture. Supports: flowcharts, sequence diagrams, class diagrams, state machines, entity relationship diagrams,...

24 0
View
pre-flight-check logo
mattnigh/skills_collection

pre-flight-check

INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.

24 0
View
browser-dev-tools logo
mattnigh/skills_collection

browser-dev-tools

This skill should be used when working with browser-rendered artifacts (i.e. Bun, React/React Native) to proactively validate that development work on localhost is being built appropriately and to support debugging browser-rendered content. Use this skill after making frontend changes to verify t...

24 0
View
lead-dev logo
mattnigh/skills_collection

lead-dev

Lead Développeur - Coordination technique opérationnelle, code review, mentoring et livraison. Pair de web-dev-process au niveau OPÉRATIONS.

24 0
View
worker-monitor logo
mattnigh/skills_collection

worker-monitor

Monitor Docker workers, RQ queue health, and auto-scale workers (max 4). Use when: checking job progress, monitoring queue depth, scaling workers up/down, diagnosing slow processing, or waiting for jobs to complete. Referenced by data-quality skill during reprocessing.

24 0
View
quality-advisor logo
mattnigh/skills_collection

quality-advisor

Proactive quality guidance system that monitors artifact creation and provides real-time feedback on documentation quality

24 0
View
bump-version logo
mattnigh/skills_collection

bump-version

This skill should be used when the user wants to bump the version number in the workspace. It updates versions across all pyproject.toml files (root, tde, and tda packages) and the CHANGELOG.md to keep them synchronized.

24 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View