Skip to content

AI 에이전트 하네스 구축#170

Open
Seol-JY wants to merge 1 commit intodevelopfrom
chore/agent-harness-setup
Open

AI 에이전트 하네스 구축#170
Seol-JY wants to merge 1 commit intodevelopfrom
chore/agent-harness-setup

Conversation

@Seol-JY
Copy link
Copy Markdown
Member

@Seol-JY Seol-JY commented Mar 16, 2026

✨ 작업 내용

AI 코딩 에이전트(Claude Code, Cursor 등)가 프로젝트 컨벤션을 정확히 따르도록 **에이전트 하네스(Agent Harness)**를 구축했습니다.
2026 하네스 엔지니어링 베스트 프랙티스에 따라 Progressive Disclosure, 도구 무관 Source of Truth, 결정적 제어(Hooks), 전문화 서브에이전트를 적용합니다.

1️⃣ AGENTS.md — 도구 무관 Source of Truth (신규)

  • 프로젝트 루트에 AGENTS.md (~50줄) 배치
  • Claude Code뿐 아니라 Cursor, Copilot 등 모든 AI 도구가 참조할 수 있는 범용 프로젝트 규칙
  • 아키텍처, 핵심 규칙, 빌드/테스트 명령어, Git 컨벤션을 간결하게 정리

2️⃣ CLAUDE.md 포인터 축소 (변경)

  • 기존 1173줄의 상세 가이드 → 5줄 포인터로 축소 (99.6% 컨텍스트 절감)
  • 새 대화 시작 시 자동 로드되는 컨텍스트가 최소화되어 에이전트 응답 품질 향상
  • 상세 내용은 필요할 때만 .agent-docs/에서 참조 (Progressive Disclosure)

3️⃣ .agent-docs/ — Progressive Disclosure 문서 분리 (신규)

  • .agent-docs/conventions.md: 기존 CLAUDE.md의 전체 개발 컨벤션 이동
    • routine 도메인 실제 코드와 대조하여 불일치 수정 (Builder final 파라미터, @TransactionalEventListener, 이벤트 클래스 occurredAt 제거 등)
  • .agent-docs/test-conventions.md: 실제 테스트 코드에서 패턴 추출하여 신규 작성
    • 베이스 클래스 상세 (UseCaseTest/ServiceTest/RepositoryTest 차이점)
    • 동시성 테스트 패턴 (CountDownLatch + ExecutorService)
    • 트랜잭션 관리 (Propagation.NEVER, TransactionTemplate)
    • Fixture 인프라 (TestFixtureBuilder, RoutineWithAuditInfo)
    • Assertion 패턴 (assertSoftly, assertThatCode, Stream 기반 검증)

4️⃣ PostToolUse Hook — 즉각 피드백 (신규)

  • .claude/settings.json에 PostToolUse Hook 정의
  • Java 파일 수정(Write/Edit) 직후 checkstyleMain 자동 실행 (~5초)
  • 기존 Husky pre-commit은 커밋 시점(파일 N개 수정 후 한 번)이지만, 이 Hook은 매 수정마다 즉각 피드백하여 오류 누적 방지

5️⃣ 서브에이전트 — 전문화된 역할 분리 (신규)

  • .claude/agents/security-reviewer.md: Spring 특화 보안 리뷰 체크리스트 (SQL Injection, @PreAuthorize 누락, IDOR, Mass Assignment, 민감 정보 로깅, 소프트 삭제 누수)
  • .claude/agents/test-writer.md: 프로젝트 테스트 컨벤션 준수 테스트 코드 작성 전용 에이전트


기존 하네스 요소와의 관계

이번 추가 요소는 기존에 이미 구축된 하네스들과 상호보완적으로 동작합니다:

계층 도구 실행 시점 역할
에이전트 수정 직후 PostToolUse Hook (신규) 매 Java 파일 수정 checkstyle 즉각 피드백
커밋 시점 Husky pre-commit (기존) git commit checkstyleMain + editorconfigCheck + editorconfigFormat
커밋 시점 Husky commit-msg (기존) git commit commitlint (feat/fix/docs/style/refactor/test/chore, 스코프 없음, 100자)
빌드 시점 Checkstyle (기존) ./gradlew build Naver rules, maxWarnings=0, ignoreFailures=false
빌드 시점 EditorConfig (기존) ./gradlew build Tab 인덴트, LF, 120자 제한
테스트 시점 ArchUnit 11개 테스트 (기존) ./gradlew test 레이어 의존 방향, 클래스 네이밍, 어노테이션 필수, DistributedLock UseCase 전용 등
CI 시점 GitHub Actions (기존) PR → main/develop gradlew build + JaCoCo 커버리지 (전체 30%, 변경 파일 50%)
문서 AGENTS.md (신규) 에이전트 컨텍스트 로드 도구 무관 프로젝트 규칙
문서 .agent-docs/ (신규) 필요 시 참조 상세 개발/테스트 컨벤션
전문 에이전트 security-reviewer, test-writer (신규) 호출 시 보안 리뷰, 테스트 작성
[에이전트 코드 작성]
  ├─ PostToolUse Hook → checkstyleMain 즉각 피드백 (신규)
  ├─ git commit → Husky pre-commit + commit-msg (기존)
  └─ PR/Push → GitHub Actions CI → gradlew build + ArchUnit + JaCoCo (기존)

✅ 리뷰 요구사항(선택)

  • PostToolUse Hook의 checkstyleMain 실행이 개발 흐름에 부담이 되지 않는지 확인 부탁드립니다 (~5초 소요)
  • .agent-docs/conventions.md에서 routine 도메인 대비 수정한 3건(Builder final, TransactionalEventListener, occurredAt)이 적절한지 검토 부탁드립니다

AGENTS.md를 프로젝트 루트 source of truth로 배치하고, CLAUDE.md를 포인터로 축소.
상세 컨벤션은 .agent-docs/로 분리하여 Progressive Disclosure 적용.
PostToolUse Hook으로 Java 파일 수정 시 checkstyle 즉각 피드백 설정.
security-reviewer, test-writer 서브에이전트 추가.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 16, 2026

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'auto_resolve_threads', 'spring_specific'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

프로젝트 아키텍처 및 코딩 컨벤션을 정의하는 포괄적인 문서화 작업입니다. 도메인 개발 가이드, 테스트 컨벤션, AI 에이전트 지침, 그리고 프로젝트 설정 파일을 추가하여 개발 표준을 체계화했습니다.

Changes

Cohort / File(s) Summary
Convention Guides
.agent-docs/conventions.md, .agent-docs/test-conventions.md
도메인 개발, 엔티티, 저장소, 서비스, 유스케이스, 표현 계층, DTO, 성능 최적화, 도메인 이벤트, 코딩 컨벤션과 테스트 구조(Base 테스트 클래스, Fixture, BDD 패턴, 트랜잭션 관리)에 대한 상세 가이드 추가.
Agent Documentation
.claude/agents/security-reviewer.md, .claude/agents/test-writer.md
Spring Security 검수 체크리스트와 SQL 주입, 인증/인가, 민감 정보 로깅 등을 다루는 Security Reviewer 에이전트와 테스트 작성 규칙 및 워크플로우를 정의하는 Test Writer 에이전트 추가.
Core Documentation & Configuration
.claude/CLAUDE.md, .claude/settings.json, AGENTS.md
CLAUDE.md를 최소화하고 AGENTS.md 프로젝트 개요 추가, settings.json에서 Gradle checkstyle PostToolUse 훅 설정.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 문서의 정원을 가꾸며,
규칙의 씨앗을 심고,
컨벤션의 햇빛이 자라나,
일관된 코드의 열매 맺고,
개발자들의 길을 밝히네! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed PR 제목은 AI 에이전트 하네스 구축이라는 변경사항의 핵심을 명확하게 요약하고 있으며, chore 태입은 문서 및 설정 추가에 적절합니다.
Description check ✅ Passed PR 설명이 지정된 템플릿과 다른 형식(마크다운 테이블, 상세한 아키텍처 설명)으로 작성되었지만, 내용은 매우 상세하고 변경사항을 충분히 설명합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/agent-harness-setup
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

📝 Jacoco Test Coverage

Overall Project 51.24% 🍏

There is no coverage information present for the Files changed

@github-actions
Copy link
Copy Markdown

🧪 Test Results

412 tests   408 ✅  24s ⏱️
124 suites    4 💤
124 files      0 ❌

Results for commit 97b29eb.

@Seol-JY Seol-JY changed the title chore: AI 에이전트 하네스 구축 AI 에이전트 하네스 구축 Mar 16, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.agent-docs/conventions.md (1)

7-31: 코드 블록에 언어 식별자를 추가하세요.

정적 분석 도구(markdownlint)에서 경고가 발생했습니다. 디렉토리 구조를 나타내는 코드 블록에 언어 식별자가 없습니다. text 또는 plaintext를 추가하면 됩니다.

