AGENT SKILL

xddp-fill-rulebook

project-rulebook.md の未記入セクションをコード調査でドラフト生成し、人が確認・修正後に書き込む。「project-rulebook を埋めて」「リポジトリ構成を生成して」などで起動する。

License 许可
MIT
最近更新
2026-11-08
Stars
★ 1
Forks
0

01 前言 Front Matter

name
xddp-fill-rulebook
description
project-rulebook.md の未記入セクションをコード調査でドラフト生成し、人が確認・修正後に書き込む。「project-rulebook を埋めて」「リポジトリ構成を生成して」などで起動する。
argument-hint
[repo名 / cross]

03 SKILL.md 正文

You are executing XDDP Fill Steering — Auto-draft project-rulebook.md.

Arguments: $ARGUMENTS

  • No arguments → target the shared project-rulebook.md, all unwritten sections
  • {repo} (a repository name matching REPOS: key) → target project-rulebook-{repo}.md
  • cross → target project-rulebook-cross.md
  • all → target shared + all per-repo + cross (if REPOS: has ≥2 entries)
  • Section number (e.g., 2, 6) after an optional repo/cross/all → target only those sections (multiple allowed: 2 6)

Examples:


0. Parse arguments

Let RAW_ARGS = trimmed $ARGUMENTS. Let tokens = split(RAW_ARGS).

Determine TARGET_REPO:

  • If first token is a section number (matches ^\d) → TARGET_REPO = shared, TARGET_SECTIONS = all tokens.
  • If first token is all → TARGET_REPO = all, TARGET_SECTIONS = remaining tokens (section numbers if any).
  • If first token is cross → TARGET_REPO = cross, TARGET_SECTIONS = remaining tokens.
  • If first token matches a REPOS: key (detected after reading xddp.config.md in Step 1) → TARGET_REPO = that token, TARGET_SECTIONS = remaining tokens.
  • If no arguments → TARGET_REPO = shared, TARGET_SECTIONS = [] (all sections).

If TARGET_SECTIONS is empty, treat as "all sections".

1. Locate xddp.config.md

