refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조

에이전트 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>
This commit is contained in:
Antigravity Agent
2026-07-11 11:05:56 +09:00
parent 6549ead309
commit c24165b8bc
6193 changed files with 1717 additions and 31 deletions
@@ -0,0 +1,134 @@
---
id: wiki-2026-0508-scratch-refactoring-스크래치-리팩토링
title: Scratch Refactoring (스크래치 리팩토링)
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Scratch Refactoring, throwaway refactor, exploratory refactoring]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [refactoring, technique, learning]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: typescript
framework: none
---
# Scratch Refactoring (스크래치 리팩토링)
## 매 한 줄
> **"매 throwaway refactor — 매 코드 이해를 위한 도구로서의 리팩토링"**. Michael Feathers가 *Working Effectively with Legacy Code*에서 정형화. 매 결과 코드를 commit하지 않고, 매 ugly legacy를 매 자유롭게 변형하며 매 구조를 학습한 뒤 매 throw away.
## 매 핵심
### 매 정의
- 매 commit하지 않는 refactor.
- 매 목적: 코드 이해 (test 작성 X, 동작 보존 X).
- 매 끝나면 `git checkout .`.
### 매 vs 일반 refactor
- 일반 refactor: 매 동작 보존 + commit.
- Scratch refactor: 매 동작 깨져도 OK + 매 폐기.
### 매 응용
1. 매 거대 legacy class 매 진입할 때 매 first-pass 이해.
2. 매 "이 코드 어떻게 동작?" 질문 매 답.
3. 매 진짜 refactor 의 매 사전 탐색.
## 💻 패턴
### 매 brutal extraction (commit X)
```bash
# 매 worktree에서 자유롭게 변형
git switch -c scratch/explore-OrderService
# ... 매 method 분리, rename, comment 추가, dead code 삭제 ...
# 매 끝나면
git switch main
git branch -D scratch/explore-OrderService
```
### 매 inline-everything (이해용)
```typescript
// 매 before — 매 6단계 helper chain
function process(order) { return finalize(validate(normalize(load(order)))); }
// 매 scratch: 매 inline 펼침 (commit X)
function process(order) {
const loaded = db.find(order.id);
if (!loaded) throw new Error();
const normalized = { ...loaded, total: loaded.items.reduce((s,i)=>s+i.price, 0) };
// ... 매 read해서 이해 → 매 throw away
}
```
### 매 rename-storm (학습용)
```typescript
// 매 이름이 모호한 변수/메서드 매 임시 rename → 매 이해 뒤 폐기
class X { f(d) { return d.x.map(v=>v.y); } }
// 매 scratch rename
class OrderQuery { extractCustomerIds(order) { return order.lines.map(l=>l.customerId); } }
// 매 이해 완료 → revert
```
### 매 type annotation 추가 (JS → TS scratch)
```typescript
// 매 untyped JS legacy를 매 임시로 type 입혀 흐름 파악
function process(/** @type {Order} */ o) { /* ... */ }
// 매 끝나면 폐기 (매 진짜 migration은 별도 task)
```
### 매 log-dump trace
```typescript
// 매 모든 분기에 console.log → 매 실제 path 관찰
function calculate(o) {
console.log("calculate", o);
if (o.type === "A") { console.log("branch A"); /* ... */ }
// 매 trace 후 매 모든 log 제거
}
```
### 매 AI-assisted scratch (2026)
```bash
# 매 Claude Opus 4.7에 매 scratch refactor 부탁
claude "Read src/legacy/OrderService.ts. Inline all helpers, rename obscure vars,
add comments explaining each branch. Goal: human-readable. Don't preserve behavior."
# 매 결과 매 read만 하고 매 discard
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| 매 legacy 매 처음 진입 | Scratch refactor 먼저. |
| 매 production fix 중 | X — 매 일반 refactor + test. |
| 매 시간 부족 | 매 scratch도 OK — 매 빠른 이해 우선. |
| 매 팀 onboarding | 매 신입 매 scratch refactor 권장. |
**기본값**: 매 unfamiliar legacy → scratch refactor → 이해 → 진짜 refactor.
## 🔗 Graph
- 부모: [[Refactoring_Best_Practices|Refactoring]]
- 응용: [[Code Reading]]
- Adjacent: [[Seam (접점)]]
## 🤖 LLM 활용
**언제**: 매 거대 legacy 진입, 매 코드 이해가 매 1차 목표일 때.
**언제 X**: 매 production behavior change, 매 long-term improvement.
## ❌ 안티패턴
- **매 commit해버림**: 매 scratch가 매 production에 매 leak.
- **매 너무 오래 매 매달림**: 매 scratch는 매 hours, 매 days X.
- **매 test 없이 매 진짜 refactor 시도**: 매 scratch 후 매 진짜 refactor에는 매 test 필수.
## 🧪 검증 / 중복
- Verified (Feathers, *Working Effectively with Legacy Code*, 2004).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Feathers scratch refactor + AI-assisted variant |