$npx -y skills add giuseppe-trisciuoglio/developer-kit --skill spring-boot-project-creatorCreates and scaffolds a new Spring Boot project (3.x or 4.x) by downloading from Spring Initializr, generating package structure (DDD or Layered architecture), configuring JPA, SpringDoc OpenAPI, and Docker Compose services (PostgreSQL, Redis, MongoDB). Use when creating a new Ja
| 1 | # Spring Boot Project Creator |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Generates a fully configured Spring Boot project from scratch using the Spring Initializr API. The skill walks the user through selecting project parameters, choosing an architecture style (DDD or Layered), configuring data stores, and setting up Docker Compose for local development. The result is a build-ready project with standardized structure, dependency management, and configuration. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | - Bootstrap a new Spring Boot 3.x or 4.x project with a standard structure. |
| 10 | - Initialize a backend microservice with JPA, SpringDoc OpenAPI, and Docker Compose. |
| 11 | - Scaffold a project following either DDD (Domain-Driven Design) or Layered (Controller/Service/Repository/Model) architecture. |
| 12 | - Set up local development infrastructure with PostgreSQL, Redis, and/or MongoDB via Docker Compose. |
| 13 | - Trigger phrases: **"create spring boot project"**, **"new spring boot app"**, **"bootstrap java project"**, **"scaffold spring boot microservice"**, **"initialize spring boot backend"**, **"generate spring boot project"**. |
| 14 | |
| 15 | ## Prerequisites |
| 16 | |
| 17 | Before starting, ensure the following tools are installed: |
| 18 | |
| 19 | - **Java Development Kit (JDK)**: Version 17+ (Java 21 recommended for Spring Boot 3.x/4.x) |
| 20 | - **Apache Maven**: Build tool (Spring Initializr generates Maven projects by default) |
| 21 | - **Docker** and **Docker Compose**: For running local infrastructure services |
| 22 | - **curl** and **unzip**: For downloading and extracting the project from Spring Initializr |
| 23 | |
| 24 | ## Instructions |
| 25 | |
| 26 | Follow these steps to create a new Spring Boot project. |
| 27 | |
| 28 | ### 1. Gather Project Configuration |
| 29 | |
| 30 | Ask the user for the following project parameters using **AskUserQuestion**. Provide sensible defaults: |
| 31 | |
| 32 | | Parameter | Default | Options | |
| 33 | |-----------|---------|---------| |
| 34 | | **Group ID** | `com.example` | Any valid Java package name | |
| 35 | | **Artifact ID** | `demo` | Kebab-case identifier | |
| 36 | | **Package Name** | Same as Group ID | Valid Java package | |
| 37 | | **Spring Boot Version** | `3.4.5` | `3.4.x`, `4.0.x` (check start.spring.io for latest) | |
| 38 | | **Java Version** | `21` | `17`, `21` | |
| 39 | | **Architecture** | User choice | `DDD` or `Layered` | |
| 40 | | **Docker Services** | User choice | PostgreSQL, Redis, MongoDB (multi-select) | |
| 41 | | **Build Tool** | `maven` | `maven`, `gradle` | |
| 42 | |
| 43 | ### 2. Generate Project with Spring Initializr |
| 44 | |
| 45 | Use `curl` to download the project scaffold from start.spring.io. |
| 46 | |
| 47 | **Base dependencies** (always included): |
| 48 | - `web` — Spring Web MVC |
| 49 | - `validation` — Jakarta Bean Validation |
| 50 | - `data-jpa` — Spring Data JPA |
| 51 | - `testcontainers` — Testcontainers support |
| 52 | |
| 53 | **Conditional dependencies** (based on Docker Services selection): |
| 54 | - PostgreSQL selected → add `postgresql` |
| 55 | - Redis selected → add `data-redis` |
| 56 | - MongoDB selected → add `data-mongodb` |
| 57 | |
| 58 | ```bash |
| 59 | # Example for Spring Boot 3.4.5 with PostgreSQL only |
| 60 | curl -s https://start.spring.io/starter.zip \ |
| 61 | -d type=maven-project \ |
| 62 | -d language=java \ |
| 63 | -d bootVersion=3.4.5 \ |
| 64 | -d groupId=com.example \ |
| 65 | -d artifactId=demo \ |
| 66 | -d packageName=com.example \ |
| 67 | -d javaVersion=21 \ |
| 68 | -d packaging=jar \ |
| 69 | -d dependencies=web,data-jpa,postgresql,validation,testcontainers \ |
| 70 | -o starter.zip |
| 71 | |
| 72 | unzip -o starter.zip -d ./demo |
| 73 | rm starter.zip |
| 74 | cd demo |
| 75 | ``` |
| 76 | |
| 77 | ### 3. Add Additional Dependencies |
| 78 | |
| 79 | Edit `pom.xml` to add SpringDoc OpenAPI and ArchUnit for architectural testing. |
| 80 | |
| 81 | ```xml |
| 82 | <!-- SpringDoc OpenAPI --> |
| 83 | <dependency> |
| 84 | <groupId>org.springdoc</groupId> |
| 85 | <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> |
| 86 | <version>2.8.15</version> |
| 87 | </dependency> |
| 88 | |
| 89 | <!-- ArchUnit for architecture tests --> |
| 90 | <dependency> |
| 91 | <groupId>com.tngtech.archunit</groupId> |
| 92 | <artifactId>archunit-junit5</artifactId> |
| 93 | <version>1.4.1</version> |
| 94 | <scope>test</scope> |
| 95 | </dependency> |
| 96 | ``` |
| 97 | |
| 98 | ### 4. Create Architecture Structure |
| 99 | |
| 100 | Based on the user's choice, create the package structure under `src/main/java/<packagePath>/`. |
| 101 | |
| 102 | #### Option A: Layered Architecture |
| 103 | |
| 104 | ``` |
| 105 | src/main/java/com/example/ |
| 106 | ├── controller/ # REST controllers (@RestController) |
| 107 | ├── service/ # Business logic (@Service) |
| 108 | ├── repository/ # Data access (@Repository, Spring Data interfaces) |
| 109 | ├── model/ # JPA entities (@Entity) |
| 110 | │ └── dto/ # Request/Response DTOs (Java records) |
| 111 | ├── config/ # Configuration classes (@Configuration) |
| 112 | └── exception/ # Custom exceptions and @ControllerAdvice |
| 113 | ``` |
| 114 | |
| 115 | Create placeholder classes for each layer: |
| 116 | |
| 117 | - **config/OpenApiConfig.java** — SpringDoc OpenAPI configuration bean |
| 118 | - ** |