Files
2nd/10_Wiki/Topics/Architecture/보이스카우트 규칙 (Boy Scout Rule).md
T
2026-05-10 22:08:15 +09:00

5.2 KiB
Raw Blame History

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-보이스카우트-규칙-boy-scout-rule 보이스카우트 규칙 (Boy Scout Rule) 10_Wiki/Topics verified self
Boy Scout Rule
Campsite Rule
Leave It Better
점진적 개선
none A 0.9 applied
clean-code
refactoring
software-craftsmanship
principles
2026-05-10 pending
language framework
language-agnostic refactoring

보이스카우트 규칙 (Boy Scout Rule)

매 한 줄

"매 check in 한 코드 의 check out 한 코드 보다 cleaner 의 leave.". Robert C. Martin (Clean Code, 2008) 의 popularize — 매 boy scout motto "leave the campsite cleaner than you found it" 의 software 의 apply. 2026 modern context 는 매 LLM-assisted refactor (Claude, Cursor) 의 cost 의 dramatic 의 lower — 매 rule 의 practice 의 ever-easier.

매 핵심

매 핵심 아이디어

  • 매 touch 한 file 에 매 small improvement.
  • 매 variable rename · dead code 의 delete · 매 magic number 의 const · 매 function 의 split.
  • 매 commit 의 scope 의 keep small — 매 unrelated cleanup 의 separate commit.

매 왜

  • Entropy 와 fight: 매 code 의 자연 의 decay — 매 active counter-force 의 필요.
  • Compound interest: 매 small fix × N developer × M commit = 매 substantial improvement.
  • Cognitive load 의 lower: 매 next reader 의 효과.

매 응용

  1. 매 PR 의 작은 cleanup 의 같이 include (그러나 main change 의 separate commit).
  2. 매 LLM 의 통한 매 mechanical refactor 의 batch.
  3. 매 lint/format 의 pre-commit 의 enforce — 매 baseline 의 raise.

💻 패턴

매 commit 의 separate (git)

# Main change
git add src/feature.ts
git commit -m "feat: add export to PDF"

# Boy scout cleanup
git add src/utils.ts  # 매 touched file 의 cleanup
git commit -m "refactor: extract date formatter, rename ambiguous vars"

매 magic number 의 const 의 promote

// Before
if (user.failedAttempts > 5) lockout(user);

// After
const MAX_FAILED_LOGIN_ATTEMPTS = 5;
if (user.failedAttempts > MAX_FAILED_LOGIN_ATTEMPTS) lockout(user);

Dead code 의 delete (with tooling)

# TypeScript — ts-prune
npx ts-prune | grep -v "(used in module)" 

# Python — vulture
vulture src/ --min-confidence 80

매 long function 의 extract

# Before — 매 80-line function
def process_order(order):
    # validate
    if not order.items: raise ...
    if order.total < 0: raise ...
    # apply discount
    ...
    # charge
    ...

# After
def process_order(order):
    _validate(order)
    discounted = _apply_discount(order)
    return _charge(discounted)

매 LLM-assisted batch refactor

# Cursor / Claude Code — 매 file 의 select 후
# "매 magic number 의 const 의 extract, 매 var 의 const 의 promote, 매 docstring 의 add"

Pre-commit hook (ratchet)

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.5.0
    hooks: [{ id: ruff, args: [--fix] }]
  - repo: local
    hooks:
      - id: complexity-check
        entry: radon cc -n C src/
        language: system

매 TODO/FIXME 의 ticket 의 promote

# 매 grep 의 FIXME 의 collect → 매 issue tracker 의 file
rg -n "FIXME|HACK|XXX" --json | jq -r '.data.lines.text'

매 결정 기준

상황 Approach
매 typo · rename · dead code 매 fix on sight
매 architectural smell Ticket 의 file — 매 separate effort
매 PR 매 already large Cleanup 의 follow-up PR 의 defer
매 hot path performance Benchmark first — 매 cleanup 의 not change behavior 의 verify
매 legacy code 의 untested Test 의 add first → 매 then refactor

기본값: 매 touch 했으면 매 5분 cleanup 의 add — 매 separate commit, 매 PR description 의 mention.

🔗 Graph

🤖 LLM 활용

언제: 매 file 의 read 한 후 매 "이 file 의 small improvement 5개 의 suggest" — 매 LLM 의 human eye 보다 빠르게 spot. 언제 X: 매 critical path · 매 high-stakes module — 매 unintended behavior change 의 risk.

안티패턴

  • Big bang refactor: 매 PR 매 unrelated cleanup × 50 — 매 review 의 impossible.
  • Drive-by style change: 매 team convention 의 무시 한 personal preference.
  • Cleanup commit 매 mix: 매 main change 와 cleanup 의 same commit — 매 git blame 의 noise.
  • Test 의 break: 매 cleanup 의 behavior 의 change — 매 test 의 guard.
  • Scope creep: 매 5분 cleanup 매 2시간 rabbit hole — stop · ticket · commit.

🧪 검증 / 중복

  • Verified (Robert C. Martin Clean Code ch1; Kent Beck Tidy First? 2024).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — patterns, LLM-assisted refactor, anti-patterns