Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "AGENTS.md を20〜50行程度の repository instruction index として整備し、CLAUDE.md から import する。また、native worktree isolation を利用せず独自 issue worktree binding を正本とする方針を static validator で強制する。"
change_kind: mixedParent Issue
なし(単独改善)
Parent Goal Ref
- Goal: AGENTS.md を repository instruction index として整備し、native worktree isolation の混入を static validator で防止する
- Desired Destination: N/A(単独改善 Issue のため)
Current Validated Scope
AGENTS.mdを20〜50行程度の index に再構成するCLAUDE.mdから@AGENTS.mdを import する- native worktree isolation の混入を検出する static validator を追加する
- worktree binding manifest(
WORKTREE_SCOPE_BINDING_V1)の仕様を docs へ記載する
Remaining Parent Gaps
なし(単独改善 Issue のため)
Outcome
AGENTS.md が20〜50行程度の repository instruction index として整備され、CLAUDE.md が @AGENTS.md を import した状態になっている。加えて、native worktree isolation(isolation: worktree frontmatter・EnterWorktree 呼び出し・cwd basename や vendor-specific agent ID からの Issue 推測など)の混入を検出する static validator が追加され、独自 issue worktree binding manifest(WORKTREE_SCOPE_BINDING_V1)と live Git state の照合による正規 binding 解決が test で保証されている状態。
In Scope
概要
AGENTS.md を20~50行程度の repository instruction index として整備し、CLAUDE.md から import する。
同時に、Claude Code/Codex CLI の native worktree isolation を利用せず、独自 issue worktree binding を正本とするプロジェクト方針を static validator で強制する。
背景
現在の AGENTS.md と CLAUDE.md は短い pointer に留まっている。
一方、すべての build/test command や Skill/Agent/Hook の詳細責務を常時 context に入れると、異なる作業文脈で不要な instructions が増え、context bloat や conflicting instructions を招く。
Repository-level instruction は索引に限定し、作業固有の手順は対応する Skill と SSOT document へ委譲する。
また、このリポジトリでは vendor-native isolation ではなく、独自 issue worktree binding を正本とする。Agent の cwd や vendor-specific agent ID から Issue を推測してはならない。
対象
AGENTS.mdCLAUDE.md- repository instruction checker
- Agent/Skill frontmatter validator
- worktree binding documentation
- tests
実装要件
CLAUDE.md
AGENTS.md を import し、Claude Code 固有の差分だけを保持する。
@AGENTS.md
AGENTS.md
20~50行程度を目安とし、次を含める。
- repository の短い概要
1 Issue = 1 PR- 独自 issue worktree binding が SSOT であること
- 主要ディレクトリから対応する運用 SSOT への索引
- 重要 docs への索引
- 逸脱時に参照する Skill
- repository mutation 前に binding validator を通すこと
次は記載しない。
- 全文脈に共通しない
pnpm typecheck / lint / test / build - Python/TypeScript/AI Agent 全体へ一律適用できない command
- Skill/Agent/Hook の詳細責務
- 長大 schema
- generic coding conventions
- GitHub branch protection と重複する長文
- repository 固有でない一般論
native isolation validator
次を禁止対象として検出する。
Claude agent frontmatter: isolation: worktree
EnterWorktree 呼び出し
Codex native isolation/worktree option
agent-* 命名 worktree を issue binding とみなす処理
cwd basename だけに依存した issue 解決
vendor-specific agent ID からの issue 推測
正規 binding は明示的 manifest と live Git state の照合で解決する。
例:
WORKTREE_SCOPE_BINDING_V1:
repo: squne121/loop-protocol
issue_number: 123
worktree_path: /absolute/path
branch: worktree-issue-123-slug
bootstrap_head_sha: ...
binding_digest: ...GitHub branch protection はローカル working tree の編集を防止しないため、repository mutation の禁止は Skill/executor/binding validator 側で強制する。
Out of Scope
AGENTS.mdを workflow manual にすること- すべての test command を常時読み込ませること
- GitHub ruleset だけでローカル main checkout の変更を防げると仮定すること
- native isolation と独自 issue binding を併用すること
Acceptance Criteria
- AC1:
AGENTS.mdが20~50行程度の index になっている - AC2:
CLAUDE.mdが@AGENTS.mdを import している - AC3: Claude Code 固有情報は
CLAUDE.mdに分離されている - AC4: 主要ディレクトリから運用 SSOT を発見できる
- AC5: 文脈固有の build/test command が常時 instruction から除外されている
- AC6: native worktree isolation の混入を検出する validator がある
- AC7:
isolation: worktreeとEnterWorktreeの fixture が拒否される - AC8: cwd basename/agent ID だけによる Issue 推測が拒否される
- AC9: manifest と live Git state の不一致が拒否される
- AC10: repository mutation 前の binding validation が test されている
- AC11: Claude Code と Codex CLI の双方で index discovery の smoke test が成功する
Verification Commands
# AC1
$ wc -l AGENTS.md
# AC2
$ rg -n "^@AGENTS.md$" CLAUDE.md
# AC3
$ rg -c "Claude Code" CLAUDE.md
# AC4
$ rg -n "docs/" AGENTS.md
# AC5
$ rg -c -e "pnpm typecheck" -e "pnpm lint" -e "pnpm test" -e "pnpm build" AGENTS.md
# AC6
$ test -f scripts/agent-ops/native_isolation_guard.py
# AC7
$ uv run --locked python3 -m pytest scripts/agent-ops/tests/test_native_isolation_guard.py -k isolation_worktree_frontmatter_rejected
# AC8
$ uv run --locked python3 -m pytest scripts/agent-ops/tests/test_native_isolation_guard.py -k cwd_or_agent_id_inference_rejected
# AC9
$ uv run --locked python3 -m pytest scripts/agent-ops/tests/test_native_isolation_guard.py -k manifest_live_git_state_mismatch_rejected
# AC10
$ uv run --locked python3 -m pytest scripts/agent-ops/tests/test_native_isolation_guard.py -k mutation_precondition_validated
# AC11
$ uv run --locked python3 -m pytest scripts/agent-ops/tests/test_native_isolation_guard.py -k index_discovery_smokeAllowed Paths
AGENTS.mdCLAUDE.mdscripts/agent-ops/native_isolation_guard.pyscripts/agent-ops/tests/test_native_isolation_guard.pydocs/dev/worktree-issue-binding.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
- Python
- Markdown / repository instruction authoring
Required Design References
- docs/dev/workflow.md
- docs/dev/secret-policy.md
Scope Delta(該当時のみ記載)
N/A
Delivery Rule
1 Issue = 1 PR- 作業は専用 worktree(
worktree-issue-<番号>-<slug>)で行う - PR は Draft PR を既定とする
Notes for Reviewer
- overlap preflight(
check_issue_overlap.py)実行結果:decision: overlap_requires_comment(policy_class C1)。AGENTS.md/CLAUDE.mdを Allowed Paths に含む OPEN Issue: feat(agent-ops): agent ops / impl-review-loop 用 context budget を導入する #1117, 実装: agent context budget inventory を導入し AGENTS/CLAUDE/skills/hooks/subagents/rules/scripts の重複読みに上限を設ける #1093, 実装: feat(agent-ops): issue-refinement-ops-review で agent_ops_inventory を必須 preflight 化する #1009, 実装: agent preflight bundle と task packet generator を追加する #790, 調査: Claude Code hook でgrep呼び出しをrgに置換する運用の実現性と flag マッピング設計を決定する #75, 調査: Claude Code hook でpython呼び出しをuv runに置換する運用の実現性と適用範囲を決定する #74。 - non_conflict_reason: 上記候補(特に 実装: agent context budget inventory を導入し AGENTS/CLAUDE/skills/hooks/subagents/rules/scripts の重複読みに上限を設ける #1093 / feat(agent-ops): agent ops / impl-review-loop 用 context budget を導入する #1117 / 実装: feat(agent-ops): issue-refinement-ops-review で agent_ops_inventory を必須 preflight 化する #1009)は AGENTS/CLAUDE 等の重複読みを測定する context budget inventory ツールの追加であり、本 Issue は
AGENTS.mdの内容自体を index 化・再構成し native isolation validator を追加するもの。編集意図が異なるため、同一ファイルへの sequential なマージ調整(コンフリクト時は rebase)で対応可能と判断する。
Activity