agentsclimarketplace

Skill

Skill singhsume123/kapt-to-ksp-skill/skill

Migrate Android projects from KAPT to KSP annotation processing. Triggers on: kapt, ksp, annotation processing, build speed, Hilt to KSP, Room to KSP, or build.gradle files containing kapt dependencies.From its SKILL.md

Install
npx -y skills add singhsume123/kapt-to-ksp-skill --skill skill

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

5.6 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it

KAPT to KSP Migration

Background

Why KAPT is Slow

KAPT (Kotlin Annotation Processing Tool) works by generating Java stubs from Kotlin code, then running standard Java annotation processors against those stubs. This means:

  • Double symbol resolution: Kotlin compiler resolves symbols once to generate stubs, then the Java annotation processor resolves them again.
  • Stub generation overhead: Every Kotlin file with annotations gets a corresponding Java stub file generated, even if no processor needs it.
  • No incremental processing by default: Most KAPT processors don't support incremental processing, so the full stub generation and processing runs on every build.

Why KSP is Faster

KSP (Kotlin Symbol Processing) reads Kotlin source code directly through a Kotlin compiler plugin. This means:

  • No stub generation: KSP sees Kotlin symbols directly — no intermediate Java stubs.
  • Kotlin-native types: KSP sees actual Kotlin types including nullability, suspend functions, and default parameters.
  • Incremental by default: KSP tracks which files each processor depends on and only reprocesses what changed.
  • Typical speedup: 25-50% faster annotation processing vs KAPT.

KAPT Status

KAPT is in maintenance mode. Google recommends migrating to KSP for all annotation processing. Major libraries (Hilt/Dagger, Room, Moshi, Glide) all support KSP.


Migration Workflow

Follow these 6 steps to migrate from KAPT to KSP:

Step 1: Analyze Current KAPT Usage

Scan your project for:

  • kotlin("kapt") or id("org.jetbrains.kotlin.kapt") plugin declarations
  • kapt(...) dependency declarations
  • kaptTest(...) and kaptAndroidTest(...) test dependencies
  • kapt { arguments { ... } } configuration blocks
  • Any kapt.incremental.apt or other kapt settings in gradle.properties

List every library that uses KAPT and check if it supports KSP. See references/hilt.md and references/room.md for library-specific details.

Step 2: Add KSP Plugin

Add the KSP Gradle plugin. The KSP version must align with your Kotlin version.

// Project-level build.gradle.kts
plugins {
    id("com.google.devtools.ksp") version "<KOTLIN_VERSION>-<KSP_RELEASE>" apply false
}

KSP version format: <kotlin-version>-<ksp-release>. For example:

  • Kotlin 2.0.0 → KSP 2.0.0-1.0.24
  • Kotlin 2.0.21 → KSP 2.0.21-1.0.28
  • Kotlin 2.1.0 → KSP 2.1.0-1.0.29

Check KSP releases for the latest version matching your Kotlin version.

Step 3: Migrate Dependencies Library-by-Library

For each module, apply the KSP plugin and swap dependencies:

plugins {
    id("com.google.devtools.ksp")
}

dependencies {
    // Before:
    // kapt("com.example:processor:1.0")
    // After:
    ksp("com.example:processor:1.0")

    // Test dependencies too:
    // kaptTest("com.example:processor:1.0")
    kspTest("com.example:processor:1.0")

    // Android test dependencies:
    // kaptAndroidTest("com.example:processor:1.0")
    kspAndroidTest("com.example:processor:1.0")
}

Migrate one library at a time. Build and test after each migration.

Step 4: Migrate Processor Arguments

KAPT and KSP use different syntax for passing arguments to processors:

// KAPT syntax:
kapt {
    arguments {
        arg("room.schemaLocation", "$projectDir/schemas")
        arg("room.incremental", "true")
    }
}

// KSP syntax:
ksp {
    arg("room.schemaLocation", "$projectDir/schemas")
    arg("room.incremental", "true")
}

Step 5: Clean Up

Once all processors are migrated to KSP:

  • Remove kotlin("kapt") plugin from every module
  • Remove any kapt { ... } configuration blocks
  • Remove kapt-related settings from gradle.properties
  • Exception: Keep kotlin("kapt") if you still use Data Binding with kapt. Data Binding does not yet support KSP.

Step 6: Verify

  1. Clean build: ./gradlew clean assembleDebug
  2. Run tests: ./gradlew testDebugUnitTest
  3. Run instrumented tests: ./gradlew connectedDebugAndroidTest
  4. Compare build times: Run a clean build before and after migration to measure improvement.

Common Errors

ErrorCauseFix
Unresolved reference: kspKSP plugin not applied to the moduleAdd id("com.google.devtools.ksp") to the module's plugins block
KSP version X does not match Kotlin version YKSP/Kotlin version mismatchUse KSP version that matches your Kotlin version exactly
Could not resolve com.example:processorLibrary doesn't have a KSP artifact, or wrong artifact IDCheck library docs — some use a different artifact for KSP
Nullability errors in generated codeKSP sees actual Kotlin types (stricter than KAPT)Fix source code nullability — see references/room.md
DefaultImpls errorsRoom < 2.6.0 with default interface methodsUpdate Room to 2.6.0+ — see references/room.md
Build succeeds but app crashes at runtimeGenerated code differences between KAPT and KSPClean build, check for mixed KAPT/KSP in same module

Library-Specific References

  • Hilt/Dagger Migration — Build file changes only, no source code changes needed.
  • Room Migration — Build file changes AND possible source code fixes for nullability and DAO patterns.

What ships with it: 2 files

17.6 KB alongside SKILL.md

references/

Keep looking

Skills are one crate of 326,512. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.