write-rules

write-rules

Create Claude Code rule files for .claude/rules/. Writes conventions and shared guidelines that auto-inject into context. Use for path-specific coding conventions or shared project guidelines. NOT for constitution/laws (use <law> in CLAUDE.md instead).

7звезд
2форков
Обновлено 1/9/2026
SKILL.md
readonlyread-only
name
write-rules
description

Create Claude Code rule files for .claude/rules/. Writes conventions and shared guidelines that auto-inject into context. Use for path-specific coding conventions or shared project guidelines. NOT for constitution/laws (use <law> in CLAUDE.md instead).

Rule Creator

Create modular rule files for conventions and shared guidelines.

Core Principles

  1. Rules = Conventions - Shared guidelines, lower priority than <law>
  2. < 50 lines - Auto-injected = token expensive
  3. Use paths: - Scope rules to relevant files only
  4. No procedures - How-to belongs in skills
  5. NOT for laws - Constitution uses <law> in CLAUDE.md

Rule Structure

.claude/rules/
├── code-style.md         # Style conventions (global)
├── api/
│   └── conventions.md    # paths: src/api/**
└── testing/
    └── guidelines.md     # paths: **/*.test.ts

File Format

Global Rule (no paths:)

---
# No paths field = applies to ALL contexts
---

# Rule Title

- Constraint 1
- Constraint 2

Path-Scoped Rule

---
paths: src/api/**/*.ts
---

# API Rules

- All endpoints MUST validate input
- MUST use standard error format

Glob Patterns

Pattern Matches
**/*.ts All TypeScript files
src/api/** All under src/api/
*.md Markdown in root only
{src,lib}/**/*.ts Multiple directories
**/*.{ts,tsx} Multiple extensions

Example: Code Style Convention

# .claude/rules/code-style.md
---
# Global - no paths
---

# Code Style

- Prefer const over let
- Use descriptive variable names
- Keep functions under 50 lines

Example: Path-Scoped Convention

# .claude/rules/api/conventions.md
---
paths: src/api/**/*.ts
---

# API Conventions

- Use async/await, not callbacks
- Return consistent response shapes
- Log errors with context

Validation Checklist

Before creating a rule:

  • [ ] Is this a convention/guideline, NOT a law? (laws use <law> in CLAUDE.md)
  • [ ] < 50 lines?
  • [ ] Does it need paths: scoping?
  • [ ] Not duplicating existing rules?
  • [ ] Written in imperative form?

References

You Might Also Like

Related Skills

coding-agent

coding-agent

179Kdev-codegen

Run Codex CLI, Claude Code, OpenCode, or Pi Coding Agent via background process for programmatic control.

add-uint-support

add-uint-support

97Kdev-codegen

Add unsigned integer (uint) type support to PyTorch operators by updating AT_DISPATCH macros. Use when adding support for uint16, uint32, uint64 types to operators, kernels, or when user mentions enabling unsigned types, barebones unsigned types, or uint support.

at-dispatch-v2

at-dispatch-v2

97Kdev-codegen

Convert PyTorch AT_DISPATCH macros to AT_DISPATCH_V2 format in ATen C++ code. Use when porting AT_DISPATCH_ALL_TYPES_AND*, AT_DISPATCH_FLOATING_TYPES*, or other dispatch macros to the new v2 API. For ATen kernel files, CUDA kernels, and native operator implementations.

skill-writer

skill-writer

97Kdev-codegen

Guide users through creating Agent Skills for Claude Code. Use when the user wants to create, write, author, or design a new Skill, or needs help with SKILL.md files, frontmatter, or skill structure.

Implements JavaScript classes in C++ using JavaScriptCore. Use when creating new JS classes with C++ bindings, prototypes, or constructors.

Creates JavaScript classes using Bun's Zig bindings generator (.classes.ts). Use when implementing new JS APIs in Zig with JSC integration.