Creates Claude Code rules (.claude/rules/*.md) with YAML frontmatter and path-specific scoping. Use when creating project rules, coding standards, or conditional guidelines for specific file types.
View on GitHubkkhys/claude-code-marketplace
base
January 21, 2026
Select agents to install to:
npx add-skill https://github.com/kkhys/claude-code-marketplace/blob/main/plugins/base/skills/creating-rules/SKILL.md -a claude-code --skill creating-rulesInstallation paths:
.claude/skills/creating-rules/# Creating Claude Code Rules
Create modular, focused rules for `.claude/rules/` directory.
## Quick Start
**First, ask the user**:
- Rule scope: global (all files) or path-specific (certain file types)?
- Location: `.claude/rules/` (project) or `~/.claude/rules/` (personal)?
Then create a `.md` file:
```markdown
---
paths: src/**/*.ts
---
# TypeScript Guidelines
- Use strict mode
- Prefer interfaces over type aliases for object shapes
- Use explicit return types for exported functions
```
## Rule File Structure
### Global Rules (No Frontmatter)
Apply to all files:
```markdown
# Code Style
- Use 2-space indentation
- Prefer const over let
- No unused variables
```
### Path-Specific Rules (With Frontmatter)
Apply only when Claude works with matching files:
```markdown
---
paths: src/api/**/*.ts
---
# API Development Rules
- All endpoints must include input validation
- Use standard error response format
- Include OpenAPI documentation comments
```
## YAML Frontmatter
### `paths` Field
Single pattern:
```yaml
paths: src/**/*.ts
```
Multiple patterns with brace expansion:
```yaml
paths: src/**/*.{ts,tsx}
```
Comma-separated patterns:
```yaml
paths: {src,lib}/**/*.ts, tests/**/*.test.ts
```
### Glob Patterns Reference
| Pattern | Matches |
|---------|---------|
| `**/*.ts` | All TypeScript files anywhere |
| `src/**/*` | All files under `src/` |
| `*.md` | Markdown files in project root only |
| `src/components/*.tsx` | React components in specific directory |
| `**/*.{ts,tsx}` | TypeScript and TSX files |
| `{src,lib}/**/*.ts` | TypeScript in `src/` or `lib/` |
## Directory Organization
### Basic Structure
```
.claude/rules/
├── code-style.md # General coding standards
├── testing.md # Testing conventions
└── security.md # Security requirements
```
### With Subdirectories
```
.claude/rules/
├── frontend/
│ ├── react.md
│ └── styles.md
├── backend/
│ ├── api.md
│ └── database.md
└── general.md
```
All `.md` files