RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/AGENTS.md/JetBrains/kotlin

AGENTS.md

analysis/AGENTS.md
AGENTS.md

Quality

86/100

Scores the file, not the repository.

Length

668 words

14 headings · 3 code blocks

Repository

53k

— · pushed 0 days ago

Last changed

3 days ago

First indexed 3 days ago.
JetBrains/kotlin/analysis/AGENTS.mdRawGitHub
1# Analysis API Guidelines
2 
3A library for analyzing Kotlin code at the semantic level, providing structured access to symbols, types, and semantic relationships.
4 
5**Entry point:** Use [`analyze()`](analysis-api/src/org/jetbrains/kotlin/analysis/api/analyze.kt) to start an analysis session. See [Analysis API documentation](https://kotl.in/analysis-api) for a usage guide.
6 
7## Architecture
8 
9- **Platform** — Provides declarations, project structure, and modification events (IntelliJ, Standalone)
10- **Engine** — Performs code analysis using platform-provided information (K1, K2)
11- **User** — Code that calls `analyze()` to work with symbols and types
12 
13→ READ [`analysis-api-platform-interface/README.md`](analysis-api-platform-interface/README.md) for detailed architecture overview
14 
15## Relationship with PSI
16 
17Analysis API builds on top of Kotlin PSI (`compiler/psi/`):
18- **PSI** provides syntax (structure of code): `KtElement`, `KtExpression`, `KtDeclaration`
19- **Analysis API** provides semantics (meaning of code): `KaSymbol`, `KaType`
20 
21```
22PSI (syntax) → Analysis API (semantics) → Symbols, Types, Resolution
23```
24 
25**Both PSI and Analysis API follow shared development principles** documented in [`docs/contribution-guide/api-development.md`](docs/contribution-guide/api-development.md).
26 
27WHEN working with PSI elements:
28→ READ [`compiler/psi/AGENTS.md`](../compiler/psi/AGENTS.md) for PSI-specific rules and conventions
29 
30## Key Conventions
31 
32- `Ka` prefix for Analysis API types, `Kt` for PSI types
33- Prefer interfaces to classes for better binary compatibility
34- Properties for attributes, functions for actions with parameters
35- Return nullable types for operations that can fail (avoid exceptions for non-exceptional cases)
36- All implementations must validate lifetime ownership with `withValidityAssertion`
37- Mark experimental APIs with `@KaExperimentalApi`, implementation details with `@KaImplementationDetail`
38 
39## Working with Test Data
40 
41When modifying test data files or running generated tests (`*Generated`) that compare output against `.txt` files, use `updateTestData` (to rewrite files) or `checkTestData` (to verify only) instead of standard test commands. Both take their options as `-P` properties, so changing filters between runs stays fast.
42 
43### `updateTestData` — the only recommended way to update test data
44 
45```bash
46# Update test data by directory (preferred for iteration)
47./gradlew updateTestData -Porg.jetbrains.kotlin.testDataManager.options.testDataPath=analysis/analysis-api/testData/components/resolver/
48 
49# Update test data by test class pattern
50./gradlew updateTestData -Porg.jetbrains.kotlin.testDataManager.options.testClassPattern=.*ResolveTest.*
51 
52# Run only golden tests (useful for quick baseline updates)
53./gradlew updateTestData -Porg.jetbrains.kotlin.testDataManager.options.goldenOnly=true
54 
55# Incremental update — only re-run variant tests for changed paths
56./gradlew updateTestData -Porg.jetbrains.kotlin.testDataManager.options.incremental=true
57 
58# Limit to a subset of modules using task paths (Gradle task-name matching)
59./gradlew :analysis:analysis-api-fir:updateTestData :analysis:stubs:updateTestData
60```
61 
62`updateTestData` is fixed to update mode. There is no `updateTestDataGlobally` — Gradle's task-name matching runs the task in every applicable subproject when invoked from the repo root.
63 
64### `checkTestData` — verification only
65 
66If you specifically need to verify that existing test data is consistent without modifying anything (e.g., sanity-checking generated files after an `updateTestData` run), use `checkTestData`. It is the exact `-P`-driven counterpart of `updateTestData` but fixed to check mode: it fails on any mismatch and writes nothing.
67 
68```bash
69./gradlew checkTestData -Porg.jetbrains.kotlin.testDataManager.options.testDataPath=analysis/analysis-api/testData/components/resolver/singleByPsi/
70```
71 
72Use this only for verification. For any workflow that writes test data, use `updateTestData`.
73 
74**Why use these tasks instead of plain `:test`?**
75- Run only relevant tests (filtered by path or class pattern)
76- Handle variant chains correctly (golden `.txt` files run before variant-specific `.js.txt`, `.wasm.txt`, etc.)
77- Automatically discover all modules that use managed test data
78- Detect and remove redundant variant files
79 
80For full options, see [test-data-manager-convention](../repo/gradle-build-conventions/test-data-manager-convention/README.md).
81 
82## Key Components
83 
84- [`analysis-api/`](analysis-api) - User-facing API surface (`KaSession`, `KaSymbol`, `KaType`)
85- [`analysis-api-platform-interface/`](analysis-api-platform-interface) - Platform abstraction (declaration providers, project structure, lifetime)
86- [`analysis-api-standalone/`](analysis-api-standalone) - CLI-based implementation of the Analysis API
87- [`analysis-api-fir/`](analysis-api-fir) - K2 implementation based on FIR
88- [`analysis-api-impl-base/`](analysis-api-impl-base) - Shared implementation utilities
89- [`low-level-api-fir/`](low-level-api-fir) - K2-specific infrastructure for lazy/incremental analysis
90- [`symbol-light-classes/`](symbol-light-classes) - Java PSI view of Kotlin declarations for interop
91- [`decompiled/light-classes-for-decompiled`](decompiled/light-classes-for-decompiled) - Light classes for decompiled/library code
92- [`test-data-manager/`](test-data-manager) - Infrastructure for managing test data files with variant chains
93 
94## Detailed Documentation
95 
96WHEN adding or modifying API endpoints:
97→ READ [`docs/contribution-guide/api-development.md`](docs/contribution-guide/api-development.md)
98 
99WHEN deprecating API or understanding stability categories:
100→ READ [`docs/contribution-guide/api-evolution.md`](docs/contribution-guide/api-evolution.md)
101 
102WHEN implementing platform components:
103→ READ [`analysis-api-platform-interface/README.md`](analysis-api-platform-interface/README.md)
104 
105WHEN working with light classes:
106→ READ [`symbol-light-classes/README.md`](symbol-light-classes/README.md)
107 
108WHEN working with lazy resolution (LL API):
109→ READ [`low-level-api-fir/README.md`](low-level-api-fir/README.md)
110 
111WHEN writing or managing test data files:
112→ READ [`test-data-manager/AGENTS.md`](test-data-manager/AGENTS.md)
113 
114WHEN seeking historical context on design decisions:
115→ READ [`docs/design-documents/README.md`](docs/design-documents/README.md) (these are historical snapshots, not necessarily up to date)
116 
117WHEN working with stubs:
118→ READ [`stubs/README.md`](stubs/README.md)
119 

Commands it names

  • ./gradlew updateTestData -Porg.jetbrains.kotlin.testDataManager.options.testDataPath=analysis/analysis-api/testData/components/resolver/
  • ./gradlew updateTestData -Porg.jetbrains.kotlin.testDataManager.options.testClassPattern=.*ResolveTest.*
  • ./gradlew updateTestData -Porg.jetbrains.kotlin.testDataManager.options.goldenOnly=true
  • ./gradlew updateTestData -Porg.jetbrains.kotlin.testDataManager.options.incremental=true
  • ./gradlew :analysis:analysis-api-fir:updateTestData :analysis:stubs:updateTestData
  • ./gradlew checkTestData -Porg.jetbrains.kotlin.testDataManager.options.testDataPath=analysis/analysis-api/testData/components/resolver/singleByPsi/

Sections

  • Analysis API Guidelines
  • Architecture
  • Relationship with PSI
  • Key Conventions
  • Working with Test Data
  • `updateTestData` — the only recommended way to update test data
  • Update test data by directory (preferred for iteration)
  • Update test data by test class pattern
  • Run only golden tests (useful for quick baseline updates)
  • Incremental update — only re-run variant tests for changed paths
  • Limit to a subset of modules using task paths (Gradle task-name matching)
  • `checkTestData` — verification only
  • Key Components
  • Detailed Documentation

What it covers

testcode-stylearchitectureapidocs

Stack — with the evidence

kotlin

(1.00)

java

(0.60)

Format

AGENTS.md

A plain-markdown README for coding agents, deliberately unopinionated: no frontmatter, no globs, no vendor keys. That minimalism is why it became the one file a dozen different agents will read, and why it carries the least per-file targeting power of any format here.

What the corpus says about it

Repository

Owner
JetBrains
Language
—
License
—
Archived
no

All configs in this repo

Also in JetBrains/kotlin

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
JetBrains/kotlincompiler/AGENTS.md · 53kAGENTS.mdkotlinjavabuildtestgit52/1003 days ago
JetBrains/kotlincompiler/build-tools/AGENTS.md · 53kAGENTS.mdkotlinjavabuildteststylearch+289/1003 days ago
JetBrains/kotlinCLAUDE.md · 53kCLAUDE.mdkotlinjavaagent-behaviour25/1003 days ago
JetBrains/kotlinanalysis/test-data-manager/AGENTS.md · 53kAGENTS.mdkotlinjavateststylearchagent-behaviour66/1003 days ago
JetBrains/kotlincompiler/fir/analysis-tests/AGENTS.md · 53kAGENTS.mdkotlinjavatestlint-formatarchdeployment74/1003 days ago
JetBrains/kotlincompiler/psi/AGENTS.md · 53kAGENTS.mdkotlinjavateststylearchtesting-strategy+381/1003 days ago
Diff against compiler/AGENTS.md Diff against compiler/build-tools/AGENTS.md Diff against CLAUDE.md Diff against analysis/test-data-manager/AGENTS.md Diff against compiler/fir/analysis-tests/AGENTS.md Diff against compiler/psi/AGENTS.md

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
elastic/elasticsearchx-pack/plugin/inference/AGENTS.md · 78kAGENTS.mdjavanode+4buildtestlint-formatstyle+3100/1003 days ago
elastic/elasticsearchx-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/AGENTS.md · 78kAGENTS.mdjavanode+4buildtestlint-formatstyle+2100/1003 days ago
react/react-nativepackages/react-native-compatibility-check/AGENTS.md · 126kAGENTS.mdreactreact-native+11testlint-formatstylearch+499/1003 days ago
kurikomi-labs/komi-storeAGENTS.md · 17kAGENTS.mdkotlinjava+1buildlint-formatstylearch+197/1003 days ago
tiann/KernelSUAGENTS.md · 18kAGENTS.mdkotlinvue+3setupbuildlint-formatstyle+497/1003 days ago
elastic/elasticsearchAGENTS.md · 78kAGENTS.mdjavanode+4buildtestlint-formatstyle+696/1003 days ago
alibaba/nacosAGENTS.md · 33kAGENTS.mdjavanode+8buildtestlint-formatstyle+696/1003 days ago
ktorio/ktorAGENTS.md · 14kAGENTS.mdkotlinjava+1buildlint-formatstylearch+796/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack