"""`.claude/`의 서브에이전트 정의와 스킬이 소유자 결정(2026-11-07)대로인지 본다. 결과만 받는 일은 서브에이전트, 파일을 바꾸는 위임은 하위 세션이다(docs/work/delegate.md 4.3절). 새 스킬은 모두 모델이 부를 수 있고, 설명에 발동 조건을 문단으로 적는다. python3 -m unittest discover -s scripts/tests """ from __future__ import annotations import json import re import unittest from pathlib import Path REPO = Path(__file__).resolve().parent.parent.parent AGENTS = REPO / ".claude/agents" SKILLS = REPO / ".claude/skills" # Claude Code cuts a skill description at this many characters in the listing. DESCRIPTION_LIMIT = 1536 WRITE_TOOLS = {"Edit", "Write", "MultiEdit", "NotebookEdit"} def front_matter(path: Path) -> dict[str, str]: text = path.read_text(encoding="utf-8") match = re.match(r"^---\n(.*?)\n---\n", text, re.S) if not match: return {} fields = {} for line in match.group(1).splitlines(): key, _, value = line.partition(":") fields[key.strip()] = value.strip() return fields class SubagentTest(unittest.TestCase): def test_the_agent_tool_is_no_longer_denied(self) -> None: settings = json.loads((REPO / ".claude/settings.json").read_text(encoding="utf-8")) deny = settings.get("permissions", {}).get("deny", []) self.assertFalse([rule for rule in deny if rule == "Agent" or rule.startswith("Agent(")]) def test_each_definition_names_itself_and_says_when_to_use_it(self) -> None: definitions = sorted(AGENTS.glob("*.md")) self.assertEqual([path.stem for path in definitions], ["arch-reviewer", "code-simplifier", "verify-api"]) for path in definitions: fields = front_matter(path) self.assertEqual(fields.get("name"), path.stem, path) self.assertRegex(fields.get("description", ""), r"쓴다", path) self.assertTrue(fields.get("tools"), f"{path} must list its tools; an empty list inherits every tool") def test_no_subagent_can_edit_files(self) -> None: for path in AGENTS.glob("*.md"): tools = {tool.strip() for tool in front_matter(path).get("tools", "").split(",")} self.assertFalse(tools & WRITE_TOOLS, f"{path} returns results only; it must not hold {tools & WRITE_TOOLS}") def test_the_reviewers_have_no_shell_that_could_change_the_tree_except_read_commands(self) -> None: self.assertNotIn("Bash", front_matter(AGENTS / "code-simplifier.md")["tools"]) reviewer = (AGENTS / "arch-reviewer.md").read_text(encoding="utf-8") self.assertIn("파일을 쓰거나 고치지 않는다", reviewer) def test_verify_api_runs_the_app_on_the_desktop_under_the_shared_lock(self) -> None: text = (AGENTS / "verify-api.md").read_text(encoding="utf-8") for fragment in ("docs/work/operate.md", "flock /tmp/claude-gates/heavy.lock", "scripts/bootstrap-local.sh", "stash@{0}", "down"): self.assertIn(fragment, text) class SkillTest(unittest.TestCase): CANON = {"new-feature": "docs/work/new-feature.md", "desktop-gates": "docs/work/operate.md"} def test_the_repository_skills_are_the_two_the_manual_names(self) -> None: self.assertEqual(sorted(path.parent.name for path in SKILLS.glob("*/SKILL.md")), sorted(self.CANON)) def test_each_skill_is_model_invoked_and_says_when_in_its_description(self) -> None: for name in self.CANON: fields = front_matter(SKILLS / name / "SKILL.md") self.assertEqual(fields.get("name"), name) self.assertNotIn("disable-model-invocation", fields) description = fields.get("description", "") self.assertLessEqual(len(description), DESCRIPTION_LIMIT, name) self.assertIn("쓴다", description, f"{name}: say when to use it") self.assertIn("부른다", description, f"{name}: say what the user says that calls it") def test_each_skill_points_at_its_canonical_playbook_instead_of_copying_it(self) -> None: for name, canon in self.CANON.items(): body = (SKILLS / name / "SKILL.md").read_text(encoding="utf-8") self.assertIn(f"정본은 `{canon}`", body) self.assertIn("정본이 맞다", body) def test_the_uninstalled_skill_lock_is_gone(self) -> None: self.assertFalse((REPO / "skills-lock.json").exists()) if __name__ == "__main__": unittest.main()