Skip to content
Back to skills

Creating Rules

ASecurity

.claude/rules/ディレクトリにベストプラクティスに沿ったルールファイル(.md)を作成します。コーディングルール、テスト規約、セキュリティ要件などのプロジェクト固有の指示を作成する場合に使用します。paths frontmatterによる条件付きルール、適切なファイル名、サブディレクトリ構造をサポートします。

  • 754 stars
  • 0 votes
  • 0 copies
  • 9 views
  • Added February 8, 2026
developmenttypescriptbashreacttestingapidatabasefrontendbackend

Works with

  • api

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill creating-rules --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Creating Rules?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Creating Rules
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-creating-rules/badge)](https://www.skillsdirectory.com/skills/majiayu000-creating-rules)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: creating-rules
description: .claude/rules/ディレクトリにベストプラクティスに沿ったルールファイル(.md)を作成します。コーディングルール、テスト規約、セキュリティ要件などのプロジェクト固有の指示を作成する場合に使用します。paths frontmatterによる条件付きルール、適切なファイル名、サブディレクトリ構造をサポートします。
---

# Creating Rules

`.claude/rules/`ディレクトリにベストプラクティスに沿ったルールファイルを作成する。

## ワークフロー

### 1. 要件の確認

ユーザーに以下を確認:
- ルールのトピック(例:コードスタイル、テスト、セキュリティ)
- 対象ファイル(特定のパスに限定するか)
- サブディレクトリに配置するか

### 2. ルールファイルの作成

#### ディレクトリ構造

```
.claude/rules/
├── code-style.md      # 全体に適用
├── testing.md         # 全体に適用
├── frontend/          # サブディレクトリで整理
│   ├── react.md
│   └── styles.md
└── backend/
    ├── api.md
    └── database.md
```

#### ファイル形式

**条件なしルール(全ファイルに適用):**

```markdown
# [トピック名]

- ルール1
- ルール2
```

**条件付きルール(特定ファイルのみ適用):**

```markdown
---
paths: src/**/*.ts
---

# [トピック名]

- ルール1
- ルール2
```

#### paths globパターン

| パターン | マッチ対象 |
|---------|-----------|
| `**/*.ts` | 全ディレクトリのTypeScriptファイル |
| `src/**/*` | src/以下の全ファイル |
| `*.md` | ルートのMarkdownファイル |
| `src/**/*.{ts,tsx}` | src/以下のTS/TSXファイル |
| `{src,lib}/**/*.ts, tests/**/*.test.ts` | 複数パターンの組み合わせ |

### 3. ベストプラクティス

詳細は [references/best-practices.md](references/best-practices.md) を参照。

**要点:**
- **焦点を絞る**: 1ファイル1トピック
- **説明的なファイル名**: 内容が分かる名前
- **条件付きルールは控えめに**: 本当に必要な場合のみ`paths`を使用
- **サブディレクトリで整理**: 関連ルールをグループ化
- **具体的に記述**: 「コードを適切にフォーマット」より「2スペースインデントを使用」

### 4. 作成後の検証

作成したルールファイルを検証:

1. **配置確認**: `.claude/rules/`に正しく配置されているか
2. **構文確認**: frontmatterのYAML構文が正しいか
3. **パターン確認**: `paths`のglobパターンが意図通りか
4. **内容確認**: ルールが具体的で実行可能か

**検証コマンド例:**
```bash
# ファイル一覧を確認
ls -la .claude/rules/

# frontmatterの構文確認(pathsが正しいか)
head -10 .claude/rules/[ファイル名].md
```

問題があれば修正し、再度検証する。

### 5. 完了確認

- ルールが正しく読み込まれることを確認
- `/memory`コマンドで読み込み状況を確認可能

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.