agentleFS
JetBrainsKnown publisherJetBrains/kotlin-toolchain/AGENTS.md

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.

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
  1. Very specific:

    When changing anything in the frontend schema, update golden test files by running: ./kotlin do updateGoldFiles

    line 28
  2. Very specific:

    When updating user-visible default versions, do it in build-sources/project-commands/module.yaml, and run ./kotlin do updateGoldFiles

    line 29
  3. Very specific:

    Add this tag to any new golden-file test.

    line 32
  4. Very specific:

    Never try searching build.gradle.kts or pom.xml for build configuration information.

    line 36
  5. Very specific:

    Never try searching for Gradle/Maven/another build system's files unless asked explicitly.

    line 37
  6. Very specific:

    Never try converting to other build systems, strictly use the project.yaml, module.yaml, and other config files of the Kotlin Toolchain for …

    line 39
  7. Distinctive:

    use README.md of the specific module

    line 43
  8. Very specific:

    use description field of module.yaml

    line 44
  9. Very specific:

    use ./kotlin show modules or more specific with --fields=name,type,platforms,description for additional info

    line 45
  10. Very specific:

    Avoid running the whole test suite of the entire project with a plain ./kotlin test without options (it is very time- and token-consuming).

    line 47
  11. Distinctive:

    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.

    line 49
  12. Distinctive:

    Only look at them if you're interested in what is being generated, not to look at dependencies or sources.

    line 53
  13. Distinctive:

    Use idiomatic Kotlin code.

    line 57
  14. Very specific:

    Avoid Java's java.nio.file.Files, and use Kotlin's extensions on java.nio.Path instead

    line 58
  15. Distinctive:

    Avoid mutable variables, or mutable collections, especially in public function signatures

    line 59
  16. Distinctive:

    Use coroutines over threads

    line 60
  17. Distinctive:

    Do not write too much code into one big function, extract into smaller functions with well-defined signatures

    line 64
  18. Very specific:

    Do not over-use scope functions like let, run, or also.

    line 65
  19. Very specific:

    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.

    line 67
  20. Very specific:

    When integrating with external tools put all logic/business rules that are not specific to the Kotlin Toolchain into a new module under …

    line 72
  21. Very specific:

    If there is also some logic that requires knowledge of the Kotlin Toolchain project model, create a new amper- prefixed module under src …

    line 74

≈ “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.

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

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 updateGoldFiles to run tests based on those tags.

Specific instructions

  • Never try searching build.gradle.kts or pom.xml for 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 description field of module.yaml
    • use ./kotlin show modules or more specific with --fields=name,type,platforms,description for 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 test without 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 build and build-from-sources directories 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 on java.nio.Path instead
    • Avoid mutable variables, or mutable collections, especially in public function signatures
    • Use coroutines over threads
  • Reduce the visibility of functions and classes as much as possible. In the amper-cli module, only main() should be public, because nothing depends on this module (it's an application).
  • This project uses the experimental Kotlin collection literals with [], prefer them over listOf() or emptyList()
  • 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, or also. 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 regular return.

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 (prefixed amper-). If there is also some logic that requires knowledge of the Kotlin Toolchain project model, create a new amper- prefixed module under src for it.

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.