docs(agents)!: leaf 지역 규칙 문서를 같은 폴더 AGENTS.md로 옮긴다

leaf·family 지역 규칙은 지금 src/**/CLAUDE.md에만 있어서 Claude Code
밖의 에이전트는 이 규칙을 정본 이름으로 찾지 못한다. 소유자가
2026-11-07에 루트와 하위 폴더 모두 AGENTS.md를 정본으로 정했다
(design-docs harness/01-harness-design.md 13절 Q1·Q2).

- 28개 파일을 git mv로 같은 폴더 AGENTS.md로 옮기고, 그 자리
  CLAUDE.md에는 `@AGENTS.md` 한 줄만 둔다. 이 세션에서
  src/domain-core 파일을 열자 CLAUDE.md의 가져오기가 펼쳐져
  AGENTS.md 본문이 함께 읽히는 것을 확인했다. 그래서 Claude Code는
  지금처럼 그 폴더를 만질 때 규칙을 읽는다.
- 버린 대안: 심볼릭 링크(Edit 도구가 링크를 통해 쓰지 않는다),
  CLAUDE.md 그대로 두기(다른 에이전트가 못 찾는다).
- 살아 있는 문서와 테스트 코드의 leaf 규칙 경로를 새 이름으로 바꿨다.
  기록 문서(evidence, upgrade, design, history, reviews, adr)는 쓴
  때의 경로를 그대로 둔다.
- link-check workflow(lychee)는 src/**/CLAUDE.md만 본다. 내용이
  AGENTS.md로 가면 상대 링크가 검사 밖으로 나가므로, PR마다 도는
  check-docs.py에 살아 있는 문서 전체의 상대 링크 검사를 더했다.
  workflow는 CI 재편 몫이라 고치지 않았다.
- check-work-docs.py의 이력 ID 검사도 src/**/AGENTS.md를 본다.

위험: git은 이 커밋을 "CLAUDE.md 수정 + AGENTS.md 추가"로 본다(같은
이름의 새 파일이 생겨 이름 바꾸기로 잡히지 않는다). 옛 이력은
`git log -- <폴더>/CLAUDE.md`로 본다. 코드 주석의 "CLAUDE.md"는
가져오기를 거쳐 같은 문서에 닿으므로 운영 코드는 고치지 않았다.

검증: python3 scripts/check-docs.py, python3 scripts/check-work-docs.py,
python3 -m unittest discover -s scripts/tests 모두 rc=0. 링크 검사
시험은 검사 조건을 끈 사본에서 7건 중 3건이 실패했다.

