agentleFS
GoogleKnown publishergoogle/ksp/AGENTS.md

ksp

AGENTS.md3.5k starsChanged 9 days agoApache-2.0View on GitHub

Welcome! This file defines the mandatory workflow, engineering methodology, and project context for AI coding agents working in the Kotlin Symbol Processing (KSP) repository. You are working on a compiler plugin and symbol processing engine. There must be zero speculation, hand-waving, or hallucination. where `<CURREN

Adopted by

Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data

Week of Sep 13: 0 new projectsWeek of Sep 20: 0 new projectsWeek of Sep 27: 0 new projectsWeek of Oct 4: 0 new projectsWeek of Oct 11: 0 new projectsWeek of Oct 18: 0 new projectsWeek of Oct 25: 0 new projectsWeek of Nov 1: 0 new projects
Sep 2026Oct 2026Nov 2026
New projects taking a version of this file each week, over the 8 weeks our latest run read: only 0 in all, so this is a hint, not a trend.

Who's talking about google/ksp

The biggest 5 of 50 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 50

Talked about on GitHub (50 times).

On GitHub · 50

45 more on GitHub
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 31,439 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

The file

We split this AGENTS.md into the rules it gives an agent

7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read CONTRIBUTING.md First: Before proposing plans or modifying code, read CONTRIBUTING.md.

    line 9
  2. Distinctive:

    Consult Additional Documentation On-Demand: Read the following repository documents when relevant to your task.

    line 10
  3. Distinctive:

    The Codebase is the Single Source of Truth: Every claim, diagnosis, or proposed change must be backed by concrete code snippets and traced …

    line 18
  4. Very specific:

    No Guessing: If an API contract, compiler behavior, or user requirement is ambiguous, inspect the implementation and test suite …

    line 23
  5. Distinctive:

    Outline a Detailed Plan First: Always outline a clear, detailed plan supported by code references and dataflow analysis before you begin.

    line 24
  6. Very specific:

    Copyright Headers: All new source files (.kt, .java) must include the standard Apache 2.0 license header used across the codebase:

    line 35
  7. Very specific:

    Before submitting a pull request to the KSP repository, you must always run the entire ./gradlew check task and check that it completes …

    line 132

≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md — Guidelines for AI Coding Agents in KSP

Welcome! This file defines the mandatory workflow, engineering methodology, and project context for AI coding agents working in the Kotlin Symbol Processing (KSP) repository.


1. Documentation Discovery & Reference Map

  1. Read CONTRIBUTING.md First: Before proposing plans or modifying code, read CONTRIBUTING.md. It is the authoritative source for the bug contribution workflow (@Bug / BugState), api/api.base verification (checkApi / updateApi), and writing unit tests in kotlin-analysis-api.
  2. Consult Additional Documentation On-Demand: Read the following repository documents when relevant to your task. Documentation can be found in Markdown files, LICENSE, and doc comments in Kotlin source files.

2. Core Engineering Methodology: Scientific Method & Zero Speculation

You are working on a compiler plugin and symbol processing engine. There must be zero speculation, hand-waving, or hallucination.

  • The Codebase is the Single Source of Truth: Every claim, diagnosis, or proposed change must be backed by concrete code snippets and traced through the actual codebase.
  • Falsify Hypotheses First (Scientific Method):
    • Whenever you form a hypothesis about how a symbol is resolved, how a type is computed, or why a bug occurs, actively try to disprove your hypothesis first using concrete code examples and dataflow examples from the codebase.
    • Trace the exact dataflow end-to-end (e.g., from Resolver entry points to AnnotationResolutionStrategy / Analysis API session calls to KSNode / KSType wrappers to PSI / FIR symbols) and cite the concrete classes, functions, and line ranges involved.
    • Revise your mental model repeatedly whenever the code contradicts your assumptions.
  • No Guessing: If an API contract, compiler behavior, or user requirement is ambiguous, inspect the implementation and test suite (kotlin-analysis-api/testData and KSPUnitTestSuite.kt) or ask the user clarifying questions rather than guessing.
  • Outline a Detailed Plan First: Always outline a clear, detailed plan supported by code references and dataflow analysis before you begin. Use this plan as your reference when you are making changes.
  • Preserve & Synchronize Documentation:
    • Preserve all existing comments and docstrings unrelated to your changes unless explicitly instructed otherwise.
    • Keep Documentation in Sync with Code Changes: Whenever you modify code, behavior, APIs, Gradle properties, or build configurations, you must also update the corresponding KDoc/doc comments and any relevant documentation files in the repository (e.g., README.md, CONTRIBUTING.md, DEVELOPMENT.md, AGENTS.md, or docs/) so that documentation never drifts out of sync with the implementation. This AGENTS.md file must also be kept in sync.

3. License & Legal Compliance

  • License: This repository is licensed under the Apache License, Version 2.0 (see LICENSE).
  • CLA: Contributions require a Google Contributor License Agreement (CONTRIBUTING.md).
  • Copyright Headers: All new source files (.kt, .java) must include the standard Apache 2.0 license header used across the codebase:
/*
 * Copyright <CURRENT YEAR> Google LLC
 * Copyright 2010-<CURRENT YEAR> JetBrains s.r.o. and Kotlin Programming Language contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

where <CURRENT YEAR> is the current year.

You will likely find files that do not have a copyright header. The headers may have been lost when moving the file in the editor. Do not restore those.


4. Repository Architecture & Module Guide

Important Note on KSP1: KSP 1.x has been removed and is no longer supported (README.md). All active compiler engine development targets KSP2 (kotlin-analysis-api).

The project consists of Gradle subprojects configured in settings.gradle.kts:

ModulePurpose & Key Details
:apiPublic-facing, dependency-free library (com.google.devtools.ksp:symbol-processing-api). Tracked by Metalava against api/api.base.
:kotlin-analysis-apiCore KSP2 engine implemented on top of the Kotlin Analysis API (FIR/K2). Key entry points: KotlinSymbolProcessing.kt (src/main/kotlin/com/google/devtools/ksp/impl/), ResolverAAImpl.kt, AnnotationResolutionStrategy.kt (src/main/kotlin/com/google/devtools/ksp/common/impl/ with AAResolutionStrategy and PsiResolutionStrategy), all KS* symbol implementations (src/main/kotlin/com/google/devtools/ksp/impl/symbol/), and the primary unit test suite (KSPUnitTestSuite.kt).
:symbol-processing-aa-embeddableRepackages :kotlin-analysis-api and its dependencies into a self-contained uber-jar, relocating bundled packages under the ksp.* namespace (symbol-processing-aa-embeddable/build.gradle.kts) to avoid classpath conflicts. Entry point: KSPLoader.loadAndRunKSP().
:gradle-pluginThe KSP Gradle plugin (id("com.google.devtools.ksp"), KspGradleSubplugin in KspSubplugin.kt, and KspAATask.kt). Configures KSP tasks for JVM, Android, and Kotlin Multiplatform (KMP) projects.
:common-utilShared internal utilities used by :kotlin-analysis-api and other modules.
:common-depsShared dependencies and command-line argument parsing utilities (symbol-processing-common-deps). Uses :cmdline-parser-gen via KSP.
:cmdline-parser-genInternal KSP processor used during the build to generate command-line parser code for :common-deps.
:integration-testsEnd-to-end Gradle TestKit tests validating the published KSP uber-jar and Gradle plugin across real build scenarios (primaryTest, secondaryTest, androidTest, agpTest).
:symbol-processingDummy POM-only artifact maintained for KotlinCompilerPluginSupportPlugin compatibility.
:test-utilsLegacy test utilities. Deprecated for new unit tests (CONTRIBUTING.md)—all new unit tests belong in :kotlin-analysis-api.

5. Contribution, Bug & Testing Workflows

Read CONTRIBUTING.md.

6. Build, Version Synchronization & Verification Reference

JDK & Kotlin Version Constraints

  • Carefully read the Gradle build files for a particular module to find out what its Java and Kotlin constraints are.
  • Decoupled Versions (gradle.properties & gradle/libs.versions.toml):
    • buildKotlinVersion / buildKspVersion: Used in gradle.properties to bootstrap and compile the KSP project itself.
    • kotlinBaseVersion (kotlin-base) & agpBaseVersion (agp-base): Duplicated in both gradle.properties and gradle/libs.versions.toml. gradle-plugin's TestConfig loads gradle.properties directly at test runtime—always keep both files in sync.
    • aa-kotlin-base (aaKotlinBaseVersion): The specific (often developmental) Kotlin version used for Analysis API dependencies in :kotlin-analysis-api and :symbol-processing-aa-embeddable.

Essential Gradle Tasks

  • Run a single unit test method across all 4 suite configurations:

    Note: Because KSPUnitTestSuite is abstract, use a wildcard or a concrete subclass name with --tests:

    ./gradlew :kotlin-analysis-api:test --tests "*.<testMethodName>"
  • Run all Analysis API unit tests:
    ./gradlew :kotlin-analysis-api:test
  • Check / Update Public API Signatures (Metalava): Whenever modifying public declarations in :api, verify compatibility against api/api.base:
    ./gradlew :api:checkApi
    ./gradlew :api:updateApi
  • Shadow JAR & Relocation Validation:
    • ./gradlew :kotlin-analysis-api:validateShadowJar: Runs jdeps against kotlin-analysis-api/shadow-validation-baseline.txt and verifies no forbidden packages (such as org/apache/log4j/jdbc) leak into the shadow JAR.
    • ./gradlew :symbol-processing-aa-embeddable:shadowJar: Verifies that all bundled classes are relocated into allowed ksp.* namespaces.
  • Gradle Plugin Tests:
    • ./gradlew :gradle-plugin:test: Runs tests for the KSP Gradle plugin.
  • Run Integration Tests: Integration tests publish all artifacts to <rootProject>/build/repos/test and run Gradle TestKit suites (integration-tests/build.gradle.kts):
    ./gradlew :integration-tests:primaryTest
    ./gradlew :integration-tests:secondaryTest
    ./gradlew :integration-tests:androidTest
    ./gradlew :integration-tests:agpTest
    Integration tests may take a long time to run so it may be helpful to just run a single test or test class when making changes, e.g.,
    ./gradlew :integration-tests:primaryTest --tests "com.google.devtools.ksp.test.primary.<TestClass>.<method>"
    where TestClass is the name of the class containing tests and method is the name of test method/entrypoint.
  • Full Verification: Before submitting a pull request to the KSP repository, you must always run the entire ./gradlew check task and check that it completes successfully.

    Note: It may be necessary to pass --rerun-tasks to ensure cached test or task outputs are re-evaluated after changes.

    ./gradlew check --rerun-tasks

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.