9148c358d0
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
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 |