contribute-rule
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecontribute-rule
contribute-rule
現在のプロジェクトから知見を収集し、TBSten/skills リポジトリに rule として登録する PR を自動作成する。
Automatically collect insights from the current project and create a PR to register them as rules in the TBSten/skills repository.
前提条件チェック
Prerequisite Check
スキル起動時にまず以下を確認する。失敗した場合は対処方法を案内して中断する。
- で git の存在を確認
git --version - で gh CLI の認証状態を確認
gh auth status
When the skill is launched, first verify the following items. If any check fails, provide guidance on how to resolve the issue and abort execution.
- Confirm git is installed via
git --version - Confirm gh CLI authentication status via
gh auth status
Step 1: 起動時の確認
Step 1: Startup Confirmation
ARGUMENTS からユーザーが収集したい知見の説明を受け取る。以下を確認する。
ユーザーの指示から明確に読み取れる項目は確認を省略してよい。
- rule 名 — kebab-case で命名。知見の内容から適切な名前を提案する
- 収集対象 — どの知見をルール化するか。具体的なファイルパスやセクションを特定する
- ルールの対象ユーザー — どのようなプロジェクト・状況で適用されるルールか
- 参照ファイルの有無 — ルールが参照するテンプレートやサンプルコード等があるか
- リポジトリ — デフォルトは 。fork を使う場合はユーザーに確認する
TBSten/skills
Receive the description of insights the user wants to collect from ARGUMENTS. Confirm the following items, you may skip confirmation for items that can be clearly inferred from the user's instructions.
- Rule name — Name in kebab-case, propose an appropriate name based on the content of the insight
- Collection target — Specify which insights to convert into rules, identify specific file paths or sections
- Target users of the rule — Define what types of projects and scenarios the rule applies to
- Presence of reference files — Check if there are templates, sample code or other materials referenced by the rule
- Repository — Default is , confirm with the user if they want to use a fork
TBSten/skills
Step 2: 知見の収集と整理
Step 2: Insight Collection and Organization
ユーザーが指定した収集対象を読み取る。
Read the collection targets specified by the user.
収集の効率化
Collection Efficiency Improvement
収集対象が多い場合、Agent tool を活用して並列に収集する:
- 対象ファイルの読み取り (Glob でファイル一覧取得 → 並列 Read)
- 関連する規約・パターンの調査 (Grep で検索 → 並列 Read)
独立したファイル読み取りは必ず並列で実行すること。
主なソース:
- CLAUDE.md の特定セクション
- 内の既存ルールファイル
.claude/rules/ - コードベース内の規約・パターン・ベストプラクティス
- コードレビューで繰り返し指摘される事項
- ユーザーの説明そのもの
読み取った知見を以下の形式で整理し、ユーザーに提示する:
- ルールの目的 — 1〜2文で何を規定するか
- ルールの内容 — Claude Code に指示する振る舞いの箇条書き
- 適用条件 — どのようなプロジェクト・状況でこのルールが有効か
- 参照ファイル — テンプレートやサンプルコード等。不要であれば「なし」と明記
ユーザーの承認を得てから次のステップに進む。
If there are a large number of collection targets, use Agent tool to collect them in parallel:
- Read target files (Get file list via Glob → Parallel read)
- Research related conventions and patterns (Search via Grep → Parallel read)
Always execute independent file read operations in parallel.
Main sources:
- Specific sections of CLAUDE.md
- Existing rule files in
.claude/rules/ - Conventions, patterns and best practices in the codebase
- Items repeatedly pointed out in code reviews
- The user's original description
Organize the collected insights in the following format and present to the user:
- Rule purpose — Describe what the rule regulates in 1-2 sentences
- Rule content — Bulleted list of behaviors to instruct Claude Code to follow
- Application conditions — Define what types of projects and scenarios this rule is valid for
- Reference files — Templates, sample code, etc. Specify "None" if not applicable
Proceed to the next step only after obtaining explicit approval from the user.
Step 3: ワークディレクトリの準備と add-rule.md の読み込み
Step 3: Work Directory Preparation and add-rule.md Loading
- ワークディレクトリを準備する:
bash
rm -rf /tmp/contribute-rule
git clone --depth 1 https://github.com/<repo>.git /tmp/contribute-rule<repo>TBSten/skills- clone したリポジトリ内のルール作成ガイドを読み込む:
/tmp/contribute-rule/.claude/skills/add-rule.mdadd-rule.md を読み込んだ後、以下のように統合する:
- add-rule.md の Step 1 (確認事項): contribute-rule の Step 1-2 で既に完了。スキップする
- add-rule.md の Step 2 (ディレクトリとファイルの作成): 構成ルールに従う。内容は contribute-rule の Step 2 で整理した知見を使う
- add-rule.md の Step 2.5 (詳細ドキュメントの作成): そのまま従う
- add-rule.md の Step 3 (README の更新): そのまま従う
ガイドが見つからない場合は、以下の「フォールバック」セクションに従う。
- Prepare the work directory:
bash
rm -rf /tmp/contribute-rule
git clone --depth 1 https://github.com/<repo>.git /tmp/contribute-rule<repo>TBSten/skills- Load the rule creation guide in the cloned repository:
/tmp/contribute-rule/.claude/skills/add-rule.mdAfter loading add-rule.md, integrate the processes as follows:
- Step 1 of add-rule.md (Confirmation items): Already completed in Steps 1-2 of contribute-rule, skip this step
- Step 2 of add-rule.md (Directory and file creation): Follow the configuration rules, use the insights organized in Step 2 of contribute-rule as content
- Step 2.5 of add-rule.md (Create detailed documentation): Follow as instructed
- Step 3 of add-rule.md (Update README): Follow as instructed
If the guide is not found, follow the "Fallback" section below.
Step 4: ルールファイルの作成
Step 4: Rule File Creation
clone した 内で、add-rule.md の手順に従い以下を作成する。
Step 2 で整理した知見をもとに RULE.md を記述する。
/tmp/contribute-rule/- — ルール本体。YAML frontmatter は不要。命令形 (imperative) で記述する
rules/<rule-name>/RULE.md - 参照ファイルがあれば同ディレクトリに配置
- インストール時にユーザーのカレントディレクトリにコピーされることを意識してパスを設計する
- サブディレクトリのネストも可能
- — 詳細ドキュメント (英語)
rules/<rule-name>.md - — 詳細ドキュメント (日本語)
rules/<rule-name>.ja.md - と
README.mdの Available Rules テーブルに行を追加README.ja.md
In the cloned directory, follow the steps in add-rule.md to create the following files. Write RULE.md based on the insights organized in Step 2.
/tmp/contribute-rule/- — Main rule body, no YAML frontmatter required, write in imperative form
rules/<rule-name>/RULE.md - Place any reference files in the same directory if available
- Design paths with the consideration that they will be copied to the user's current directory during installation
- Subdirectory nesting is allowed
- — Detailed documentation (English)
rules/<rule-name>.md - — Detailed documentation (Japanese)
rules/<rule-name>.ja.md - Add a new row to the Available Rules table in and
README.mdREADME.ja.md
レビューの提示方法
Review Presentation Method
作成ファイル数に応じて提示方法を変える:
- 3 ファイル以下: 全ファイルの内容を提示
- 4 ファイル以上: 以下を提示
- ファイル一覧と各ファイルの概要 (1行)
- RULE.md の全内容 (最重要ファイル)
- 「他のファイルも確認しますか?」とユーザーに確認
フィードバックがあれば修正してから次に進む。
Adjust the presentation method according to the number of created files:
- 3 files or less: Present the full content of all files
- 4 files or more: Present the following:
- File list and 1-line summary for each file
- Full content of RULE.md (the most important file)
- Confirm with the user: "Would you like to check other files as well?"
Make revisions based on user feedback before proceeding to the next step.
プロジェクト固有情報の除外チェック
Project-specific Information Exclusion Check
ルールは公開リポジトリに登録されるため、作成したファイルに以下が含まれていないか細心の注意を払う:
- プロジェクト固有のファイルパス、URL、ドメイン名
- 社内システムやサービスの名前
- 認証情報、トークン、API キー
- 個人名、メールアドレス、チーム名
- 社内ドキュメントへのリンク
- その他、公開すべきでない情報
知見を汎用化する際に具体例が必要な場合は、プレースホルダー (, 等) に置き換える。
チェック結果をユーザーに報告し、問題がないことを確認してから次に進む。
<project-name><your-domain>Since the rule will be registered in a public repository, carefully check that the created files do not contain the following sensitive information:
- Project-specific file paths, URLs, domain names
- Internal system or service names
- Authentication credentials, tokens, API keys
- Personal names, email addresses, team names
- Links to internal documents
- Other information that should not be disclosed publicly
If specific examples are needed when generalizing insights, replace them with placeholders (such as , etc.). Report the check result to the user and confirm there are no issues before proceeding.
<project-name><your-domain>Step 4.5: セルフレビュー
Step 4.5: Self-review
PR 作成前に以下を確認する:
- 必要なファイルが揃っているか — 以下のファイルが存在することを確認する:
- が存在すること (詳細ドキュメント 英語)
./rules/<rule-name>.md - が存在すること (詳細ドキュメント 日本語)
./rules/<rule-name>.ja.md - が存在すること
./rules/<rule-name>/RULE.md - ルールが参照するすべてのファイルが 配下に存在すること
./rules/<rule-name>/ - と
README.mdの Available Rules テーブルに新しいルールのエントリが追加されていることREADME.ja.md
- RULE.md が命令形で記述されているか — 「〜してください」ではなく「〜する」の形式
- ルールの内容が汎用的か — 特定プロジェクトでしか適用できないルールになっていないか
- 参照ファイルのパスが適切か — ユーザーのプロジェクトルートに展開されることを考慮
- README テーブルが既存行と同じフォーマットか — HTML タグ、改行、code block の書き方を既存行と比較
問題が見つかった場合は修正してからユーザーに報告する。
Verify the following items before creating the PR:
- All required files are present — Confirm the following files exist:
- exists (English detailed documentation)
./rules/<rule-name>.md - exists (Japanese detailed documentation)
./rules/<rule-name>.ja.md - exists
./rules/<rule-name>/RULE.md - All files referenced by the rule exist under
./rules/<rule-name>/ - A new rule entry has been added to the Available Rules table in and
README.mdREADME.ja.md
- RULE.md is written in imperative form — Use "Do X" format instead of "Please do X"
- Rule content is generic — Ensure the rule is not only applicable to a specific project
- Reference file paths are appropriate — Consider that they will be deployed to the user's project root directory
- README table matches the format of existing rows — Compare HTML tags, line breaks, code block writing style with existing rows
If any issues are found, fix them before reporting to the user.
Step 5: PR の作成
Step 5: PR Creation
以下の内容をユーザーに提示し、push と PR 作成の許可を明示的に得てから実行する:
- push 先リポジトリとブランチ名
- コミットに含まれるファイル一覧
- プロジェクト固有情報が含まれていないことの最終確認
許可を得たら、以下を実行する:
bash
cd /tmp/contribute-rule
git checkout -b add-rule/<rule-name>
git add rules/<rule-name>/ README.md README.ja.md
git commit -m "add <rule-name> rule"
git push -u origin add-rule/<rule-name>PR を作成する:
bash
gh pr create \
--repo <repo> \
--head add-rule/<rule-name> \
--title "Add <rule-name> rule" \
--body "## Summary
- <Step 2 で整理したルールの目的>Present the following content to the user, and execute the operations only after explicitly obtaining permission to push and create the PR:
- Target repository for push and branch name
- List of files included in the commit
- Final confirmation that no project-specific information is included
After obtaining permission, execute the following:
bash
cd /tmp/contribute-rule
git checkout -b add-rule/<rule-name>
git add rules/<rule-name>/ README.md README.ja.md
git commit -m "add <rule-name> rule"
git push -u origin add-rule/<rule-name>Create the PR:
bash
gh pr create \
--repo <repo> \
--head add-rule/<rule-name> \
--title "Add <rule-name> rule" \
--body "## Summary
- <Rule purpose organized in Step 2>Files
Files
- rules/<rule-name>/RULE.md
- <その他の追加ファイル一覧>
- rules/<rule-name>/RULE.md
- <List of other added files>
Test plan
Test plan
- curl -fsSL .../rules/install.sh | bash -s -- <rule-name> でインストールできること
- .claude/rules/<rule-name>.md が正しく配置されること
- 参照ファイルがカレントディレクトリに正しく配置されること "
作成された PR の URL をユーザーに報告する。- curl -fsSL .../rules/install.sh | bash -s -- <rule-name> runs successfully
- .claude/rules/<rule-name>.md is placed correctly
- Reference files are placed correctly in the current directory "
Report the URL of the created PR to the user.エラー時の対応
Error Handling
- 失敗 →
gh auth statusを案内gh auth login - clone 失敗 → ネットワーク接続の確認を案内
- push 失敗 → リポジトリへの write 権限を確認するよう案内。fork の利用を提案
- PR 作成失敗で同名ブランチが既存 → ブランチ名にサフィックス (等) を付与して再試行
-v2
- failure → Guide user to run
gh auth statusgh auth login - Clone failure → Guide user to check network connection
- Push failure → Guide user to confirm write permission to the repository, propose using a fork if needed
- PR creation fails due to existing branch with the same name → Add a suffix (such as etc.) to the branch name and retry
-v2
フォールバック
Fallback
add-rule.md が clone 先に存在しない場合、以下の最低限の構成で作成する:
- にルールの内容を記述
rules/<rule-name>/RULE.md - 参照ファイルがあれば同ディレクトリに配置
- README のテーブルは手動で更新するようユーザーに案内する
If add-rule.md does not exist in the cloned repository, create the rule with the following minimum configuration:
- Write the rule content in
rules/<rule-name>/RULE.md - Place reference files in the same directory if available
- Guide the user to manually update the README table