Skill: Configuration
When to load it: When adding any new configurable value or environment-specific
behaviour to a feature.
What This Skill Does
Produces type-safe, validated configuration properties bound from application.yml.
Enforces fail-fast validation at startup and keeps configurable values out of Java source.
Rules
- All configurable values go in
application.yml. Never hardcoded in Java source. - Group related properties under a
@ConfigurationPropertiesclass. Do not use@Value
for more than one related property.
- Validate at startup with
@Validated. Fail fast — a misconfiguration discovered at
runtime is worse than a failed startup.
- Provide sensible defaults for non-critical values. Do not require configuration for
things with an obvious default.
- Document each property in
application.ymlwith a comment.
Pattern
@ConfigurationProperties(prefix = "[feature]")
@Validated
public record [Feature]Properties(
@NotBlank String [requiredProperty],
@Min(1) @Max(100) int [boundedProperty],
@Positive double [positiveProperty]
) {}
# application.yml
[feature]:
# [What this property controls. Required.]
[required-property]: [value]
# [What this property controls. Range: 1–100. Default: 10.]
[bounded-property]: 10
# [What this property controls. Must be positive.]
[positive-property]: 0.7
Register in Spring Boot:
@Configuration
@EnableConfigurationProperties([Feature]Properties.class)
public class [Feature]Config {}
Design Constraints
- Do not hardcode configurable values in Java source — always
application.yml - Do not use
@Valuewhen two or more related properties exist — use@ConfigurationProperties - Do not skip
@Validated— startup validation is not optional - Do not provide a default for required values — required means no default