agentleFS
JetBrainsKnown publisherJetBrains/koog/.claude/skills/add-java-code-snippets-in-docs/SKILL.md

add-java-code-snippets-in-docs

Skill4.6k starsChanged 7 months agoApache-2.0View on GitHub

Use when the user asks to add Java tabs/examples to mkdocs docs that already have Kotlin examples (files under docs/docs/**.md using === "Kotlin" / Knit INCLUDE+SUFFIX blocks). Handles mkdocs-material tabs, Knit directives, @JavaAPI bridge methods, and JVM factory classes.

Trending

More talk lately.about the whole repository

Dec 2025: 1 mentionJan 2026: 0 mentionsFeb 2026: 2 mentionsMar 2026: 5 mentionsApr 2026: 2 mentionsMay 2026: 2 mentionsJun 2026: 0 mentionsJul 2026: 4 mentionsAug 2026: 3 mentionsSep 2026: 12 mentionsOct 2026: 5 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the JetBrains/koog repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about JetBrains/koog

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

See all 59

Talked about on GitHub, Bluesky and Hacker News (59 times).

On GitHub · 46

41 more on GitHub

On Bluesky · 12

7 more on Bluesky

On Hacker News · 1

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 7 are distinctive, and 6 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.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read one reference doc to anchor on the established pattern:

    line 23
  2. Very specific:

    Check existing Java tab: If absent → add one. If it has empty / */ placeholder content → replace entirely.

    line 37
  3. Very specific:

    Consider Kotlin-side alignment: If the Kotlin block uses Kotlin-only APIs (kotlinx.io, MutableStateFlow, KLogger, inline Duration), …

    line 38
  4. Distinctive:

    Always import in INCLUDE; never use FQNs in visible code.

    line 89
  5. Very specific:

    Never use file-level annotations (@file:Suppress, @file:OptIn) — scope to specific declarations.

    line 90
  6. Very specific:

    If Kotlin shows no main(), Java must hide main() in INCLUDE/SUFFIX.

    line 96
  7. Very specific:

    If Kotlin shows install(Feature) { ...

    line 97
  8. Distinctive:

    If Kotlin creates a writer before the agent, Java must too.

    line 98
  9. Very specific:

    If Kotlin shows agent.run(input), Java must too.

    line 99
  10. Distinctive:

    Read both visible blocks side-by-side after writing.

    line 101
  11. Distinctive:

    When the Kotlin block uses an entirely Kotlin-only API:

    line 107
  12. Distinctive:

    Do NOT leave the Java tab empty: Write a compilable Java class with explanatory comments.

    line 109
  13. Distinctive:

    After each Java block:

    line 132

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill 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
SKILL.md

When to use

Adding Java code blocks alongside existing Kotlin blocks in mkdocs documentation (docs/docs/**.md). Typical triggers: "add Java examples to <file>", "add Java tabs", "complete the Java side of <doc>", "fix the Java block in <doc>".

Do NOT use this skill for:

  • Writing brand-new Kotlin docs (no precursor Kotlin block to mirror).
  • Splitting source files between JVM and non-JVM source sets — use the split-jvm-nonjvm skill instead.
  • Java examples outside the mkdocs/Knit pipeline.

Prerequisites

JDK 17. Gradle 8.x fails cryptically on newer JDKs. If the default JDK is newer, prefix every ./gradlew command in this workflow with JAVA_HOME=/path/to/jdk-17.

Before starting

Read one reference doc to anchor on the established pattern:

  • docs/docs/features/tracing.md — full Tracing feature (blocks 1–6).
  • docs/docs/agent-events.md — custom FeatureMessageProcessor subclass (suspend bridge methods handleMessage / handleClose).
  • docs/docs/testing.md — MockPromptExecutor builder, tool mocking, comment-only blocks for Kotlin-only DSL.
  • docs/docs/features/open-telemetry/index.md — OpenTelemetry examples.
  • docs/docs/features/open-telemetry/opentelemetry-langfuse-exporter.md — Langfuse exporter.
  • docs/docs/features/open-telemetry/opentelemetry-weave-exporter.md — Weave exporter.

Workflow

For each Kotlin code block in the target .md:

  1. Read the Kotlin block: INCLUDE, visible code, SUFFIX, KNIT directive.
  2. Check existing Java tab. If absent → add one. If it has empty /** */ placeholder content → replace entirely. If it has real content → update.
  3. Consider Kotlin-side alignment. If the Kotlin block uses Kotlin-only APIs (kotlinx.io, MutableStateFlow, KLogger, inline Duration), consider whether the Kotlin example should switch to a JVM create() factory (e.g., TraceFeatureMessageFileWriter.create(path)). This keeps the two examples structurally aligned. See reference/factory-classes.md.
  4. Add @JavaAPI bridge methods if missing. If the Java code needs a bridge that doesn't exist yet (e.g., a builder method on MockExecutorBuilder), add it before writing the Java tab. This may pause the doc work for a source-code change — flag it to the user before proceeding.
  5. Write the Java tab immediately after the Kotlin tab, using the template below.
  6. If renaming Knit files (e.g., hyphenated example-feature-java-01.java → camelCase exampleFeatureJava01.java), delete the old generated files first.
  7. Generate and compile (see Verification at the bottom).
  8. Read the generated .java to confirm correctness. Fix and repeat 7–8 on failure.

Mkdocs / Knit tab structure

Java tabs go immediately after the Kotlin tab. All content inside a tab is indented 4 spaces. <!--- INCLUDE -->, <!--- SUFFIX -->, <!--- KNIT --> are Knit directives (HTML comments — invisible when rendered), not mkdocs syntax.

=== "Kotlin"

    <!--- INCLUDE
    import ...
    -->
    ```kotlin
    // visible code
    ```
    <!--- KNIT example-feature-01.kt -->

=== "Java"

    <!--- INCLUDE
    import ...;
    public class exampleFeatureJava01 {
        public static void main(String[] args) {
    -->
    <!--- SUFFIX
        }
    }
    -->
    ```java
    // visible code
    ```
    <!--- KNIT exampleFeatureJava01.java -->

KNIT naming — capital "Java" matters

docs/knit.code.include has the check <#if !knit.name?contains("Java")>package .... Files with capital "Java" in the name skip the package declaration; lowercase "java" or hyphenated names emit a package line that breaks compilation.

  • ✅ exampleFeatureJava01.java, exampleTestingJava13.java
  • ❌ example-feature-java-01.java, examplefeaturejava01.java

Knit rules

  • INCLUDE + visible code + SUFFIX must concatenate into a valid Java file.
  • Hidden variables in Kotlin INCLUDE (outputPath, input, etc.) must also appear in Java INCLUDE.
  • Visible-code indentation in .md is 4 spaces (tab content). Knit strips that when generating.
  • Always import in INCLUDE; never use FQNs in visible code.
  • Never use file-level annotations (@file:Suppress, @file:OptIn) — scope to specific declarations.

Structural matching (the most important rule)

The Java visible code must match the Kotlin visible code in scope and structure.

  • If Kotlin shows no main(), Java must hide main() in INCLUDE/SUFFIX.
  • If Kotlin shows install(Feature) { ... }, Java must show .install(Feature.Feature, config -> { }).
  • If Kotlin creates a writer before the agent, Java must too.
  • If Kotlin shows agent.run(input), Java must too.

Read both visible blocks side-by-side after writing. They should read as equivalent code in their respective languages.

When Kotlin uses APIs with no Java bridge

Some Kotlin DSLs (graph testing: testGraph, assertSubgraphByName, assertNodes, assertEdges, verifySubgraph, assertReachable) have no @JavaAPI bridges. To check: grep for @JavaAPI in the source file — if absent, treat as Kotlin-only.

When the Kotlin block uses an entirely Kotlin-only API:

  1. Do NOT leave the Java tab empty. Write a compilable Java class with explanatory comments.
  2. The class must have a valid main so it compiles.
  3. Comments explain what the Kotlin DSL does and the recommended Java alternative.
// Graph structure testing (testGraph, assertSubgraphByName, assertEdges,
// verifySubgraph, assertReachable) is available through the Kotlin testing DSL.
//
// In Java, test agent behavior by running and asserting on the result:
//   String result = agent.run("test input");
//   assert "expected".equals(result);

Deep references

Load these only when you need them:

  • reference/interop-tables.md — Kotlin↔Java mapping table, suspend bridges (@JvmName("run"), handleMessage, handleClose), abstract-property rules, key source files to grep for @JavaAPI.
  • reference/factory-classes.md — JVM create() factory pattern, two-overload skeleton, type-conversion cheat sheet, when needed vs not, anti-patterns. Cross-references the split-jvm-nonjvm skill.
  • reference/pitfalls.md — var-vs-field, brace-counting in SUFFIX, is-prefixed property getters, @JvmOverloads requirement, docs classpath limits (no JUnit), legacy /** */ placeholder, MockExecutorBuilder API.

Verification

After each Java block:

./gradlew :docs:knit
./gradlew :docs:compileJava

On failure, read the generated file to diagnose:

cat docs/src/main/kotlin/exampleFeatureJavaNN.java

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.