agentleFS
KaratussKaratuss/bstack/skills/spring-core/SKILL.md

spring-core

Skill0 starsChanged 7 months agoMITView on GitHub

Spring Boot 3.x Bean 생명주기·자동구성·프로파일·관용 패턴. 설정 구조화·업그레이드 이슈 시 사용.

The file

Files
SKILL.md

/spring-core — Spring Boot 관용 패턴 스킬

Spring Boot 3.x의 Bean 생명주기, 자동구성, 프로파일, 관용 패턴을 다룬다.

When to use

  • Spring Bean 설정, 생명주기 이슈
  • @Configuration, @Conditional, 자동구성 문제
  • 프로파일(@Profile) 활용 방법
  • 공통 설정 (CORS, 직렬화, 예외 처리) 구조화
  • Spring Boot 3.x 업그레이드 이슈

Spring Boot 3.x 핵심 패턴

생성자 주입 (필수)

// 권장
@Service
@RequiredArgsConstructor
public class OrderService {
    private final OrderRepository orderRepository;
    private final PaymentGateway paymentGateway;
}

// 금지: @Autowired 필드 주입

예외 처리

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(BusinessException.class)
    public ResponseEntity<ErrorResponse> handleBusiness(BusinessException e) {
        return ResponseEntity
            .status(e.getStatus())
            .body(ErrorResponse.of(e.getCode(), e.getMessage()));
    }
}

환경별 설정 분리

application.yml         # 공통
application-local.yml   # 로컬 개발
application-test.yml    # 테스트 (TestContainers 등)
application-prod.yml    # 운영 (민감 정보는 환경변수)

자동구성 커스터마이징

@AutoConfiguration
@ConditionalOnProperty(name = "feature.x.enabled", havingValue = "true")
public class FeatureXAutoConfiguration {
    // ...
}

Actuator / 헬스체크

  • /actuator/health 항상 활성화
  • 운영 환경: management.endpoints.web.exposure.include=health,info,metrics
  • 커스텀 헬스: HealthIndicator 구현

자주 발생하는 문제

증상원인해결
NoSuchBeanDefinitionException컴포넌트 스캔 범위 밖@ComponentScan 경로 확인
순환 의존성 오류설계 문제레이어 분리, 이벤트 기반으로 전환
프로파일 미적용spring.profiles.active 미설정application.yml default profile 확인
LazyInitializationException트랜잭션 외부에서 Lazy 로딩/persistence 스킬로 전환

출력 형식

  1. 현재 코드의 anti-pattern 명시
  2. 권장 패턴으로 수정된 코드 제시
  3. 이유 한 줄 설명

References

  • docs/STYLE_GUIDE.md — 원칙 (Karpathy 4 + 동료 협업 + 정량)
  • docs/RED_FLAGS.md — 안티패턴
  • docs/LAYER_RULES.md — 레이어 규칙

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.