|
| 1 | +--- |
| 2 | +name: coding |
| 3 | +description: Implement and review Java code changes for Micronaut framework repositories using maintainer standards. Use when users ask to add or refactor Java code, fix framework bugs, evolve internal APIs, or prepare committer-ready changes with tests and verification. |
| 4 | +license: Apache-2.0 |
| 5 | +compatibility: Micronaut framework repositories in micronaut-projects generated from micronaut-project-template |
| 6 | +metadata: |
| 7 | + author: Álvaro Sánchez-Mariscal |
| 8 | + version: "1.0.0" |
| 9 | +--- |
| 10 | + |
| 11 | +# Coding (Micronaut Committer) |
| 12 | + |
| 13 | +Use this skill for maintainer-facing Java implementation work in Micronaut repositories. Do not default to end-user application shortcuts. |
| 14 | + |
| 15 | +## Goal |
| 16 | + |
| 17 | +Deliver minimal, source-backed Java changes that preserve framework quality: binary compatibility, null-safety, reflection-free behavior, and full Gradle verification (`check`, `docs`, and compatibility checks when API-facing). |
| 18 | + |
| 19 | +## Trigger Examples |
| 20 | + |
| 21 | +Should trigger: |
| 22 | + |
| 23 | +- "Implement this Micronaut Java feature in `src/main/java` and keep API compatibility." |
| 24 | +- "Refactor this module internals and mark non-public APIs correctly." |
| 25 | +- "Fix failing framework tests and prepare committer-ready validation output." |
| 26 | +- "Add configuration support using Micronaut conventions, not app-level shortcuts." |
| 27 | + |
| 28 | +Should not trigger: |
| 29 | + |
| 30 | +- "Explain Micronaut basics to a beginner." |
| 31 | +- "Create an end-user sample app from scratch." |
| 32 | +- "Only edit release notes/changelog text." |
| 33 | + |
| 34 | +## Procedure |
| 35 | + |
| 36 | +1. Establish scope and API impact. |
| 37 | +2. Implement Java code with Micronaut maintainer conventions. |
| 38 | +3. Enforce API boundaries and binary compatibility. |
| 39 | +4. Keep Gradle/build changes aligned with repository conventions. |
| 40 | +5. Verify with maintainer-grade checks before completion. |
| 41 | + |
| 42 | +### 1) Establish scope and API impact |
| 43 | + |
| 44 | +- Identify affected modules and whether any change is public API or internal-only. |
| 45 | +- Inspect existing package patterns before editing (imports, nullability style, tests, naming). |
| 46 | +- For API-facing edits, plan compatibility checks up front (`japiCmp`). |
| 47 | +- Keep change surface minimal; avoid opportunistic refactors unless required. |
| 48 | + |
| 49 | +### 2) Implement Java with Micronaut maintainer conventions |
| 50 | + |
| 51 | +- Prefer modern Java idioms where they improve clarity (records, sealed types, pattern matching, `var` for local inference), but only when supported by the repository toolchain/target level. |
| 52 | +- Do not use fully qualified class names unless import conflicts force it. |
| 53 | +- Follow the repository's established nullability annotations/defaults; use JSpecify and package-level `@NullMarked` only when that convention already exists in the module. |
| 54 | +- Avoid reflection-oriented implementations in framework code paths; prefer Micronaut compile-time/introspection mechanisms. |
| 55 | +- Use `jakarta.inject` APIs for DI, not `javax.inject`. |
| 56 | +- Prefer constructor injection and immutable state over field injection. |
| 57 | +- For configuration models, prefer `@ConfigurationProperties` over scattered `@Value` usage. |
| 58 | + |
| 59 | +### 3) Enforce API boundaries and compatibility |
| 60 | + |
| 61 | +- Treat all public-facing changes through a Semantic Versioning lens (`https://semver.org/`) before implementation. |
| 62 | +- Classify impact explicitly: patch for backward-compatible fixes, minor for backward-compatible feature additions, major for breaking API/behavioral changes. |
| 63 | +- Keep public API binary compatible unless a major-version change explicitly allows breaks. |
| 64 | +- Prefer non-breaking API evolution first: deprecate existing methods and add replacement variants/overloads instead of deleting methods or changing signatures in place. |
| 65 | +- When using the deprecate-and-add path, keep deprecated APIs functional, point to replacements in Javadoc, and schedule removals only for the next major version. |
| 66 | +- If breaking public-facing changes are explicitly allowed, document them in the user guide under `src/main/docs/guide` with migration notes, and update `toc.yml` when adding new guide sections. |
| 67 | +- Mark non-user-facing APIs with `@io.micronaut.core.annotation.Internal`. |
| 68 | +- Keep visibility as narrow as possible for non-public internals. |
| 69 | +- When deprecating API, provide migration-friendly Javadoc and avoid silent behavioral breaks. |
| 70 | + |
| 71 | +### 4) Keep Gradle/build changes convention-aligned |
| 72 | + |
| 73 | +- Use `./gradlew` for all Gradle execution. |
| 74 | +- Use Gradle version catalogs (`gradle/libs.versions.toml`) instead of hard-coded dependency versions. |
| 75 | +- Use appropriate scopes (`api`, `implementation`, `compileOnly`, `runtimeOnly`) based on API exposure. |
| 76 | +- Do not add custom build logic directly in module build files when it belongs in convention plugins. |
| 77 | +- When uncertain about module paths, use `./gradlew projects` and prefer canonical `micronaut-*` project names. |
| 78 | + |
| 79 | +### 5) Verify before completion |
| 80 | + |
| 81 | +First confirm canonical verification tasks from `CONTRIBUTING.md` and existing CI/build files, then run the repository equivalents from root. |
| 82 | + |
| 83 | +Common sequence in Micronaut repositories: |
| 84 | + |
| 85 | +```bash |
| 86 | +./gradlew :<module>:compileTestJava |
| 87 | +# If module includes Groovy tests: |
| 88 | +./gradlew :<module>:compileTestGroovy |
| 89 | +./gradlew :<module>:test --tests 'pkg.ClassTest' |
| 90 | +./gradlew :<module>:test |
| 91 | +# If repository documents cM alias/checkstyle aggregate task: |
| 92 | +./gradlew -q cM |
| 93 | +./gradlew -q spotlessCheck |
| 94 | +./gradlew check |
| 95 | +./gradlew docs |
| 96 | +``` |
| 97 | + |
| 98 | +For API-affecting changes, also run if configured in the repository: |
| 99 | + |
| 100 | +```bash |
| 101 | +./gradlew japiCmp |
| 102 | +``` |
| 103 | + |
| 104 | +If Spotless fails, run `./gradlew -q spotlessApply` and re-run `spotlessCheck`. |
| 105 | + |
| 106 | +## Guardrails |
| 107 | + |
| 108 | +- Do not introduce `javax.inject` usage. |
| 109 | +- Do not hard-code dependency versions in module build files. |
| 110 | +- Do not break public APIs without explicit major-version intent. |
| 111 | +- Do not skip tests or docs verification for code changes. |
| 112 | +- Do not use reflection as a convenience in framework internals. |
| 113 | + |
| 114 | +## Delivery Contract |
| 115 | + |
| 116 | +When finishing implementation work, report: |
| 117 | + |
| 118 | +1. Exactly which files changed and why. |
| 119 | +2. Whether the change is API-facing or internal-only. |
| 120 | +3. Semantic Versioning impact classification (patch/minor/major) for any public-facing change. |
| 121 | +4. For deprecate-and-add API evolution, which elements were deprecated and which replacement variants were introduced. |
| 122 | +5. For breaking public-facing changes, which user guide files were updated and what migration guidance was added. |
| 123 | +6. Commands executed for verification and outcomes. |
| 124 | +7. Any follow-up risk (for example compatibility implications). |
| 125 | + |
| 126 | +## Validation Checklist |
| 127 | + |
| 128 | +- [ ] `SKILL.md` frontmatter is valid and `name` matches directory (`coding`). |
| 129 | +- [ ] Guidance is maintainer-focused (not end-user app guidance). |
| 130 | +- [ ] Java conventions include nullability, DI, and reflection-free guidance. |
| 131 | +- [ ] API boundary guidance includes `@Internal` and compatibility checks. |
| 132 | +- [ ] For public API evolution without breaking changes, deprecations include clear replacement guidance and functional compatibility is preserved. |
| 133 | +- [ ] If breaking changes are allowed, user guide docs in `src/main/docs/guide` are updated with migration notes. |
| 134 | +- [ ] Verification includes tests, style checks, `check`, and `docs`. |
| 135 | + |
| 136 | +## References |
| 137 | + |
| 138 | +- `CONTRIBUTING.md` |
| 139 | +- `MAINTAINING.md` |
| 140 | +- `.agents/skills/gradle/SKILL.md` |
| 141 | +- `.agents/skills/docs/SKILL.md` |
| 142 | +- `.agents/skills/skill-creator/references/spec-checklist.md` |
0 commit comments