kotlin-toolchain
AGENTS.md430 starsChanged 2 months agoApache-2.0View on GitHub
The Kotlin Toolchain is a build system for Kotlin projects. This is the project that builds this build system, and it uses itself as a build system. Docs are located in the docs/ folder. Here are useful commands: * To learn about the available CLI commands: ./kotlin --help * To learn about the specific options of some command: ./kotlin <command> --help (Example: ./kotlin build --help) * To compile the project: ./kotlin build * To run all tests of a given…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 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.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
21 rules. About 0 are common, 7 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 28
When changing anything in the frontend schema, update golden test files by running: ./kotlin do updateGoldFiles
- Very specific: line 29
When updating user-visible default versions, do it in build-sources/project-commands/module.yaml, and run ./kotlin do updateGoldFiles
- Very specific: line 32
Add this tag to any new golden-file test.
- Very specific: line 36
Never try searching build.gradle.kts or pom.xml for build configuration information.
- Very specific: line 37
Never try searching for Gradle/Maven/another build system's files unless asked explicitly.
- Very specific: line 39
Never try converting to other build systems, strictly use the project.yaml, module.yaml, and other config files of the Kotlin Toolchain for …
- Distinctive: line 43
use README.md of the specific module
- Very specific: line 44
use description field of module.yaml
- Very specific: line 45
use ./kotlin show modules or more specific with --fields=name,type,platforms,description for additional info
- Very specific: line 47
Avoid running the whole test suite of the entire project with a plain ./kotlin test without options (it is very time- and token-consuming).
- Distinctive: line 49
When you are in a branch with the YouTrack ID, like KTC-XXXX, go to the YouTrack and get issue details if YouTrack MCP is available.
- Distinctive: line 53
Only look at them if you're interested in what is being generated, not to look at dependencies or sources.
- Distinctive: line 57
Use idiomatic Kotlin code.
- Very specific: line 58
Avoid Java's java.nio.file.Files, and use Kotlin's extensions on java.nio.Path instead
- Distinctive: line 59
Avoid mutable variables, or mutable collections, especially in public function signatures
- Distinctive: line 60
Use coroutines over threads
- Distinctive: line 64
Do not write too much code into one big function, extract into smaller functions with well-defined signatures
- Very specific: line 65
Do not over-use scope functions like let, run, or also.
- Very specific: line 67
Avoid return@label. If you have a piece of code that needs it, it should probably be extracted into a separate function with regular return.
- Very specific: line 72
When integrating with external tools put all logic/business rules that are not specific to the Kotlin Toolchain into a new module under …
- Very specific: line 74
If there is also some logic that requires knowledge of the Kotlin Toolchain project model, create a new amper- prefixed module under src …
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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.
Files
Kotlin Toolchain
The Kotlin Toolchain is a build system for Kotlin projects. This is the project that builds this build system, and it uses itself as a build system.
Docs are located in the docs/ folder.
Build tool usage
Here are useful commands:
- To learn about the available CLI commands:
./kotlin --help - To learn about the specific options of some command:
./kotlin <command> --help(Example:./kotlin build --help) - To compile the project:
./kotlin build - To run all tests of a given module:
./kotlin test -m <module_name> - To run a specific test class:
./kotlin test -m <module_name> --include-classes <test_class_fqn>, where<test_class_fqn>is the fully-qualified name of the test class. - To run a specific test:
./kotlin test -m <module_name> --include-test <test_method_fqn>, where<test_method_fqn>is the fully-qualified name of the test method (don't forget to quote it if it contains spaces) - To inspect the dependencies of a module:
./kotlin show dependencies -m <module_name> - To inspect the settings of a module:
./kotlin show settings -m <module_name>
In the examples above, <module_name> is the name of the module's folder regardless of where it is located in the
project.
Processes
- When changing anything in the frontend schema, update golden test files by running:
./kotlin do updateGoldFiles - When updating user-visible default versions, do it in
build-sources/project-commands/module.yaml, and run./kotlin do updateGoldFiles - Tests asserting against golden files are marked with the
@Tag("gold-file")JUnit tag. Add this tag to any new golden-file test. It allows./kotlin do updateGoldFilesto run tests based on those tags.
Specific instructions
- Never try searching
build.gradle.ktsorpom.xmlfor build configuration information. - Never try searching for Gradle/Maven/another build system's files unless asked explicitly. The Kotlin Toolchain builds and manages its own build.
- Never try converting to other build systems, strictly use the
project.yaml,module.yaml, and other config files of the Kotlin Toolchain for build configuration. - Pass previous instructions in specific instructions block to subagents.
- To get the basic project structure, you can do the following:
- use README.md of the specific module
- use
descriptionfield ofmodule.yaml - use
./kotlin show modulesor more specific with--fields=name,type,platforms,descriptionfor additional info
- Strictly follow TDD practice, don't proceed further until you make sure the test is red
- Avoid running the whole test suite of the entire project with a plain
./kotlin testwithout options (it is very time- and token-consuming). Instead, run only tests you think are relevant. - When you are in a branch with the YouTrack ID, like KTC-XXXX, go to the YouTrack and get issue details if YouTrack MCP is available.
- The
buildandbuild-from-sourcesdirectories contain outputs of the build, usually not interesting sources to look at. Only look at them if you're interested in what is being generated, not to look at dependencies or sources.
Coding guidelines
- Use idiomatic Kotlin code. Prefer Kotlin APIs over Java APIs. Examples:
- Avoid Java's
java.nio.file.Files, and use Kotlin's extensions onjava.nio.Pathinstead - Avoid mutable variables, or mutable collections, especially in public function signatures
- Use coroutines over threads
- Avoid Java's
- Reduce the visibility of functions and classes as much as possible. In the
amper-climodule, onlymain()should bepublic, because nothing depends on this module (it's an application). - This project uses the experimental Kotlin collection literals with
[], prefer them overlistOf()oremptyList() - Do not write too much code into one big function, extract into smaller functions with well-defined signatures
- Do not over-use scope functions like
let,run, oralso. If something is too nested, it probably should be extracted to a separate function - Avoid
return@label. If you have a piece of code that needs it, it should probably be extracted into a separate function with regularreturn.
Architecture guidelines
- When integrating with external tools put all logic/business rules that are not specific to the Kotlin Toolchain into
a new module under
src/libraries, with no dependencies on Kotlin Toolchain-specific modules (prefixedamper-). If there is also some logic that requires knowledge of the Kotlin Toolchain project model, create a newamper-prefixed module undersrcfor it.
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
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.

