OpenParable
Skip to content
← Back to skills

Write Rules

Agent Building
write-rules

Write Rules is an Agent Skill for agent building published in the majiayu000/claude-skill-registry repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

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).

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/majiayu000/claude-skill-registry/blob/HEAD/skills/development/write-rules/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/write-rules, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

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

PatternMatches
**/*.tsAll TypeScript files
src/api/**All under src/api/
*.mdMarkdown in root only
{src,lib}/**/*.tsMultiple 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