contribute-rule
Automatically collect insights from the current project and create a PR to register them as rules in the TBSten/skills repository.
Prerequisite Check
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
- Confirm gh CLI authentication status via
Step 1: Startup Confirmation
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
Step 2: Insight Collection and Organization
Read the collection targets specified by the user.
Collection Efficiency Improvement
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
- 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: Work Directory Preparation and add-rule.md Loading
- Prepare the work directory:
bash
rm -rf /tmp/contribute-rule
git clone --depth 1 https://github.com/<repo>.git /tmp/contribute-rule
is the repository confirmed in Step 1 (default:
).
- Load the rule creation guide in the cloned repository:
/tmp/contribute-rule/.claude/skills/add-rule.md
After 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: Rule File Creation
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.
rules/<rule-name>/RULE.md
— Main rule body, no YAML frontmatter required, write in imperative form
- 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)
- — Detailed documentation (Japanese)
- Add a new row to the Available Rules table in and
Review Presentation Method
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
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.
Step 4.5: Self-review
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>.ja.md
exists (Japanese detailed documentation)
./rules/<rule-name>/RULE.md
exists
- All files referenced by the rule exist under
- A new rule entry has been added to the Available Rules table in and
- 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 Creation
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
- rules/<rule-name>/RULE.md
- <List of other added files>
## Test plan
- [ ] 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
- failure → Guide user to run
- 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
Fallback
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