# square/kotlinpoet

A Kotlin API for generating .kt source files.

Repository: https://github.com/square/kotlinpoet
Canonical: https://ross.abutalabs.com/products/kotlinpoet
Homepage: https://square.github.io/kotlinpoet/
Language: Kotlin
License: Apache-2.0
License Family: permissive
Topics: kotlin, code-generation, javapoet
Last push: 2026-08-26T22:09:41+00:00

## Health v2 (maintenance only)
Score: 83/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 53, longevity 100
- inputs: {"age_days": 3472, "days_push": 7, "days_rel": 159, "gap_med": 125, "n_releases_24m": 4}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 4157, forks 316 (observed 2026-08-28T04:08:36.582109+00:00)

## What it is
KotlinPoet is a Kotlin and Java API for generating .kt source files, inspired by JavaPoet. It is commonly used for annotation processing and generating code from metadata such as database schemas or protocol formats.

## Use cases
- generate kotlin source files programmatically
- write an annotation processor that emits kotlin code
- generate boilerplate from database schemas
- generate kotlin classes from protocol or metadata files
- avoid hand-writing repetitive kotlin code

## When to choose
- you need to emit valid Kotlin source code from JVM code
- you are building a Kotlin compiler plugin or annotation processor
- you want a fluent, type-safe API instead of string-templated code generation

## When to avoid
- you need to generate Java source code (use JavaPoet instead)
- you need to parse or analyze existing Kotlin code rather than generate it
- your target language is not Kotlin

## Facets
- artifact type: library
- maturity: stable
- function: developer-tools
- domain: developer-tools, programming-languages
- platform: jvm
- tags: kotlin, code-generation, javapoet-inspired, annotation-processing, source-generation

## Member repositories
- square/kotlinpoet (main) score 83

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:08:36.582109+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:22:51.653173+00:00, confidence not recorded.
  - readme: https://github.com/square/kotlinpoet (fetched 2026-08-28T04:08:36.582109+00:00, sha 7cfe45f90766)
  - homepage: https://square.github.io/kotlinpoet/ (fetched 2026-08-29T09:13:36.495420+00:00, sha f794da142200)
- Data as of 2026-08-30T08:39:29.467469+00:00.
