Files
2nd/10_Wiki/Topics/Domain_Programming/From_Other/Program Comprehension Strategies.md
T
Antigravity Agent c24165b8bc 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>
2026-07-11 11:05:56 +09:00

5.9 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-program-comprehension-strategies Program Comprehension Strategies 10_Wiki/Topics verified self
Code Reading
Code Comprehension
Mental Models of Code
none A 0.9 applied
software-engineering
cognition
code-review
onboarding
2026-05-10 pending
language framework
multi cognitive-software-engineering

Program Comprehension Strategies

매 한 줄

"매 90% of programming is reading code, not writing it.". 매 Brooks (1983), Pennington (1987), Soloway (1986) 의 cognitive software engineering 연구에서 출발한 매 분야 — 매 code → mental model 변환의 strategies. 매 2026 LLM 시대에는 매 Cursor/Claude Code 의 contextual indexing 이 매 human comprehension 을 augment.

매 핵심

매 3대 strategy

  • Top-down (Brooks): 매 hypothesis 형성 → code 로 verify. 매 domain expert 가 사용.
  • Bottom-up (Pennington): 매 statement → control-flow → data-flow → program model. 매 novice 가 사용.
  • Opportunistic (mixed): 매 expert programmer 의 실제 행동 — top-down 시작, beacon 발견 시 bottom-up 으로 dive.

매 cognitive constructs

  • Beacons: 매 recognizable patterns (e.g., for(i=0; i<n; i++) → 매 loop, swap(a,b) → 매 sort).
  • Plans: 매 stereotypical solutions (e.g., search plan, accumulator plan).
  • Chunks: 매 functionally cohesive code groups stored as 1 unit in working memory.

매 응용

  1. Code review: 매 reviewer 는 top-down — PR 의 의도 파악 후 specific changes 검증.
  2. Onboarding: 매 new dev 는 bottom-up — small fixes 로 시작, 점진적 chunking.
  3. AI-assisted reading: 매 LLM 에게 code summarization → human 이 hypothesis 생성.

💻 패턴

Pattern 1: Top-down hypothesis-driven reading

# 매 step 1: read README / docstring → 매 form hypothesis
# 매 step 2: locate entry point (main, app.py)
# 매 step 3: trace only the path that confirms/refutes hypothesis

def trace_hypothesis(repo, hypothesis):
    entry = find_entry_point(repo)
    call_graph = build_call_graph(entry)
    relevant = filter_by_keyword(call_graph, hypothesis.keywords)
    return relevant

Pattern 2: Beacon recognition (LLM-augmented)

import anthropic
client = anthropic.Anthropic()

def extract_beacons(code: str) -> list[str]:
    resp = client.messages.create(
        model="claude-opus-4-7",
        max_tokens=1024,
        system="Identify recognizable code patterns (beacons) and name their plan.",
        messages=[{"role": "user", "content": f"```\n{code}\n```"}],
    )
    return parse_beacons(resp.content[0].text)

Pattern 3: Chunking via cohesion analysis

def chunk_function(ast_node):
    """매 group statements by 매 shared variables (cohesion)."""
    chunks, current = [], []
    last_vars = set()
    for stmt in ast_node.body:
        vars = extract_vars(stmt)
        if last_vars and not (vars & last_vars):
            chunks.append(current)
            current = []
        current.append(stmt)
        last_vars = vars
    if current:
        chunks.append(current)
    return chunks

Pattern 4: Cross-reference walking (bottom-up)

# 매 ripgrep + ctags-driven exploration
rg -l "AuthService" --type ts | head -5
rg "class AuthService" --type ts -A 30
rg "new AuthService\(" --type ts  # 매 callers

Pattern 5: LLM-driven code summarization

# 매 Claude Code-style structured summary
PROMPT = """Summarize this file with:
1. 매 PURPOSE (1 sentence)
2. 매 KEY DATA STRUCTURES
3. 매 PUBLIC API
4. 매 NON-OBVIOUS CONTRACTS / INVARIANTS
5. 매 DEPENDENCIES (incoming + outgoing)
"""

def summarize(file_path):
    code = open(file_path).read()
    return claude_call(PROMPT + f"\n```\n{code}\n```")

Pattern 6: Mental model checkpointing

<!-- 매 personal-notes.md per repo while reading -->
## Module: auth/
- Purpose: JWT issuance & verification
- Entry: `auth/router.ts:loginHandler`
- Key invariant: tokens always include `iss=our-domain`
- Open Q: where is refresh-token rotation?

Pattern 7: Diagram-first — produce dependency graph before reading

madge --image deps.svg src/
# 매 visual chunking — see clusters before diving

매 결정 기준

상황 Strategy
매 domain familiar, code new Top-down
매 domain new, code small Bottom-up
매 large unknown codebase Opportunistic + diagram first
매 bug hunt Bottom-up from stack trace
매 architecture review Top-down from entry points
매 LLM augmentation Summarize → form hypothesis → verify

기본값: 매 opportunistic — 매 README + entry point 부터 시작, beacon 발견 시 dive.

🔗 Graph

🤖 LLM 활용

언제: 매 onboarding new repo, 매 reviewing large PR, 매 understanding legacy code, 매 building mental model. 언제 X: 매 1-line hot-fix 에 over-engineering 하지 마라.

안티패턴

  • Read everything linearly: 매 working memory 초과 — chunking 없이 무너짐.
  • Skip the README: 매 hypothesis 없이 bottom-up 만 → 매 lost in details.
  • No checkpointing: 매 1시간 후 모두 잊음 — write down mental model.
  • Trust LLM summary blindly: 매 hallucination 위험 — 매 verify on key claims.

🧪 검증 / 중복

  • Verified (Brooks 1983, Pennington 1987, Soloway & Ehrlich 1984, Storey 2006 review).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — top-down/bottom-up/opportunistic + LLM augmentation