c24165b8bc
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5.2 KiB
5.2 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-red-green-refactoring | Red-Green Refactoring | 10_Wiki/Topics | verified | self |
|
none | A | 0.92 | applied |
|
2026-05-10 | pending |
|
Red-Green Refactoring
매 한 줄
"매 Red → Green → Refactor — 매 minute scale 의 design loop". Kent Beck 의 Test-Driven Development: By Example (2002) 에서 codified 된 micro-cycle. 매 failing test (Red) → minimum code 로 pass (Green) → smell 제거 (Refactor) 의 30초~3분 사이클이 매 production-grade XP/TDD 의 atomic unit 이다.
매 핵심
매 세 phase
- Red: 매 새 behavior 를 실패하는 test 로 명시. Compile error 도 Red 로 인정 (Beck).
- Green: 매 fastest path 로 pass — fake it, obvious implementation, triangulation 중 택 1. 매 ugly OK.
- Refactor: 매 두 hat 의 second hat — duplicate 제거, naming, 추상화. 매 test 는 계속 green.
매 cycle 시간
- 매 한 cycle = 30초 ~ 3분 권장. 30분 넘으면 step too big.
- 매 commit 단위 = green 직후 또는 refactor 직후. Red 상태 commit 의 X.
매 응용
- Outside-in (London school): mock 기반 acceptance test → unit drill-down.
- Inside-out (Detroit/Chicago school): domain core 부터 state-based test.
- AI pair: 매 Claude Code 가 test 작성, 매 human 이 implementation 확인 — 또는 reverse.
💻 패턴
Vitest 의 매 cycle 예시
// === RED ===
import { describe, it, expect } from 'vitest';
import { Money } from './money';
describe('Money', () => {
it('multiplies amount by scalar', () => {
expect(new Money(5, 'USD').times(2)).toEqual(new Money(10, 'USD'));
});
});
// → fails: Money is not defined
Green: 매 fastest path
// money.ts — Beck 의 "fake it" 단계
export class Money {
constructor(public amount: number, public currency: string) {}
times(n: number): Money {
return new Money(this.amount * n, this.currency);
}
// equals 는 Vitest 의 toEqual 가 structural 로 처리
}
Refactor: 매 immutable + value semantics
export class Money {
private constructor(
public readonly amount: number,
public readonly currency: string,
) {}
static of(amount: number, currency: string): Money {
if (!Number.isFinite(amount)) throw new RangeError('amount NaN');
return new Money(amount, currency);
}
times(n: number): Money {
return Money.of(this.amount * n, this.currency);
}
}
Triangulation pattern
// 매 두 번째 test 가 generalization 을 강제
it('multiplies by 3', () => {
expect(Money.of(5, 'USD').times(3)).toEqual(Money.of(15, 'USD'));
});
// → 매 hardcoded `return new Money(10, ...)` 는 더 이상 통하지 않음
Tidy First (Beck 2023)
// 매 refactor 와 behavior change 를 별도 commit 으로 분리
// 1. tidy first: rename, extract — pure structural
// 2. behavior: 새 test + impl
// 매 PR review 의 noise 감소
TCR (test && commit || revert) — Beck 2018
# 매 hardcore variant: green 이면 commit, red 이면 코드 폐기
vitest run && git commit -am wip || git checkout -- .
AI-assisted RGR (Claude Code 2026)
// 1. human: write Red test
// 2. claude: minimal Green implementation
// 3. human: review + suggest refactor
// 4. claude: apply Extract Function, etc.
// 매 test 의 contract 는 human 이 own
매 결정 기준
| 상황 | Approach |
|---|---|
| 새 feature, 도메인 명확 | Inside-out RGR |
| 외부 contract 우선 | Outside-in (mock-driven) |
| Legacy, 매 test 없음 | 매 Characterization test 후 RGR |
| Spike / prototype | RGR skip — 매 throw away 후 RGR 로 재작성 |
| Refactor only | Red 없이 Refactor hat — 매 test 가 이미 green |
기본값: Inside-out RGR + Tidy First commit 분리.
🔗 Graph
- 부모: TDD · Refactoring_Best_Practices
- 변형: BDD
- 응용: Pair Programming · Mob Programming
- Adjacent: Rule of Three (3의 법칙) · Code Smell · XP
🤖 LLM 활용
언제: 매 well-bounded pure function, 매 algorithm, 매 domain logic. Claude Code 의 Green phase delegation 효율 높음. 언제 X: 매 UI snapshot, 매 distributed system race, 매 exploration spike — RGR overhead 가 가치 초과.
❌ 안티패턴
- Test after: 매 implementation 후 test 추가 — 매 design feedback loss, 매 false-confidence test.
- Commit at Red: 매 broken main, 매 bisect 불가.
- Skipping Refactor: 매 green-and-go — 매 debt 누적.
- Big Red: 매 30분 짜리 test → step too big, 매 walking skeleton 으로 분해.
- Refactor with failing test: 매 두 hat 의 violation — 매 behavior change 와 cleanup 혼합.
🧪 검증 / 중복
- Verified: Beck TDD: By Example (2002), Tidy First (2023). Martin Fowler Refactoring 2e (2018) Ch.1.
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — full RGR cycle, patterns, Tidy First/TCR variants |