@el-j/magic-helix-plugins 4.0.0-beta.1 → 4.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/architecture/codeowners.md +123 -0
  2. package/dist/architecture/monorepo.md +146 -0
  3. package/dist/architecture/nx.md +122 -0
  4. package/dist/architecture/turborepo.md +114 -0
  5. package/dist/ci/github-actions.md +268 -0
  6. package/dist/ci/gitlab-ci.md +330 -0
  7. package/dist/containers/docker-multistage.md +120 -0
  8. package/dist/containers/kubernetes-deploy.md +210 -0
  9. package/dist/cpp/index.cjs +79 -0
  10. package/dist/cpp/index.mjs +209 -0
  11. package/dist/csharp/index.cjs +2 -2
  12. package/dist/csharp/{index.js → index.mjs} +17 -11
  13. package/dist/csharp/templates/framework-aspnetcore.md +205 -0
  14. package/dist/csharp/templates/framework-blazor.md +271 -0
  15. package/dist/csharp/templates/lang-csharp.md +162 -0
  16. package/dist/devops/docker-compose.md +111 -0
  17. package/dist/devops/docker-dockerfile.md +94 -0
  18. package/dist/devops/github-actions.md +160 -0
  19. package/dist/devops/gitlab-ci.md +210 -0
  20. package/dist/generic/lang-typescript.md +57 -0
  21. package/dist/generic/state-redux.md +21 -0
  22. package/dist/generic/state-rxjs.md +6 -0
  23. package/dist/generic/style-mui.md +23 -0
  24. package/dist/generic/style-tailwind.md +76 -0
  25. package/dist/generic/test-cypress.md +21 -0
  26. package/dist/generic/test-jest.md +20 -0
  27. package/dist/generic/test-playwright.md +21 -0
  28. package/dist/generic/test-vitest.md +131 -0
  29. package/dist/go/index.cjs +3 -3
  30. package/dist/go/{index.js → index.mjs} +18 -15
  31. package/dist/go/templates/lang-go.md +571 -0
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.mjs +24 -0
  34. package/dist/java/index.cjs +2 -2
  35. package/dist/java/{index.js → index.mjs} +25 -19
  36. package/dist/java/templates/build-gradle.md +102 -0
  37. package/dist/java/templates/build-maven.md +86 -0
  38. package/dist/java/templates/framework-spring-boot.md +179 -0
  39. package/dist/java/templates/lang-java.md +78 -0
  40. package/dist/java/templates/lang-kotlin.md +88 -0
  41. package/dist/meta/magic-helix-meta.md +213 -0
  42. package/dist/meta/meta-debug.md +459 -0
  43. package/dist/meta/meta-implement.md +450 -0
  44. package/dist/meta/meta-roadmap.md +265 -0
  45. package/dist/nodejs/templates/angular-core.md +19 -0
  46. package/dist/nodejs/templates/lang-typescript.md +57 -0
  47. package/dist/nodejs/templates/nestjs-core.md +7 -0
  48. package/dist/nodejs/templates/react-core.md +677 -0
  49. package/dist/nodejs/templates/react-zustand.md +7 -0
  50. package/dist/nodejs/templates/state-redux.md +21 -0
  51. package/dist/nodejs/templates/state-rxjs.md +6 -0
  52. package/dist/nodejs/templates/style-primevue.md +6 -0
  53. package/dist/nodejs/templates/style-quasar.md +22 -0
  54. package/dist/nodejs/templates/style-tailwind.md +76 -0
  55. package/dist/nodejs/templates/test-cypress.md +21 -0
  56. package/dist/nodejs/templates/test-jest.md +20 -0
  57. package/dist/nodejs/templates/test-playwright.md +21 -0
  58. package/dist/nodejs/templates/test-vitest.md +131 -0
  59. package/dist/nodejs/templates/vue-core.md +108 -0
  60. package/dist/nodejs/templates/vue-pinia.md +5 -0
  61. package/dist/patterns/architecture/clean-architecture.md +469 -0
  62. package/dist/patterns/architecture/dependency-injection.md +517 -0
  63. package/dist/patterns/architecture/domain-driven-design.md +621 -0
  64. package/dist/patterns/architecture/layered-architecture.md +382 -0
  65. package/dist/patterns/architecture/repository-pattern.md +408 -0
  66. package/dist/patterns/domain-expertise/nextjs-rules.md +115 -0
  67. package/dist/patterns/domain-expertise/react-patterns.md +181 -0
  68. package/dist/patterns/domain-expertise/server-components.md +212 -0
  69. package/dist/patterns/domain-expertise/shadcn-ui.md +52 -0
  70. package/dist/patterns/domain-expertise/tailwind-patterns.md +52 -0
  71. package/dist/patterns/environment/container-awareness.md +17 -0
  72. package/dist/patterns/environment/ide-features.md +17 -0
  73. package/dist/patterns/environment/os-commands.md +17 -0
  74. package/dist/patterns/organization/heading-hierarchy.md +103 -0
  75. package/dist/patterns/organization/sequential-workflows.md +102 -0
  76. package/dist/patterns/organization/xml-rule-groups.md +64 -0
  77. package/dist/patterns/reasoning/agent-loop.md +151 -0
  78. package/dist/patterns/reasoning/confirmation-gates.md +141 -0
  79. package/dist/patterns/reasoning/dependency-analysis.md +132 -0
  80. package/dist/patterns/reasoning/one-tool-per-iteration.md +152 -0
  81. package/dist/patterns/reasoning/preview-before-action.md +194 -0
  82. package/dist/patterns/reasoning/reflection-checkpoints.md +166 -0
  83. package/dist/patterns/reasoning/result-verification.md +157 -0
  84. package/dist/patterns/reasoning/subtask-breakdown.md +131 -0
  85. package/dist/patterns/reasoning/thinking-tags.md +100 -0
  86. package/dist/patterns/role-definition/capability-declarations.md +72 -0
  87. package/dist/patterns/role-definition/expert-identity.md +45 -0
  88. package/dist/patterns/role-definition/scope-boundaries.md +61 -0
  89. package/dist/patterns/safety/code-safety-rules.md +17 -0
  90. package/dist/patterns/safety/credential-handling.md +17 -0
  91. package/dist/patterns/safety/destructive-warnings.md +17 -0
  92. package/dist/patterns/safety/refusal-messages.md +17 -0
  93. package/dist/patterns/tone/adaptive-tone.md +17 -0
  94. package/dist/patterns/tone/concise-communication.md +17 -0
  95. package/dist/patterns/tone/forbidden-phrases.md +17 -0
  96. package/dist/patterns/tool-guidelines/function-schemas.md +143 -0
  97. package/dist/patterns/tool-guidelines/parameter-examples.md +137 -0
  98. package/dist/patterns/tool-guidelines/usage-policies.md +105 -0
  99. package/dist/php/index.cjs +2 -2
  100. package/dist/php/{index.js → index.mjs} +12 -6
  101. package/dist/php/templates/framework-laravel.md +112 -0
  102. package/dist/php/templates/lang-php.md +94 -0
  103. package/dist/python/index.cjs +4 -4
  104. package/dist/python/{index.js → index.mjs} +10 -7
  105. package/dist/python/templates/lang-python.md +508 -0
  106. package/dist/ruby/index.cjs +2 -2
  107. package/dist/ruby/{index.js → index.mjs} +16 -10
  108. package/dist/ruby/templates/framework-rails.md +309 -0
  109. package/dist/ruby/templates/framework-sinatra.md +227 -0
  110. package/dist/ruby/templates/lang-ruby.md +216 -0
  111. package/dist/rust/index.cjs +3 -3
  112. package/dist/rust/{index.js → index.mjs} +24 -18
  113. package/dist/rust/templates/lang-rust.md +89 -0
  114. package/dist/swift/index.cjs +32 -0
  115. package/dist/swift/index.mjs +112 -0
  116. package/dist/swift/templates/framework-vapor.md +352 -0
  117. package/dist/swift/templates/lang-swift.md +291 -0
  118. package/package.json +31 -21
  119. package/dist/index.js +0 -20
  120. /package/dist/nodejs/{index.js → index.mjs} +0 -0
@@ -1,5 +1,6 @@
1
- import { B as o } from "../BasePlugin-6wv0hYJ9.js";
2
- class d extends o {
1
+ import * as o from "node:path";
2
+ import { B as l } from "../BasePlugin-6wv0hYJ9.js";
3
+ class m extends l {
3
4
  constructor() {
4
5
  super(...arguments), this.name = "java", this.displayName = "Java", this.version = "3.0.0", this.priority = 75;
5
6
  }
@@ -11,7 +12,14 @@ class d extends o {
11
12
  {
12
13
  name: "java-core",
13
14
  tags: ["java"],
14
- content: `# Java Development Guidelines
15
+ content: () => this.loadTemplateFromFile(
16
+ o.join(__dirname, "templates/lang-java.md")
17
+ ).then((e) => e || this.getJavaFallbackTemplate())
18
+ }
19
+ ];
20
+ }
21
+ getJavaFallbackTemplate() {
22
+ return `# Java Development Guidelines
15
23
 
16
24
  This project uses Java.
17
25
 
@@ -33,9 +41,7 @@ This project uses Java.
33
41
  ## Testing
34
42
  - Write JUnit tests
35
43
  - Use Mockito for mocking
36
- - Aim for good test coverage`
37
- }
38
- ];
44
+ - Aim for good test coverage`;
39
45
  }
40
46
  getDependencyTagMap() {
41
47
  return {
@@ -54,38 +60,38 @@ This project uses Java.
54
60
  manifestFile: "pom.xml",
55
61
  projectPath: e
56
62
  };
57
- const n = t.match(/<artifactId>([^<]+)<\/artifactId>/), s = t.match(/<description>([^<]+)<\/description>/), a = {}, i = t.matchAll(
63
+ const i = t.match(/<artifactId>([^<]+)<\/artifactId>/), n = t.match(/<description>([^<]+)<\/description>/), s = {}, a = t.matchAll(
58
64
  /<dependency>[\s\S]*?<groupId>([^<]+)<\/groupId>[\s\S]*?<artifactId>([^<]+)<\/artifactId>[\s\S]*?(?:<version>([^<]+)<\/version>)?/g
59
65
  );
60
- for (const r of i)
61
- a[`${r[1]}:${r[2]}`] = r[3] || "*";
66
+ for (const r of a)
67
+ s[`${r[1]}:${r[2]}`] = r[3] || "*";
62
68
  return {
63
69
  language: "Java",
64
- name: n?.[1] || this.getProjectName(e),
65
- description: s?.[1],
66
- dependencies: a,
70
+ name: i?.[1] || this.getProjectName(e),
71
+ description: n?.[1],
72
+ dependencies: s,
67
73
  manifestFile: "pom.xml",
68
74
  projectPath: e
69
75
  };
70
76
  }
71
77
  detectGradle(e) {
72
- const t = this.fileExists(e, "build.gradle") ? "build.gradle" : "build.gradle.kts", n = this.readFile(e, t), s = {};
73
- if (n) {
74
- const a = n.matchAll(
78
+ const t = this.fileExists(e, "build.gradle") ? "build.gradle" : "build.gradle.kts", i = this.readFile(e, t), n = {};
79
+ if (i) {
80
+ const s = i.matchAll(
75
81
  /(?:implementation|api|testImplementation)\s*['"]([^:'"]+):([^:'"]+):?([^'"]*)['"]/g
76
82
  );
77
- for (const i of a)
78
- s[`${i[1]}:${i[2]}`] = i[3] || "*";
83
+ for (const a of s)
84
+ n[`${a[1]}:${a[2]}`] = a[3] || "*";
79
85
  }
80
86
  return {
81
87
  language: "Java/Kotlin",
82
88
  name: this.getProjectName(e),
83
- dependencies: s,
89
+ dependencies: n,
84
90
  manifestFile: t,
85
91
  projectPath: e
86
92
  };
87
93
  }
88
94
  }
89
95
  export {
90
- d as JavaPlugin
96
+ m as JavaPlugin
91
97
  };
@@ -0,0 +1,102 @@
1
+ # Gradle Build Tool Instructions
2
+
3
+ ## Project Structure
4
+ ```
5
+ project/
6
+ ├── build.gradle or build.gradle.kts
7
+ ├── settings.gradle or settings.gradle.kts
8
+ ├── gradle/
9
+ │ └── wrapper/
10
+ ├── src/
11
+ │ ├── main/
12
+ │ │ ├── java/ or kotlin/
13
+ │ │ └── resources/
14
+ │ └── test/
15
+ │ ├── java/ or kotlin/
16
+ │ └── resources/
17
+ └── build/
18
+ ```
19
+
20
+ ## Common Commands
21
+
22
+ ```bash
23
+ # Build lifecycle
24
+ ./gradlew clean # Clean build artifacts
25
+ ./gradlew build # Full build with tests
26
+ ./gradlew assemble # Build without tests
27
+ ./gradlew test # Run tests
28
+ ./gradlew check # Run all checks
29
+
30
+ # Spring Boot
31
+ ./gradlew bootRun # Run application
32
+ ./gradlew bootJar # Create executable JAR
33
+
34
+ # Dependency management
35
+ ./gradlew dependencies # Show dependency tree
36
+ ./gradlew dependencyUpdates # Check for updates (with plugin)
37
+ ```
38
+
39
+ ## Docker Optimization
40
+
41
+ ### Layer Caching Strategy
42
+ ```dockerfile
43
+ # Download dependencies in separate layer
44
+ FROM gradle:8.5-jdk17 AS deps
45
+ WORKDIR /app
46
+ COPY build.gradle.kts settings.gradle.kts ./
47
+ COPY gradle ./gradle
48
+ RUN gradle dependencies --no-daemon
49
+
50
+ # Build application
51
+ FROM deps AS build
52
+ COPY src ./src
53
+ RUN gradle bootJar --no-daemon
54
+
55
+ # Runtime
56
+ FROM eclipse-temurin:17-jre-alpine
57
+ COPY --from=build /app/build/libs/*.jar app.jar
58
+ CMD ["java", "-jar", "app.jar"]
59
+ ```
60
+
61
+ ## Kotlin DSL (build.gradle.kts)
62
+
63
+ ```kotlin
64
+ plugins {
65
+ id("org.springframework.boot") version "3.2.0"
66
+ id("io.spring.dependency-management") version "1.1.4"
67
+ kotlin("jvm") version "1.9.20"
68
+ kotlin("plugin.spring") version "1.9.20"
69
+ }
70
+
71
+ repositories {
72
+ mavenCentral()
73
+ }
74
+
75
+ dependencies {
76
+ implementation("org.springframework.boot:spring-boot-starter-web")
77
+ implementation("org.jetbrains.kotlin:kotlin-reflect")
78
+ testImplementation("org.springframework.boot:spring-boot-starter-test")
79
+ }
80
+
81
+ tasks.withType<Test> {
82
+ useJUnitPlatform()
83
+ }
84
+ ```
85
+
86
+ ## Best Practices
87
+
88
+ - Use Gradle Wrapper (./gradlew) for consistent builds
89
+ - Prefer Kotlin DSL for type safety
90
+ - Use version catalogs for dependency management
91
+ - Leverage buildSrc for shared build logic
92
+ - Enable Gradle daemon for faster builds
93
+ - Use `--parallel` for multi-module projects
94
+
95
+ ## Performance Tips
96
+
97
+ ```kotlin
98
+ // gradle.properties
99
+ org.gradle.caching=true
100
+ org.gradle.parallel=true
101
+ org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m
102
+ ```
@@ -0,0 +1,86 @@
1
+ # Maven Build Tool Instructions
2
+
3
+ ## Project Structure
4
+ ```
5
+ project/
6
+ ├── pom.xml
7
+ ├── src/
8
+ │ ├── main/
9
+ │ │ ├── java/
10
+ │ │ └── resources/
11
+ │ └── test/
12
+ │ ├── java/
13
+ │ └── resources/
14
+ └── target/
15
+ ```
16
+
17
+ ## Common Commands
18
+
19
+ ```bash
20
+ # Build lifecycle
21
+ ./mvnw clean # Clean build artifacts
22
+ ./mvnw compile # Compile source code
23
+ ./mvnw test # Run tests
24
+ ./mvnw package # Package as JAR/WAR
25
+ ./mvnw install # Install to local repo
26
+ ./mvnw deploy # Deploy to remote repo
27
+
28
+ # Spring Boot
29
+ ./mvnw spring-boot:run # Run application
30
+
31
+ # Dependency management
32
+ ./mvnw dependency:tree # Show dependency tree
33
+ ./mvnw dependency:resolve # Download dependencies
34
+ ./mvnw versions:display-dependency-updates # Check for updates
35
+ ```
36
+
37
+ ## Docker Optimization
38
+
39
+ ### Layer Caching Strategy
40
+ ```dockerfile
41
+ # Download dependencies in separate layer
42
+ FROM maven:3.9-eclipse-temurin-17 AS deps
43
+ WORKDIR /app
44
+ COPY pom.xml .
45
+ RUN mvn dependency:go-offline
46
+
47
+ # Build application
48
+ FROM deps AS build
49
+ COPY src ./src
50
+ RUN mvn package -DskipTests
51
+
52
+ # Runtime
53
+ FROM eclipse-temurin:17-jre-alpine
54
+ COPY --from=build /app/target/*.jar app.jar
55
+ CMD ["java", "-jar", "app.jar"]
56
+ ```
57
+
58
+ ## Best Practices
59
+
60
+ - Use Maven Wrapper (./mvnw) for consistent builds
61
+ - Define dependency versions in `<dependencyManagement>`
62
+ - Use Spring Boot BOM for version management
63
+ - Leverage profiles for different environments
64
+ - Keep plugins up to date
65
+
66
+ ## POM Configuration Tips
67
+
68
+ ```xml
69
+ <properties>
70
+ <java.version>17</java.version>
71
+ <maven.compiler.source>17</maven.compiler.source>
72
+ <maven.compiler.target>17</maven.compiler.target>
73
+ </properties>
74
+
75
+ <dependencyManagement>
76
+ <dependencies>
77
+ <dependency>
78
+ <groupId>org.springframework.boot</groupId>
79
+ <artifactId>spring-boot-dependencies</artifactId>
80
+ <version>${spring-boot.version}</version>
81
+ <type>pom</type>
82
+ <scope>import</scope>
83
+ </dependency>
84
+ </dependencies>
85
+ </dependencyManagement>
86
+ ```
@@ -0,0 +1,179 @@
1
+ # Spring Boot Framework Instructions
2
+
3
+ ## Architecture Patterns
4
+
5
+ ### Layered Architecture
6
+ ```
7
+ Controller → Service → Repository → Database
8
+ ```
9
+
10
+ ### Controller Layer
11
+ ```java
12
+ @RestController
13
+ @RequestMapping("/api/users")
14
+ public class UserController {
15
+
16
+ private final UserService userService;
17
+
18
+ public UserController(UserService userService) {
19
+ this.userService = userService;
20
+ }
21
+
22
+ @GetMapping("/{id}")
23
+ public ResponseEntity<User> getUser(@PathVariable Long id) {
24
+ return userService.findById(id)
25
+ .map(ResponseEntity::ok)
26
+ .orElse(ResponseEntity.notFound().build());
27
+ }
28
+ }
29
+ ```
30
+
31
+ ### Service Layer
32
+ ```java
33
+ @Service
34
+ public class UserService {
35
+
36
+ private final UserRepository repository;
37
+
38
+ @Transactional
39
+ public User createUser(User user) {
40
+ return repository.save(user);
41
+ }
42
+ }
43
+ ```
44
+
45
+ ### Repository Layer
46
+ ```java
47
+ @Repository
48
+ public interface UserRepository extends JpaRepository<User, Long> {
49
+ Optional<User> findByEmail(String email);
50
+ }
51
+ ```
52
+
53
+ ## Configuration
54
+
55
+ ### application.yml
56
+ ```yaml
57
+ spring:
58
+ datasource:
59
+ url: jdbc:postgresql://localhost:5432/mydb
60
+ username: ${DB_USER}
61
+ password: ${DB_PASSWORD}
62
+ jpa:
63
+ hibernate:
64
+ ddl-auto: validate
65
+ properties:
66
+ hibernate:
67
+ dialect: org.hibernate.dialect.PostgreSQLDialect
68
+
69
+ server:
70
+ port: 8080
71
+ ```
72
+
73
+ ## Docker Best Practices
74
+
75
+ ### Optimized Dockerfile
76
+ ```dockerfile
77
+ FROM eclipse-temurin:17-jre-alpine
78
+ WORKDIR /app
79
+
80
+ # Add non-root user
81
+ RUN addgroup -S spring && adduser -S spring -G spring
82
+ USER spring:spring
83
+
84
+ COPY --chown=spring:spring target/*.jar app.jar
85
+
86
+ # JVM optimization for containers
87
+ ENV JAVA_OPTS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0"
88
+
89
+ EXPOSE 8080
90
+ ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]
91
+ ```
92
+
93
+ ### Health Checks
94
+ ```yaml
95
+ # docker-compose.yml
96
+ services:
97
+ app:
98
+ healthcheck:
99
+ test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
100
+ interval: 30s
101
+ timeout: 3s
102
+ retries: 3
103
+ ```
104
+
105
+ ## Production Readiness
106
+
107
+ ### Actuator Endpoints
108
+ ```xml
109
+ <dependency>
110
+ <groupId>org.springframework.boot</groupId>
111
+ <artifactId>spring-boot-starter-actuator</artifactId>
112
+ </dependency>
113
+ ```
114
+
115
+ ### Security
116
+ ```java
117
+ @Configuration
118
+ @EnableWebSecurity
119
+ public class SecurityConfig {
120
+
121
+ @Bean
122
+ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
123
+ http
124
+ .authorizeHttpRequests(auth -> auth
125
+ .requestMatchers("/actuator/health").permitAll()
126
+ .anyRequest().authenticated()
127
+ )
128
+ .oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt);
129
+ return http.build();
130
+ }
131
+ }
132
+ ```
133
+
134
+ ## Testing
135
+
136
+ ### Integration Tests
137
+ ```java
138
+ @SpringBootTest
139
+ @AutoConfigureMockMvc
140
+ class UserControllerIntegrationTest {
141
+
142
+ @Autowired
143
+ private MockMvc mockMvc;
144
+
145
+ @Test
146
+ void shouldGetUser() throws Exception {
147
+ mockMvc.perform(get("/api/users/1"))
148
+ .andExpect(status().isOk())
149
+ .andExpect(jsonPath("$.name").value("John"));
150
+ }
151
+ }
152
+ ```
153
+
154
+ ### Test Containers
155
+ ```java
156
+ @Testcontainers
157
+ @SpringBootTest
158
+ class RepositoryIntegrationTest {
159
+
160
+ @Container
161
+ static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:15-alpine");
162
+
163
+ @DynamicPropertySource
164
+ static void configureProperties(DynamicPropertyRegistry registry) {
165
+ registry.add("spring.datasource.url", postgres::getJdbcUrl);
166
+ registry.add("spring.datasource.username", postgres::getUsername);
167
+ registry.add("spring.datasource.password", postgres::getPassword);
168
+ }
169
+ }
170
+ ```
171
+
172
+ ## Performance
173
+
174
+ - Use connection pooling (HikariCP is default)
175
+ - Enable HTTP/2
176
+ - Use caching (@Cacheable, @CacheEvict)
177
+ - Implement pagination for large datasets
178
+ - Use async processing with @Async where appropriate
179
+ - Monitor with Micrometer metrics
@@ -0,0 +1,78 @@
1
+ # Java/Kotlin Language Instructions
2
+
3
+ ## Project Type
4
+ - Language: Java/Kotlin
5
+ - Build Tool: {Maven|Gradle}
6
+ - Framework: {Spring Boot|Micronaut|Quarkus|None}
7
+
8
+ ## Build Commands
9
+
10
+ ### Maven
11
+ ```bash
12
+ ./mvnw clean install # Build project
13
+ ./mvnw test # Run tests
14
+ ./mvnw spring-boot:run # Run Spring Boot app
15
+ ```
16
+
17
+ ### Gradle
18
+ ```bash
19
+ ./gradlew build # Build project
20
+ ./gradlew test # Run tests
21
+ ./gradlew bootRun # Run Spring Boot app
22
+ ```
23
+
24
+ ## Code Conventions
25
+
26
+ ### Java
27
+ - Follow Java naming conventions (PascalCase for classes, camelCase for methods)
28
+ - Use meaningful variable names
29
+ - Prefer immutability where possible
30
+ - Use Optional for nullable values
31
+ - Handle exceptions appropriately
32
+
33
+ ### Kotlin
34
+ - Use data classes for DTOs
35
+ - Leverage null safety features
36
+ - Use extension functions appropriately
37
+ - Prefer immutability (val over var)
38
+ - Use scope functions (let, apply, run, with)
39
+
40
+ ## Docker Optimization
41
+
42
+ ### Multi-stage Dockerfile Example (Maven)
43
+ ```dockerfile
44
+ FROM maven:3.9-eclipse-temurin-17 AS build
45
+ WORKDIR /app
46
+ COPY pom.xml .
47
+ RUN mvn dependency:go-offline
48
+ COPY src ./src
49
+ RUN mvn clean package -DskipTests
50
+
51
+ FROM eclipse-temurin:17-jre-alpine
52
+ WORKDIR /app
53
+ COPY --from=build /app/target/*.jar app.jar
54
+ EXPOSE 8080
55
+ ENTRYPOINT ["java", "-jar", "app.jar"]
56
+ ```
57
+
58
+ ### JVM Tuning for Containers
59
+ ```bash
60
+ # Use container-aware JVM flags
61
+ java -XX:+UseContainerSupport \
62
+ -XX:MaxRAMPercentage=75.0 \
63
+ -XX:InitialRAMPercentage=50.0 \
64
+ -jar app.jar
65
+ ```
66
+
67
+ ## Testing
68
+
69
+ - Use JUnit 5 for unit tests
70
+ - Use Mockito for mocking
71
+ - Use Testcontainers for integration tests
72
+ - Maintain test coverage >80%
73
+
74
+ ## Dependencies
75
+
76
+ - Keep dependencies up to date
77
+ - Use dependency management (Maven BOM, Gradle platform)
78
+ - Scan for vulnerabilities regularly
@@ -0,0 +1,88 @@
1
+ # Kotlin Specific Instructions
2
+
3
+ ## Language Features
4
+
5
+ ### Null Safety
6
+ ```kotlin
7
+ // Use nullable types explicitly
8
+ val name: String? = null
9
+ val length = name?.length ?: 0
10
+
11
+ // Safe calls
12
+ user?.address?.city
13
+ ```
14
+
15
+ ### Data Classes
16
+ ```kotlin
17
+ data class User(
18
+ val id: Long,
19
+ val name: String,
20
+ val email: String
21
+ )
22
+ ```
23
+
24
+ ### Extension Functions
25
+ ```kotlin
26
+ fun String.toSnakeCase(): String =
27
+ this.replace(Regex("([a-z])([A-Z])"), "$1_$2").lowercase()
28
+ ```
29
+
30
+ ### Coroutines (Async)
31
+ ```kotlin
32
+ suspend fun fetchData(): Data {
33
+ return withContext(Dispatchers.IO) {
34
+ // IO operation
35
+ }
36
+ }
37
+ ```
38
+
39
+ ## Spring Boot with Kotlin
40
+
41
+ ### Controller Example
42
+ ```kotlin
43
+ @RestController
44
+ @RequestMapping("/api/users")
45
+ class UserController(private val userService: UserService) {
46
+
47
+ @GetMapping("/{id}")
48
+ fun getUser(@PathVariable id: Long): User {
49
+ return userService.findById(id)
50
+ }
51
+ }
52
+ ```
53
+
54
+ ### Service with Coroutines
55
+ ```kotlin
56
+ @Service
57
+ class UserService(private val repository: UserRepository) {
58
+
59
+ suspend fun findAllAsync(): List<User> =
60
+ withContext(Dispatchers.IO) {
61
+ repository.findAll()
62
+ }
63
+ }
64
+ ```
65
+
66
+ ## Best Practices
67
+
68
+ - Use `val` over `var` for immutability
69
+ - Leverage sealed classes for state management
70
+ - Use `when` expressions instead of multiple `if-else`
71
+ - Apply scope functions appropriately (let, run, apply, also, with)
72
+ - Use destructuring for data classes
73
+ - Prefer sequences for large collections
74
+
75
+ ## Build Configuration
76
+
77
+ ### build.gradle.kts
78
+ ```kotlin
79
+ plugins {
80
+ kotlin("jvm") version "1.9.20"
81
+ kotlin("plugin.spring") version "1.9.20"
82
+ }
83
+
84
+ dependencies {
85
+ implementation("org.jetbrains.kotlin:kotlin-stdlib")
86
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
87
+ }
88
+ ```