contribute-rule
Automatically create a PR to register insights, conventions, and best practices obtained from the current project as rules in the TBSten/skills repository. It runs the entire end-to-end process: collecting insights from the project's CLAUDE.md, .claude/rules/ directory and codebase, packaging them as reusable Claude Code rules, and creating the PR. Rules are files stored in .claude/rules/, and unlike skills, they do not require frontmatter. RULE.md serves as the main rule body, while detailed documentation (<rule-name>.md / <rule-name>.ja.md) is placed directly under the rules/ directory. Use when the user requests: "Register insights as rules", "contribute rule", "Share this rule", "Register as a rule", "Compile rules into a PR", "Turn this convention into a rule", "Turn best practices into rules". gh CLI and git must be installed.
NPX Install
npx skill4agent add tbsten/skills contribute-ruleTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →contribute-rule
Prerequisite Check
- Confirm git is installed via
git --version - Confirm gh CLI authentication status via
gh auth status
Step 1: Startup Confirmation
- 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: Insight Collection and Organization
Collection Efficiency Improvement
- Read target files (Get file list via Glob → Parallel read)
- Research related conventions and patterns (Search via Grep → Parallel read)
- 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
- 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
Step 3: Work Directory Preparation and add-rule.md Loading
- Prepare the work directory:
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.md- 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
Step 4: Rule File Creation
/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 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?"
Project-specific Information Exclusion Check
- 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
<project-name><your-domain>Step 4.5: Self-review
- 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
Step 5: PR Creation
- Target repository for push and branch name
- List of files included in the commit
- Final confirmation that no project-specific information is included
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>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
"Error Handling
- 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
- 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