Read ~/.claude/skills/xddp-common/SKILL.md, apply "## Load Config" with: NOT_FOUND_MESSAGE: "xddp.config.md が見つかりませんでした。\/xddp-01-init` を先に実行してください。"→ letWORKSPACE_ROOT, XDDP_DIR, REPOS_KEYS`(他の戻り値は本スキルでは未使用).

Let XDDP_ABS = {WORKSPACE_ROOT}/{XDDP_DIR}.

Now resolve TARGET_REPO if it was set from the first argument (may need REPOS_KEYS to verify):

  • If first token matches a REPOS_KEYS entry → confirmed as TARGET_REPO.
  • If first token is not a section number, not all, not cross, and not in REPOS_KEYS → report error: "指定された引数 '{token}' はリポジトリ名でも all/cross でもありません。" and stop.

Determine target files (TARGETS = list of {repo → steering_file} pairs):

  • TARGET_REPO = shared → [{shared: {XDDP_ABS}/project-rulebook.md}]
  • TARGET_REPO = cross → [{cross: {XDDP_ABS}/project-rulebook-cross.md}]
  • TARGET_REPO = {repo} → [{{repo}: {XDDP_ABS}/project-rulebook-{repo}.md}]
  • TARGET_REPO = all → shared + each repo in REPOS_KEYS + cross (if len(REPOS_KEYS)≥2)

Single-repo guard (standalone if block; placed after the "Determine target files" block completes, before Step 2 begins):

If len(REPOS_KEYS) == 1:

  • If TARGET_REPO matches a REPOS_KEYS entry: Tell the user: "シングルリポジトリ構成では project-rulebook-{repo}.md は生成されません。引数なしで /xddp-fill-rulebook を実行すると共通の project-rulebook.md を対象にします。" and stop.
  • If TARGET_REPO = cross: Tell the user: "シングルリポジトリ構成では project-rulebook-cross.md は生成されません。引数なしで /xddp-fill-rulebook を実行すると共通の project-rulebook.md を対象にします。" and stop.
  • If TARGET_REPO = all: Set TARGETS = [{shared: {XDDP_ABS}/project-rulebook.md}]. Notify the user: "シングルリポジトリ構成のため、all 指定でも project-rulebook.md のみを対象にします。" Continue with updated TARGETS.

2. Locate/create target project-rulebook file(s)

For each target file in TARGETS:

  • If not found:
    • shared → copy ~/.claude/skills/xddp-common/templates/project-rulebook-template.md
    • cross → copy ~/.claude/skills/xddp-common/templates/project-rulebook-cross-template.md
    • {repo} → copy ~/.claude/skills/xddp-common/templates/project-rulebook-repo-template.md; replace {REPO_NAME} placeholder with actual repo name
    • Tell the user "(ファイル名)が存在しなかったためテンプレートからコピーしました。" and continue.
  • If found: read it.

3. Identify unwritten sections

For each target file, scan for placeholder strings:

Shared project-rulebook.md:

Section Placeholder strings
§1 (プロジェクト名)、(主要言語: Python / TypeScript / Go / Java / etc.)、(フレームワーク: FastAPI / Next.js / Spring Boot / etc.)、(アーキテクチャ: モノリス / マイクロサービス / etc.)、(データベース: PostgreSQL / MySQL / DynamoDB / etc.)、(テストフレームワーク: pytest / Jest / JUnit / etc.)
§1.5 テーブル行が | (例) で始まる(REPOS: ≥2 entries の場合のみスコープ)
§2 (プロジェクト固有の命名規約をここに記述する)
§3 (プロジェクト固有のアーキテクチャ決定をここに記録する)
§4 (プロジェクト固有のパターンをここに記述する)
§5 (プロジェクト固有の禁止事項・注意事項をここに記述する)
§6 (プロジェクト固有のモジュール構成をここに記述する)

Per-repo project-rulebook-{repo}.md:

Section Placeholder strings
§1 (リポジトリ名 = xddp.config.md の REPOS: キー名と一致)、(主要言語: ...) などの () 囲みプレースホルダー
§2 (このリポジトリ固有の命名規約をここに記述する)、(このリポジトリ固有の DB・API 命名規約をここに記述する)
§5 (このリポジトリ固有のアーキテクチャ決定をここに記録する)
§4 (このリポジトリ固有のエラーハンドリングパターンをここに記述する) など
§6 (このリポジトリ固有の禁止事項・注意事項をここに記述する)
§6 (このリポジトリ固有のモジュール構成をここに記述する) (if §6 exists)

Cross project-rulebook-cross.md:

Section Placeholder strings
§1 テーブル行が | (例) で始まる
§2 (プロジェクト固有の SemVer 運用ルールをここに追記する)
§3 (プロジェクト固有の命名規則をここに追記する)
§4 (プロジェクト固有のエラーコード一覧をここに記述する)
§5 (プロジェクト固有の認証方式をここに記述する)
§6 (プロジェクト固有の移行期間ルールをここに記述する)

If TARGET_SECTIONS is specified: filter to only those sections. Let UNWRITTEN = sections to process. If UNWRITTEN is empty for all targets: tell the user "すべてのセクションが記入済みです。" and stop.

4. Investigate codebase and draft each section

For each section in UNWRITTEN, run the investigation and generate a draft.

§1 Project overview (shared): Read xddp.config.md for already-set values. Then inspect:

  • requirements.txt / pyproject.toml → Python project
  • package.json → Node/TypeScript project
  • go.mod → Go project
  • pom.xml / build.gradle → Java project
  • Root README.md

Draft the 6 config fields: PROJECT_NAME, LANGUAGE, FRAMEWORK, ARCHITECTURE, DB, TEST_FRAMEWORK.

§1 Repository basic info (per-repo): Inspect the target repo's root files to draft REPO_NAME, LANGUAGE, FRAMEWORK, BUILD_TOOL, TEST_FRAMEWORK, ROLE, and the module map.

§1 / §2 Cross-repo overview (cross): For each repo in REPOS:, investigate the upstream-repos / downstream-repos relationships to draft the target repository table and dependency block.

§1.5 Repository structure (shared — only when len(REPOS_KEYS) ≥ 2): For each repo in REPOS:, investigate in parallel:

  • requirements.txt / pyproject.toml / package.json / go.mod → main technologies
  • src/**/*.py / src/**/*.ts import statements → inter-repo package dependencies
  • httpx.post / requests.post / fetch / axios / RestTemplate calls → HTTP call targets
  • README.md / main.py / main.ts / app.py → service role

Draft:

  1. Repository table (name / role / main tech)
  2. Dependency block (package deps + HTTP calls)

§2 Naming conventions: Sample 5–10 source files from each repo and examine:

  • File/directory names → naming pattern (snake_case, camelCase, kebab-case)
  • Class names → PascalCase or other
  • Function/method names → snake_case or camelCase
  • Constants → UPPER_SNAKE_CASE or other
  • DB table/column names (look for ORM model definitions or migration files)
  • API endpoint paths (look for router definitions)

§6 Module structure: Read directory structure. Then, based on LANGUAGE detected in §1:

LANGUAGE Entry point files to read
Python __init__.py in each package directory
TypeScript / JavaScript index.ts / index.js in each module directory
Go Top-level *.go files in each package directory
Java src/main/ structure + package-info.java
Rust lib.rs / main.rs
Other (unknown) Directory structure only; skip file content

Draft a concise module map showing each directory's role.

§5 (ADR — Architecture Decision Records): Run the following git commands on {REPO_PATH}:

git -C {REPO_PATH} log --oneline --all --extended-regexp --grep="refactor|revert|rework|migrate|redesign" -20

Also identify large-scope commits (many files changed across modules):

git -C {REPO_PATH} log --oneline --all -30 --name-only --format="%H %s"

AI judgment: if changed files span ≥3 distinct top-level directories → include as candidate.

For each identified candidate commit, draft one minimal ADR entry:

#### ADR-候補-{hash[:7]}: {コミットメッセージから推定したタイトル}

**状態:** ドラフト(git log から推定 — 人による確認・修正が必要)
**コミット:** {hash} — {date}
**推定内容:** {コミットメッセージから読み取れる設計上の判断や制約}

Limit to at most 5 ADR candidates to avoid overwhelming the user. If no candidates found from git log: insert (git log から候補を確認できませんでした。手動記入してください)

§6 (not applicable): Insert the note: (コード調査から確認できなかったため手動記入してください)

§4 (filled in during specout): Insert the note: (スペックアウト(工程4a)で調査・記入されます)

5. Present all drafts and accept diff instructions

Show all drafted sections together in a single message:

以下のドラフトを生成しました。修正があればセクション番号と変更内容を指示してください。
問題なければ「OK」と入力してください。

---

## §1 プロジェクト概要(ドラフト)

{draft content}

---

## §1.5 リポジトリ構成(ドラフト)

{draft content}

---

(以降、対象セクション分を続ける)

Accept the user's response:

  • OK / ok / はい / 問題ない → proceed to Step 6
  • Diff instructions (e.g., "§2 の命名規約は〇〇に変えてください") → apply changes and re-present the updated drafts
  • Repeat until the user confirms with OK

6. Write to project-rulebook file(s)

For each target file in TARGETS, for each section in UNWRITTEN:

  • Replace the placeholder content in the target file with the confirmed draft.
  • Replace the entire section body (from the section heading to the next --- separator) with the confirmed draft.

Send a PushNotification:

  • title: "xddp-fill-rulebook 完了"
  • message: "{書き込んだファイル名とセクション番号の一覧}への書き込みが完了しました。内容を確認してください。" (例: "project-rulebook.md §1 §2 / project-rulebook-repo-a.md §1 への書き込みが完了しました。内容を確認してください。")

Tell the user:

以下のファイルにセクションを記入しました:
- {ファイル名}: §X {セクション名}(対象セクション分を列挙)

次のステップ: 内容を確認し、必要に応じて手動で追記・修正してください。
スペックアウトを開始する場合は `/xddp-04-specout {CR番号}` を実行してください。

04 同仓库更多 Skills