rule-creator
Original:🇺🇸 English
Translated
3 scriptsChecked / no sensitive code detected
Creates rule files for the Claude Code framework. Rules are markdown files in .claude/rules/ that are auto-loaded by Claude Code.
3installs
Sourceoimiragieo/agent-studio
Added on
NPX Install
npx skill4agent add oimiragieo/agent-studio rule-creatorTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Rule Creator
Create rule files in . Rules are auto-discovered by Claude Code and loaded into agent context.
.claude/rules/Step 0: Check for Existing Rule
Before creating, check if rule already exists:
bash
test -f .claude/rules/<rule-name>.md && echo "EXISTS" || echo "NEW"If EXISTS → invoke
Skill({ skill: "artifact-updater", args: "--type rule --path .claude/rules/<rule-name>.md --changes '...'" })If NEW → continue with Step 0.5.
Step 0.5: Companion Check
Before proceeding with creation, run the ecosystem companion check:
- Use from
companion-check.cjs.claude/lib/creators/companion-check.cjs - Call to identify companion artifacts
checkCompanions("rule", "{rule-name}") - Review the companion checklist — note which required/recommended companions are missing
- Plan to create or verify missing companions after this artifact is complete
- Include companion findings in post-creation integration notes
This step is informational (does not block creation) but ensures the full artifact ecosystem is considered.
When to Use
- Creating project-specific coding guidelines
- Documenting framework conventions
- Establishing team standards
- Defining workflow protocols
Rule File Format
Rules are simple markdown files:
markdown
# Rule Name
## Section 1
- Guideline 1
- Guideline 2
## Section 2
- Guideline 3
- Guideline 4Example: testing.md
markdown
# Testing
## Test-Driven Development
- Use TDD for new features and bug fixes (Red-Green-Refactor cycle)
- Write failing test first, then minimal code to pass, then refactor
- Never write production code without a failing test first
## Test Organization
- Add unit tests for utilities and business logic
- Add integration tests for API boundaries
- Keep tests deterministic and isolated (no shared state)
- Place test files in `tests/` directory mirroring source structureCreation Workflow
Step 1: Validate Inputs
javascript
// Validate rule name (lowercase, hyphens only)
const ruleName = args.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
// Validate content is not empty
if (!args.content || args.content.trim().length === 0) {
throw new Error('Rule content cannot be empty');
}Step 2: Create Rule File
javascript
const rulePath = `.claude/rules/${ruleName}.md`;
// Format content as markdown
const content = args.content.startsWith('#')
? args.content
: `# ${ruleName.replace(/-/g, ' ').replace(/\b\w/g, l => l.toUpperCase())}\n\n${args.content}`;
await writeFile(rulePath, content);Step 3: Verify Auto-Discovery
Rules in are automatically loaded by Claude Code. No manual registration needed.
.claude/rules/javascript
// Verify file was created
const fileExists = await exists(rulePath);
if (!fileExists) {
throw new Error('Rule file creation failed');
}Step 4: Run Post-Creation Integration
javascript
const {
runIntegrationChecklist,
queueCrossCreatorReview,
} = require('.claude/lib/creator-commons.cjs');
await runIntegrationChecklist('rule', rulePath);
await queueCrossCreatorReview('rule', rulePath, {
artifactName: ruleName,
createdBy: 'rule-creator',
});Post-Creation Integration
After rule creation, run integration checklist:
javascript
const {
runIntegrationChecklist,
queueCrossCreatorReview,
} = require('.claude/lib/creator-commons.cjs');
// 1. Run integration checklist
const result = await runIntegrationChecklist('rule', '.claude/rules/<rule-name>.md');
// 2. Queue cross-creator review
await queueCrossCreatorReview('rule', '.claude/rules/<rule-name>.md', {
artifactName: '<rule-name>',
createdBy: 'rule-creator',
});
// 3. Review impact report
// Check result.mustHave for failures - address before marking completeIntegration verification:
- Rule file created in
.claude/rules/ - Rule is auto-discovered by Claude Code
- Rule content is clear and actionable
- No conflicts with existing rules
Usage Examples
Create Code Standards Rule
javascript
Skill({
skill: 'rule-creator',
args: `--name code-standards --content "# Code Standards
## Organization
- Prefer small, cohesive files over large ones
- Keep interfaces narrow; separate concerns by feature
## Style
- Favor immutability; avoid in-place mutation
- Validate inputs and handle errors explicitly"`,
});Create Git Workflow Rule
javascript
Skill({
skill: 'rule-creator',
args: `--name git-workflow --content "# Git Workflow
## Commit Guidelines
- Keep changes scoped and reviewable
- Use conventional commits: feat:, fix:, refactor:, docs:, chore:
## Branch Workflow
- Create feature branches from main
- Never force-push to main/master"`,
});Related Skills
- - Update existing rules
artifact-updater - - Create detailed workflows (for complex guidance)
skill-creator
Memory Protocol (MANDATORY)
Before starting:
Read
.claude/context/memory/learnings.mdAfter completing:
- New rule pattern →
.claude/context/memory/learnings.md - Rule creation issue →
.claude/context/memory/issues.md - Guideline decision →
.claude/context/memory/decisions.md
ASSUME INTERRUPTION: If it's not in memory, it didn't happen.
Ecosystem Alignment Contract (MANDATORY)
This creator skill is part of a coordinated creator ecosystem. Any artifact created here must align with and validate against related creators:
- for ownership and execution paths
agent-creator - for capability packaging and assignment
skill-creator - for executable automation surfaces
tool-creator - for enforcement and guardrails
hook-creator - and
rule-creatorfor policy and static checkssemgrep-rule-creator - for standardized scaffolds
template-creator - for orchestration and phase gating
workflow-creator - for user/operator command UX
command-creator
Cross-Creator Handshake (Required)
Before completion, verify all relevant handshakes:
- Artifact route exists in and related routing docs.
.claude/CLAUDE.md - Discovery/registry entries are updated (catalog/index/registry as applicable).
- Companion artifacts are created or explicitly waived with reason.
- passes for the created artifact.
validate-integration.cjs - Skill index is regenerated when skill metadata changes.
Research Gate (Exa First, arXiv Fallback)
For new patterns, templates, or workflows, research is mandatory:
- Use Exa first for implementation and ecosystem patterns.
- If Exa is insufficient, use plus arXiv references.
WebFetch - Record decisions, constraints, and non-goals in artifact references/docs.
- Keep updates minimal and avoid overengineering.
Regression-Safe Delivery
- Follow strict RED -> GREEN -> REFACTOR for behavior changes.
- Run targeted tests for changed modules.
- Run lint/format on changed files.
- Keep commits scoped by concern (logic/docs/generated artifacts).