Amazon Q Rules for Spring Boot + Java

Enterprise Java with Spring Boot and JPA

JavaSpring BootJPAEnterprise
.amazonq/rules
# Role
You are an expert Java developer building enterprise applications with Spring Boot.

# Tech Stack
- Java 21+
- Spring Boot 3
- Spring Data JPA
- Spring Security
- Maven/Gradle

# Code Conventions
- Use Spring Boot auto-configuration wherever possible.
- Follow layered architecture: controller → service → repository.
- Use Spring Data JPA repositories for data access.
- Use DTOs for API request/response — never expose entities directly.
- Use `@RestController` for REST APIs with proper HTTP methods.
- Use Spring Security for authentication and authorization.
- Use constructor injection (not field injection with `@Autowired`).
- Use `@Transactional` for service methods that modify data.
- Write unit tests with JUnit 5 and Mockito.

# Code Style Preferences
- Use TypeScript strict mode. Define types for all variables, parameters, and return values.
- Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it.
- Use `const` by default. Only use `let` when reassignment is needed. Never use `var`.
- Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors.
- Use early returns (guard clauses) to reduce nesting and improve readability.
- Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations.
- Keep functions small and focused. Each function should do one thing. Aim for under 50 lines.

# What to Avoid
- Do not expose JPA entities in API responses.
- Do not use field injection — use constructor injection.
- Do not catch exceptions silently.
- Do not hardcode configuration — use `application.properties` or `application.yml`.

About Amazon Q Rules for Spring Boot + Java

The .amazonq/rules file helps Amazon Q understand your Spring Boot + Java project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for Spring Boot.

This preset includes rules for:

  • Use Spring Boot auto-configuration wherever possible.
  • Follow layered architecture: controller → service → repository.
  • Use Spring Data JPA repositories for data access.
  • Use DTOs for API request/response — never expose entities directly.
  • Use `@RestController` for REST APIs with proper HTTP methods.

How to use this file

  1. Click Copy or Download above.
  2. Place the .amazonq/rules file in your project's root directory.
  3. Amazon Q will automatically detect and apply these rules.

Get Spring Boot + Java Rules for Other IDEs

Other Amazon Q Presets