Home › All rules › Community › Springboot Copilot Instructions

Springboot Copilot Instructions

Guidelines for building Spring Boot base applications

GitHub CopilotSpring Boot (Java)Community (MIT)

How to use

Save this as .github/instructions/springboot.instructions.md in your project, commit it, and GitHub Copilot will apply it to matching files. Review it first: community files can be opinionated or out of date.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.github/instructions/springboot.instructions.mdDownload  
---
description: 'Guidelines for building Spring Boot base applications'
applyTo: '**/*.java, **/*.kt'
---

# Spring Boot Development

## General Instructions

- Make only high confidence suggestions when reviewing code changes.
- Write code with good maintainability practices, including comments on why certain design decisions were made.
- Handle edge cases and write clear exception handling.
- For libraries or external dependencies, mention their usage and purpose in comments.

## Spring Boot Instructions

### Dependency Injection

- Use constructor injection for all required dependencies.
- Declare dependency fields as `private final`.

### Configuration

- Use YAML files (`application.yml`) for externalized configuration.
- Environment Profiles: Use Spring profiles for different environments (dev, test, prod)
- Configuration Properties: Use @ConfigurationProperties for type-safe configuration binding
- Secrets Management: Externalize secrets using environment variables or secret management systems

### Code Organization

- Package Structure: Organize by feature/domain rather than by layer
- Separation of Concerns: Keep controllers thin, services focused, and repositories simple
- Utility Classes: Make utility classes final with private constructors

### Service Layer

- Place business logic in `@Service`-annotated classes.
- Services should be stateless and testable.
- Inject repositories via the constructor.
- Service method signatures should use domain IDs or DTOs, not expose repository entities directly unless necessary.

### Logging

- Use SLF4J for all logging (`private static final Logger logger = LoggerFactory.getLogger(MyClass.class);`).
- Do not use concrete implementations (Logback, Log4j2) or `System.out.println()` directly.
- Use parameterized logging: `logger.info("User {} logged in", userId);`.

### Security & Input Handling

- Use parameterized queries | Always use Spring Data JPA or `NamedParameterJdbcTemplate` to prevent SQL injection.
- Validate request bodies and parameters using JSR-380 (`@NotNull`, `@Size`, etc.) annotations and `BindingResult`

## Build and Verification

- After adding or modifying code, verify the project continues to build successfully.
- If the project uses Maven, run `mvn clean package`.
- If the project uses Gradle, run `./gradlew build` (or `gradlew.bat build` on Windows).
- Ensure all tests pass as part of the build.

## Useful Commands

| Gradle Command            | Maven Command                     | Description                                   |
|:--------------------------|:----------------------------------|:----------------------------------------------|
| `./gradlew bootRun`       |`./mvnw spring-boot:run`           | Run the application.                          |
| `./gradlew build`         |`./mvnw package`                   | Build the application.                        |
| `./gradlew test`          |`./mvnw test`                      | Run tests.                                    |
| `./gradlew bootJar`       |`./mvnw spring-boot:repackage`     | Package the application as a JAR.             |
| `./gradlew bootBuildImage`|`./mvnw spring-boot:build-image`   | Package the application as a container image. |

More: Spring Boot (Java) rules · all community rules

Related rules

Spring Boot 4 CLAUDE.md

CLAUDE.md for Spring Boot 4 (Spring Framework 7) services on Java 25: null-safety, HTTP clients, testing, and migrations.

Claude Code (CLAUDE.md)Spring Boot (Java)

Spring Boot 3 Copilot instructions

Copilot instructions for Spring Boot 3.x services on Java 21 with records, JPA, validation, and Testcontainers.

GitHub CopilotSpring Boot (Java)

Java General Purpose Cursor Rules

Cursor rules for Java General Purpose.

CursorSpring Boot (Java)Community (CC0)

Java Springboot Jpa Cursor Rules

Cursor rules for Java development with Springboot and JPA integration.

CursorSpring Boot (Java)Community (CC0)

JavaScript Chrome Apis Cursor Rules

Cursor rules for JavaScript development with Chrome APIs integration.

CursorSpring Boot (Java)Community (CC0)

JavaScript TypeScript Code Quality Cursor Rules

Cursor rules for JavaScript and TypeScript development with code quality integration.

CursorSpring Boot (Java)Community (CC0)

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.