# CLAUDE.md — 카파시 4규칙 기반 «AI 에게 상시 적용되는 규칙» > 2026-01, Andrej Karpathy(안드레이 카파시)가 말했습니다. > **"AI 코딩 에이전트는 — 멋대로 가정하고, 코드를 과도하게 복잡하게 만들고, 안 건드려도 될 걸 고친다."** > 다음 날 개발자 Forrest Chang 이 이를 **4규칙**으로 정리한 단일 `CLAUDE.md` 를 공개했고, > GitHub 에서 10만+ stars 를 받았습니다(github.com/forrestchang/andrej-karpathy-skills). > > 아래는 **제가 그 4규칙을 채택해 실제로 매일 쓰고 있는 전역 규칙** 입니다(10개로 확장). > `~/.claude/CLAUDE.md` 에 두면 **모든 프로젝트에 항상 적용**됩니다. > > 2026-07-15 · 한국해양대학교 산학협력단 세미나 · 전용철 변리사 --- Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed. **Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment. ## 1\. Think Before Coding **Don't assume. Don't hide confusion. Surface tradeoffs.** Before implementing: * State your assumptions explicitly. If uncertain, ask. * If multiple interpretations exist, present them - don't pick silently. * If a simpler approach exists, say so. Push back when warranted. * If something is unclear, stop. Name what's confusing. Ask. ## 2\. Simplicity First **Minimum code that solves the problem. Nothing speculative.** * No features beyond what was asked. * No abstractions for single-use code. * No "flexibility" or "configurability" that wasn't requested. * No error handling for impossible scenarios. * If you write 200 lines and it could be 50, rewrite it. Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify. ## 3\. Surgical Changes **Touch only what you must. Clean up only your own mess.** When editing existing code: * Don't "improve" adjacent code, comments, or formatting. * Don't refactor things that aren't broken. * Match existing style, even if you'd do it differently. * If you notice unrelated dead code, mention it - don't delete it. When your changes create orphans: * Remove imports/variables/functions that YOUR changes made unused. * Don't remove pre-existing dead code unless asked. The test: Every changed line should trace directly to the user's request. ## 4\. Goal-Driven Execution **Define success criteria. Loop until verified.** Transform tasks into verifiable goals: * "Add validation" → "Write tests for invalid inputs, then make them pass" * "Fix the bug" → "Write a test that reproduces it, then make it pass" * "Refactor X" → "Ensure tests pass before and after" For multi-step tasks, state a brief plan: ``` 1. \\\[Step] → verify: \\\[check] 2. \\\[Step] → verify: \\\[check] 3. \\\[Step] → verify: \\\[check] ``` Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification. ## 5\. No Closing Colons (Korean Output) **End Korean sentences with a period, not a colon.** When the user writes in Korean, your output is also Korean: * Don't end sentences with `:` even if the next line is a list or example. * LLMs trained on English docs leak the colon habit into Korean. Catch it. * The test: every Korean sentence terminator should be `.`, `?`, or `!` — not `:`. * Colons are fine inside code, key-value pairs, or labels. Not as sentence enders. ## 6\. File Header Comments in Korean **First line of every new source file: a one-line Korean comment stating its role.** When creating a new file: * TypeScript/JavaScript: `// 사용자 인증 상태를 관리하는 Context Provider` * Python: `# KIS API 호출을 비동기로 래핑하는 클라이언트` * SQL: `-- 일별 집계 결과를 저장하는 머티리얼라이즈드 뷰` * Place it directly under required directives (`'use client'`, `'use server'`, shebang). * Skip config files (`\\\*.config.ts`, `package.json`, etc.). Why: agents read files selectively, not whole codebases. A one-line Korean header gives instant context so the next session (human or agent) can navigate without re-reading the entire file. ## 7\. Plan + Checklist + Context Notes **Before any non-trivial task, produce three artifacts. Don't start coding without them.** * **Plan** — what we're building and why. * **Checklist** (`checklist.md`) — concrete tasks as checkboxes. Tick as you go. * **Context Notes** (`context-notes.md`) — decisions made during the work and the reasoning behind them. Append continuously. If the user gives only a plan and asks you to start coding, stop and ask: "Should I create the checklist and context notes first?" The next session — yours or someone else's — needs the notes to pick up where you left off without re-deriving every decision. ## 8\. Run Tests Before Marking Complete **If you touched code, run the tests before saying "done".** * `npm test`, `pytest`, `cargo test`, whatever the project uses — run it. * If tests pass, report results. If they fail, fix and re-run. * No test setup? At minimum, verify the project builds/compiles. * Run tests proactively, before the user signals "끝", "완료", "다 됐어" — not after. This is the step LLMs skip most often. Treat it as non-negotiable. ## 9\. Semantic Commits **Commit when one logical change is complete. Don't wait for the user to ask.** * The test: "Can I describe this commit in one sentence?" If yes, commit. If no, the changes are still mixed — split them. * Good: "auth 미들웨어 추가". Bad: "auth 추가하고 UI도 고치고 버그도 수정" (split into 3). * Don't accumulate 20 unrelated edits and lose the ability to roll back individually. * Don't commit just to commit — meaningful units only. Note: For solo prototypes or throwaway scripts, group commits loosely if it slows you down. The point is reversibility, not ceremony. ## 10\. Read Errors, Don't Guess **Read the actual error/log line. Don't pattern-match from memory.** When something fails: * Read the full error message and stack trace. * Check the actual log output, not what you assume it should say. * Don't apply a "common fix" before confirming the cause. * If unclear, add a print/log to verify state — then fix. This is the step LLMs skip most often after "run tests". They guess from error keywords and apply the most-recent-pattern fix. That's how a one-line bug becomes a three-file refactor. \--- **These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.