BREAKING CHANGE: 파생 서비스의 leaf 규칙 문서 이름이 AGENTS.md로
바뀐다. 동기화 뒤 각 leaf의 CLAUDE.md는 `@AGENTS.md` 한 줄이다.
This commit is contained in:
DongHyeonka
2026-11-07 21:58:12 +09:00
parent b3f63be655
commit 08f932123a
102 changed files with 3107 additions and 2986 deletions
+49 -2
View File
@@ -61,7 +61,7 @@ from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
EXCEPTIONS_FILE = "scripts/check-docs-exceptions.txt"
REGISTRY_FILE = "src/config/architecture/modules.json"
CHECKS = ("language", "head", "reference", "number", "map", "readme")
CHECKS = ("language", "head", "reference", "number", "map", "readme", "link")
# 기록: 본문은 쓴 때의 원문이다. 머리 블록만 고친다. 종류는 폴더가 정한다.
RECORD_KINDS = [
@@ -148,6 +148,10 @@ VERSION = re.compile(r"(?<![\w.§])v?\d+\.\d+\.\d+(?:[.-][A-Za-z][A-Za-z0-9]*)*(
SPRING_BOOT_CELL = re.compile(r"^Spring Boot(?:\s+(?:BOM|버전))?$")
CELL_MARKUP = re.compile(r"[*_`]")
LINK_TEXT = re.compile(r"\[([^\]\n]*)\]\([^)\s]*\)")
# 상대 링크: 살아 있는 문서의 `[글](경로)`가 이 트리의 파일·폴더를 가리킨다. lychee(link-check.yml)는 PR에서
# 정해진 경로만 보고, 그 밖의 문서(`src/**/AGENTS.md`, `.claude/**`, 루트 `AGENTS.md`)의 상대 링크는 이 검사만 본다.
LINK_TARGET = re.compile(r"\[[^\]\n]*\]\(([^)\s]+)\)")
URL_SCHEME = re.compile(r"^[a-z][a-z0-9+.-]*:", re.I)
@dataclass(frozen=True)
@@ -367,6 +371,49 @@ def inline_spans(lines: list[str]) -> list[tuple[int, str]]:
return spans
def link_targets(lines: list[str]) -> list[tuple[int, str]]:
"""(줄 번호, 상대 링크 대상) — 코드 블록·인라인 코드·「이력」 인용 블록 밖에서만."""
targets, fence, history = [], None, False
for number, line in enumerate(lines, start=1):
match = FENCE.match(line)
if fence:
if match and match.group(1)[0] == fence[0] and len(match.group(1)) >= len(fence):
fence = None
continue
if match:
fence = match.group(1)
continue
quoted = line.lstrip().startswith(">")
if quoted and HISTORY_QUOTE.match(line):
history = True
elif not quoted:
history = False
if history:
continue
for found in LINK_TARGET.finditer(INLINE.sub("", line)):
target = found.group(1).split("#", 1)[0]
if target and not URL_SCHEME.match(target):
targets.append((number, target))
return targets
def check_link(root: Path, files: list[str]) -> list[Problem]:
known = known_paths(root)
problems = []
for path in files:
if not is_living(path):
continue
text = (root / path).read_text(encoding="utf-8")
lines = body_lines(text)
offset = len(text.split("\n")) - len(lines)
for number, target in link_targets(lines):
resolved = posixpath.normpath(posixpath.join(posixpath.dirname(path), target))
if resolved.startswith("..") or not is_known(known, resolved):
problems.append(Problem("link", path, target, f"없는 곳을 가리키는 상대 링크다: {target}",
number + offset))
return problems
def registry_projects(root: Path) -> set[str]:
registry = root / REGISTRY_FILE
if not registry.is_file():
@@ -634,7 +681,7 @@ def check_readme(root: Path, files: list[str]) -> list[Problem]:
RUNNERS = {"language": check_language, "head": check_head, "reference": check_reference, "number": check_number,
"map": check_map, "readme": check_readme}
"map": check_map, "readme": check_readme, "link": check_link}
def read_exceptions(text: str) -> list[str]:
+4 -3
View File
@@ -9,7 +9,7 @@ to finish the job from those alone. Two things break that, and both are mechanic
who does not know that review. History belongs in `docs/work/evidence.md`, and the two reference
files that are indexes of history (`reference/decisions.md`, `reference/defect-patterns.md`).
The same rule covers the other files a new session reads first: the rule book `AGENTS.md` and
every `src/**/CLAUDE.md` (owner decision 2026-11-07). Module READMEs, design documents and
every `src/**/AGENTS.md` (owner decision 2026-11-07). Module READMEs, design documents and
`docs/reviews/**` keep their IDs, because a reader can follow them from inside the repository.
2. Length. Each entry file has a line limit, and the entry path (map + README + one playbook) has a
total limit, so a session reads the whole path instead of skimming it.
@@ -196,11 +196,12 @@ def check_skeleton(errors: list[str]) -> None:
def module_guides() -> list[Path]:
"""Every src/**/CLAUDE.md, the local rule book of a leaf or a family, outside build output."""
"""Every src/**/AGENTS.md, the local rule book of a leaf or a family, outside build output.
The src/**/CLAUDE.md beside it is one line, `@AGENTS.md`, so Claude Code reads the same book."""
skipped = {"build", ".gradle", "node_modules"}
return sorted(
path
for path in (REPO_ROOT / "src").rglob("CLAUDE.md")
for path in (REPO_ROOT / "src").rglob("AGENTS.md")
if not skipped.intersection(path.relative_to(REPO_ROOT).parts)
)
+32
View File
@@ -439,6 +439,38 @@ class ReadmeTest(RepositoryTestCase):
self.assertFailsWith(self.repo.run(("readme",)), "루트 README가 없다")
class LinkTest(RepositoryTestCase):
def errors_for(self, text: str, path: str = "src/app/AGENTS.md") -> list[str]:
self.repo.write(path, KOREAN + text)
return self.repo.run(("link",))
def test_a_relative_link_to_a_missing_file_fails(self) -> None:
self.assertFailsWith(self.errors_for("[설계](README.md)를 본다.\n"), "없는 곳을 가리키는 상대 링크다: README.md")
def test_a_relative_link_to_a_tracked_file_passes(self) -> None:
self.repo.write("src/app/README.md", KOREAN)
self.assertEqual(self.errors_for("[설계](README.md#결정)를 본다.\n"), [])
def test_a_link_up_the_tree_resolves_from_the_document_folder(self) -> None:
self.assertEqual(self.errors_for("[살아 있는 문서](../../docs/live.md)를 본다.\n"), [])
def test_a_link_out_of_the_repository_fails(self) -> None:
self.assertFailsWith(self.errors_for("[밖](../../../outside.md)를 본다.\n"), "../../../outside.md")
def test_a_folder_left_empty_on_disk_fails(self) -> None:
(self.repo.root / "src/app/moved").mkdir(parents=True)
self.assertFailsWith(self.errors_for("[옮김](moved/)을 본다.\n"), "moved/")
def test_urls_anchors_code_and_history_quotes_are_skipped(self) -> None:
text = ("[웹](https://example.com/x) [절](#절) `[코드](gone.md)`\n"
"```text\n[블록](gone.md)\n```\n> 이력: [옛 문서](gone.md)는 지웠다.\n")
self.assertEqual(self.errors_for(text), [])
def test_a_record_is_not_checked(self) -> None:
self.repo.write("docs/design/2026-08-11-x-design.md", head() + "[옛](gone.md)\n")
self.assertEqual(self.repo.run(("link",)), [])
class CommandLineTest(unittest.TestCase):
def test_an_unknown_check_is_a_usage_error(self) -> None:
self.assertEqual(check_docs.main(["--only", "spelling"]), 2)