📝 제안된 수정
-```
+```text
 domain/{도메인명}/
 ├── common/              # 도메인 내 공통 유틸리티
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agent-docs/conventions.md around lines 7 - 31, The markdown code block
showing the directory tree (starting with "domain/{도메인명}/") lacks a language
identifier causing markdownlint warnings; fix it by adding a language tag (e.g.,
`text` or `plaintext`) immediately after the opening triple backticks (change
``` to ```text) in the code block in .agent-docs/conventions.md so the block is
treated as plain text by linters.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.agent-docs/test-conventions.md:
- Around line 249-265: 설명 문구가 잘못되어 있어 `UseCaseTest`/`ServiceTest` 베이스 클래스에
`@Transactional`이 없어도 "테스트별로 트랜잭션이 롤백된다"라고 되어 있는데, 이 부분을 수정해서 기본 동작을 "베이스 클래스에
`@Transactional`이 없으므로 개별 테스트에 `@Transactional`을 선언해야 롤백이 적용된다"로 바꾸고,
`@Transactional(propagation = Propagation.NEVER)` 예제 설명은 "롤백이 아닌 실제 DB 커밋 상태를
검증하려면 테스트에 명시적으로 `@Transactional`을 사용하지 않거나 `Propagation.NEVER`를 선언"하는 식으로 명확히
바꿔 `UseCaseTest`/`ServiceTest`와 `@Transactional`/`Propagation.NEVER` 기호를 언급해 문서를
업데이트하세요.

---

Nitpick comments:
In @.agent-docs/conventions.md:
- Around line 7-31: The markdown code block showing the directory tree (starting
with "domain/{도메인명}/") lacks a language identifier causing markdownlint
warnings; fix it by adding a language tag (e.g., `text` or `plaintext`)
immediately after the opening triple backticks (change ``` to ```text) in the
code block in .agent-docs/conventions.md so the block is treated as plain text
by linters.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1f71454d-7816-4628-9320-e3d604cd4bf9

📥 Commits

Reviewing files that changed from the base of the PR and between 9f24240 and 97b29eb.

📒 Files selected for processing (7)
  • .agent-docs/conventions.md
  • .agent-docs/test-conventions.md
  • .claude/CLAUDE.md
  • .claude/agents/security-reviewer.md
  • .claude/agents/test-writer.md
  • .claude/settings.json
  • AGENTS.md

Comment on lines +249 to +265
## 트랜잭션 관리

### 기본 동작

`UseCaseTest`/`ServiceTest` 상속 시 테스트별로 트랜잭션이 롤백됩니다.

### `Propagation.NEVER` — 실제 DB 상태 검증

트랜잭션 롤백 없이 실제 커밋된 DB 상태를 확인해야 할 때 사용:

```java
@Test
@Transactional(propagation = Propagation.NEVER)
void 기존_기록이_존재하는_경우에_완료_상태_변경이_성공한다() {
// 실제 DB 커밋 후 상태 검증
}
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify `@Transactional` annotation in base test classes

echo "=== Checking UseCaseTest for `@Transactional` ==="
rg -n "@Transactional" src/test/java/im/toduck/UseCaseTest.java || echo "No `@Transactional` found"

echo ""
echo "=== Checking ServiceTest for `@Transactional` ==="
rg -n "@Transactional" src/test/java/im/toduck/ServiceTest.java || echo "No `@Transactional` found"

echo ""
echo "=== Full class annotations in UseCaseTest ==="
head -30 src/test/java/im/toduck/UseCaseTest.java

echo ""
echo "=== Full class annotations in ServiceTest ==="
head -35 src/test/java/im/toduck/ServiceTest.java

Repository: toduck-App/toduck-backend

Length of output: 2761


기본 트랜잭션 롤백 동작 설명을 수정하세요.

UseCaseTest/ServiceTest 베이스 클래스에 @Transactional 어노테이션이 없어서 "테스트별로 트랜잭션이 롤백된다"는 설명이 실제 동작과 맞지 않습니다. 개별 테스트에서 명시적으로 @Transactional을 선언해야 롤백이 적용됩니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agent-docs/test-conventions.md around lines 249 - 265, 설명 문구가 잘못되어 있어
`UseCaseTest`/`ServiceTest` 베이스 클래스에 `@Transactional`이 없어도 "테스트별로 트랜잭션이 롤백된다"라고
되어 있는데, 이 부분을 수정해서 기본 동작을 "베이스 클래스에 `@Transactional`이 없으므로 개별 테스트에
`@Transactional`을 선언해야 롤백이 적용된다"로 바꾸고, `@Transactional(propagation =
Propagation.NEVER)` 예제 설명은 "롤백이 아닌 실제 DB 커밋 상태를 검증하려면 테스트에 명시적으로
`@Transactional`을 사용하지 않거나 `Propagation.NEVER`를 선언"하는 식으로 명확히 바꿔
`UseCaseTest`/`ServiceTest`와 `@Transactional`/`Propagation.NEVER` 기호를 언급해 문서를
업데이트하세요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant